Salome HOME
22bde17c0ada382ba535d43dd829125f31331e69
[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(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
15 }
16
17 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
18   : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
19 {}
20
21 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
22 {
23   return myShape;
24 }
25
26 void GeomAlgoAPI_MakeShape::generated(
27   const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
28 {
29   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
30   if(aBuilder) {
31     const TopTools_ListOfShape& aList =  aBuilder->Generated(theShape->impl<TopoDS_Shape>());
32     TopTools_ListIteratorOfListOfShape it(aList);
33     for(;it.More();it.Next()) {
34       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
35       aShape->setImpl(new TopoDS_Shape(it.Value()));
36       theHistory.push_back(aShape);
37     }
38   }
39 }
40
41 void GeomAlgoAPI_MakeShape::modified(
42   const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
43 {
44   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
45   if(aBuilder) {
46     const TopTools_ListOfShape& aList =  aBuilder->Modified(theShape->impl<TopoDS_Shape>());
47     TopTools_ListIteratorOfListOfShape it(aList);
48     for(;it.More();it.Next()) {
49       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
50       aShape->setImpl(new TopoDS_Shape(it.Value()));
51       theHistory.push_back(aShape);
52     }
53   }
54 }
55
56 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
57 {
58   bool isDeleted(false);
59   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
60   if(aBuilder) {
61     isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
62   }
63   return isDeleted;
64 }