Salome HOME
f28779de5f60f244d5c41124d2541b00fdeefcbf
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_MakeShape.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAlgoAPI_MakeShape.cpp
4 // Created:     20 Oct 2014
5 // Author:      Sergey ZARITCHNY
6
7 #include <GeomAlgoAPI_MakeShape.h>
8 #include <BRepBuilderAPI_MakeShape.hxx>
9 #include <TopTools_ListOfShape.hxx>
10 #include <TopTools_ListIteratorOfListOfShape.hxx>
11 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
12   : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape())
13 {
14   myShape->setImpl((void *)&implPtr<BRepBuilderAPI_MakeShape>()->Shape());
15 }
16
17 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
18   : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
19 {}
20 void GeomAlgoAPI_MakeShape::init(void* theMkShape)
21 {
22   setImpl((void *)implPtr<BRepBuilderAPI_MakeShape>());
23 }
24
25 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
26 {
27   return myShape;
28 }
29
30 /// Returns the  list   of shapes generated   from the shape <theShape>
31 void GeomAlgoAPI_MakeShape::generated(
32   const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
33 {
34   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
35   if(aBuilder) {
36     const TopTools_ListOfShape& aList =  aBuilder->Generated(theShape->impl<TopoDS_Shape>());
37     TopTools_ListIteratorOfListOfShape it(aList);
38     for(;it.More();it.Next()) {
39       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
40       aShape->setImpl(new TopoDS_Shape(it.Value()));
41       theHistory.push_back(aShape);
42     }
43   }
44 }
45
46 /// Returns the  list   of shapes modified   from the shape <theShape>
47 void GeomAlgoAPI_MakeShape::modified(
48   const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
49 {
50   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
51   if(aBuilder) {
52     const TopTools_ListOfShape& aList =  aBuilder->Modified(theShape->impl<TopoDS_Shape>());
53     TopTools_ListIteratorOfListOfShape it(aList);
54     for(;it.More();it.Next()) {
55       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
56       aShape->setImpl(new TopoDS_Shape(it.Value()));
57       theHistory.push_back(aShape);
58     }
59   }
60 }
61
62 /// Returns whether the shape is an edge
63 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
64 {
65   bool isDeleted(false);
66   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
67   if(aBuilder) {
68     isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
69   }
70   return isDeleted;
71 }