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 AlgoType theAlgoType)
18 : GeomAPI_Interface(theMkShape),
19 myAlgoType(theAlgoType),
20 myShape(new GeomAPI_Shape())
25 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
28 case BOPAlgoBuilder: {
29 myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));
35 //=================================================================================================
36 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape,
37 const std::shared_ptr<GeomAPI_Shape> theWire,
38 const std::shared_ptr<GeomAPI_Shape> theBaseShape)
39 : GeomAPI_Interface(theMkShape),
41 myShape(new GeomAPI_Shape()),
43 myBaseShape(theBaseShape)
45 myShape->setImpl(new TopoDS_Shape(implPtr<BRepOffsetAPI_MakePipe>()->Shape()));
48 //=================================================================================================
49 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
54 //=================================================================================================
55 void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
56 ListOfShape& theHistory)
58 if(myAlgoType == MakePipe) {
59 BRepOffsetAPI_MakePipe* aMakePipe = implPtr<BRepOffsetAPI_MakePipe>();
60 TopExp_Explorer aShapeExplorer(myWire->impl<TopoDS_Wire>(), TopAbs_EDGE);
61 for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
62 const TopoDS_Shape& aSpine = aShapeExplorer.Current();
63 const TopoDS_Shape& aProfile = theShape->impl<TopoDS_Shape>();
64 if(aProfile.ShapeType() != TopAbs_EDGE && aProfile.ShapeType() != TopAbs_VERTEX) {
67 const TopoDS_Shape& aBaseShape = myBaseShape->impl<TopoDS_Shape>();
68 TopExp_Explorer anExp(aBaseShape, aProfile.ShapeType());
69 Standard_Boolean hasShape = Standard_False;
70 for(; anExp.More(); anExp.Next()) {
71 if(anExp.Current().IsSame(aProfile)) {
72 hasShape = Standard_True;
79 const TopoDS_Shape& aGeneratedShape = aMakePipe->Generated(aSpine, aProfile);
80 if(aGeneratedShape.IsNull()) {
83 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
84 aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
85 theHistory.push_back(aShape);
88 TopTools_ListOfShape aList;
89 if(myAlgoType == MakeShape) {
90 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
91 aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
92 } else if(myAlgoType == BOPAlgoBuilder) {
93 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
94 aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
96 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
97 if(anIt.Value().IsNull()) {
100 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
101 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
102 theHistory.push_back(aShape);
107 //=================================================================================================
108 void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
109 ListOfShape& theHistory)
111 TopTools_ListOfShape aList;
112 if(myAlgoType == MakeShape) {
113 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
114 aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
115 } else if(myAlgoType == BOPAlgoBuilder) {
116 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
117 aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
119 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
120 if(anIt.Value().IsNull()) {
123 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
124 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
125 theHistory.push_back(aShape);
129 //=================================================================================================
130 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
132 bool isDeleted = false;
133 if(myAlgoType == MakeShape) {
134 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
135 isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
136 } else if(myAlgoType == BOPAlgoBuilder) {
137 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
138 isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;