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())
24 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
27 case BOPAlgoBuilder: {
28 myShape->setImpl(new TopoDS_Shape(implPtr<BOPAlgo_Builder>()->Shape()));
34 //=================================================================================================
35 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
40 //=================================================================================================
41 void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
42 ListOfShape& theHistory)
44 TopTools_ListOfShape aList;
45 if(myAlgoType == MakeShape) {
46 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
47 aList = aMakeShape->Generated(theShape->impl<TopoDS_Shape>());
48 } else if(myAlgoType == BOPAlgoBuilder) {
49 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
50 aList = aBOPBuilder->Generated(theShape->impl<TopoDS_Shape>());
52 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
53 if(anIt.Value().IsNull()) {
56 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
57 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
58 theHistory.push_back(aShape);
62 //=================================================================================================
63 void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
64 ListOfShape& theHistory)
66 TopTools_ListOfShape aList;
67 if(myAlgoType == MakeShape) {
68 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
69 aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
70 } else if(myAlgoType == BOPAlgoBuilder) {
71 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
72 aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
74 for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) {
75 if(anIt.Value().IsNull()) {
78 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
79 aShape->setImpl(new TopoDS_Shape(anIt.Value()));
80 theHistory.push_back(aShape);
84 //=================================================================================================
85 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
87 bool isDeleted = false;
88 if(myAlgoType == MakeShape) {
89 BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
90 isDeleted = aMakeShape->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
91 } else if(myAlgoType == BOPAlgoBuilder) {
92 BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
93 isDeleted = aBOPBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;