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 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
81 aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
82 theHistory.push_back(aShape);
85 TopTools_ListOfShape aList;
86 if(myAlgoType == MakeShape) {
87 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
88 aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
89 } else if(myAlgoType == BOPAlgoBuilder) {
90 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
91 aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
93 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
94 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
95 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
96 theHistory.push_back(aShape);
101 //=================================================================================================
102 void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
103 ListOfShape& theHistory)
105 TopTools_ListOfShape aList;
106 if(myAlgoType == MakeShape) {
107 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
108 aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
109 } else if(myAlgoType == BOPAlgoBuilder) {
110 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
111 aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
113 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
114 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
115 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
116 theHistory.push_back(aShape);
120 //=================================================================================================
121 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
123 bool isDeleted = false;
124 if(myAlgoType == MakeShape) {
125 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
126 isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
127 } else if(myAlgoType == BOPAlgoBuilder) {
128 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
129 isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;