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()
18 : myBuilderType(OCCT_BRepBuilderAPI_MakeShape),
23 //=================================================================================================
24 bool GeomAlgoAPI_MakeShape::isDone() const
29 //=================================================================================================
30 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
35 //=================================================================================================
36 void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
37 ListOfShape& theHistory)
39 TopTools_ListOfShape aList;
40 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
41 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
42 aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
43 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
44 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
45 aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
47 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
48 if(anIt.Value().IsNull()) {
51 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
52 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
53 theHistory.push_back(aShape);
57 //=================================================================================================
58 void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
59 ListOfShape& theHistory)
61 TopTools_ListOfShape aList;
62 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
63 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
64 aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
65 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
66 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
67 aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
69 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
70 if(anIt.Value().IsNull()) {
73 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
74 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
75 theHistory.push_back(aShape);
79 //=================================================================================================
80 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
82 bool isDeleted = false;
83 if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
84 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
85 isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
86 } else if(myBuilderType == OCCT_BOPAlgo_Builder) {
87 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
88 isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
94 //=================================================================================================
95 void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType)
97 myBuilderType = theBuilderType;
100 //=================================================================================================
101 void GeomAlgoAPI_MakeShape::setDone(const bool theFlag)
106 //=================================================================================================
107 void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theShape)
112 //=================================================================================================
113 void GeomAlgoAPI_MakeShape::initialize() {
114 switch (myBuilderType) {
115 case OCCT_BRepBuilderAPI_MakeShape: {
116 myDone = implPtr<BRepBuilderAPI_MakeShape>()->IsDone() == Standard_True;
117 myShape.reset(new GeomAPI_Shape());
118 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
121 case OCCT_BOPAlgo_Builder: {
123 myShape.reset(new GeomAPI_Shape());
124 myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));