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