Salome HOME
4682f1fb0c760213ab57f52b24533b17ac25abe7
[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 void GeomAlgoAPI_MakeShape::generated(
31   const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
32 {
33   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
34   if(aBuilder) {
35     const TopTools_ListOfShape& aList =  aBuilder->Generated(theShape->impl<TopoDS_Shape>());
36     TopTools_ListIteratorOfListOfShape it(aList);
37     for(;it.More();it.Next()) {
38       std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
39       aShape->setImpl(new TopoDS_Shape(it.Value()));
40       theHistory.push_back(aShape);
41     }
42   }
43 }
44
45 void GeomAlgoAPI_MakeShape::modified(
46   const std::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       std::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 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
61 {
62   bool isDeleted(false);
63   BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
64   if(aBuilder) {
65     isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
66   }
67   return isDeleted;
68 }