1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAlgoAPI_MakeShape.cpp
4 // Created: 20 Oct 2014
5 // Author: Sergey ZARITCHNY
7 #include <GeomAlgoAPI_MakeShape.h>
9 #include <BOPAlgo_Builder.hxx>
10 #include <BRepBuilderAPI_MakeShape.hxx>
11 #include <BRepOffsetAPI_MakePipe.hxx>
12 #include <TopExp_Explorer.hxx>
13 #include <TopTools_ListOfShape.hxx>
14 #include <TopTools_ListIteratorOfListOfShape.hxx>
16 //=================================================================================================
17 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape, const BuilderType theBuilderType)
18 : GeomAPI_Interface(theMkShape),
19 myBuilderType(theBuilderType),
20 myShape(new GeomAPI_Shape())
22 switch (myBuilderType) {
23 case OCCT_BRepBuilderAPI_MakeShape: {
24 myDone = implPtr<BRepBuilderAPI_MakeShape>()->IsDone() == Standard_True;
25 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
28 case OCCT_BOPAlgo_Builder: {
30 myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));
36 //=================================================================================================
37 bool GeomAlgoAPI_MakeShape::isDone() const
42 //=================================================================================================
43 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
48 //=================================================================================================
49 void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
50 ListOfShape& theHistory)
52 TopTools_ListOfShape aList;
53 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
54 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
55 aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
56 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
57 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
58 aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
60 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
61 if(anIt.Value().IsNull()) {
64 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
65 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
66 theHistory.push_back(aShape);
70 //=================================================================================================
71 void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
72 ListOfShape& theHistory)
74 TopTools_ListOfShape aList;
75 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
76 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
77 aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
78 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
79 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
80 aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
82 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
83 if(anIt.Value().IsNull()) {
86 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
87 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
88 theHistory.push_back(aShape);
92 //=================================================================================================
93 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
95 bool isDeleted = false;
96 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
97 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
98 isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
99 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
100 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
101 isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
108 //=================================================================================================
109 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
110 : myBuilderType(OCCT_BRepBuilderAPI_MakeShape),
112 myShape(new GeomAPI_Shape())
116 //=================================================================================================
117 void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType)
119 myBuilderType = theBuilderType;
122 //=================================================================================================
123 void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
128 //=================================================================================================
129 void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)