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>
8 #include <BRepBuilderAPI_MakeShape.hxx>
9 #include <BRepOffsetAPI_MakePipe.hxx>
10 #include <TopExp_Explorer.hxx>
11 #include <TopTools_ListOfShape.hxx>
12 #include <TopTools_ListIteratorOfListOfShape.hxx>
14 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
15 : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape())
17 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
20 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape,
21 const std::shared_ptr<GeomAPI_Shape> theWire,
22 const std::shared_ptr<GeomAPI_Shape> theBaseShape)
23 : GeomAPI_Interface(theMkShape),
24 myShape(new GeomAPI_Shape()),
26 myBaseShape(theBaseShape)
28 myShape->setImpl(new TopoDS_Shape(implPtr<BRepBuilderAPI_MakeShape>()->Shape()));
31 GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
32 : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
35 const std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
40 void GeomAlgoAPI_MakeShape::generated(
41 const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
44 BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
46 const TopTools_ListOfShape& aList = aBuilder->Generated(theShape->impl<TopoDS_Shape>());
47 TopTools_ListIteratorOfListOfShape it(aList);
48 for(;it.More();it.Next()) {
49 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
50 aShape->setImpl(new TopoDS_Shape(it.Value()));
51 theHistory.push_back(aShape);
54 } else { // Pipe builder
55 BRepOffsetAPI_MakePipe* aPipeBuilder = implPtr<BRepOffsetAPI_MakePipe>();
57 TopExp_Explorer aShapeExplorer(myWire->impl<TopoDS_Wire>(), TopAbs_EDGE);
58 for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
59 const TopoDS_Shape& aSpine = aShapeExplorer.Current();
60 const TopoDS_Shape& aProfile = theShape->impl<TopoDS_Shape>();
61 if(aProfile.ShapeType() != TopAbs_EDGE && aProfile.ShapeType() != TopAbs_VERTEX) {
64 const TopoDS_Shape& aBaseShape = myBaseShape->impl<TopoDS_Shape>();
65 TopExp_Explorer anExp(aBaseShape, aProfile.ShapeType());
66 Standard_Boolean hasShape = Standard_False;
67 for(; anExp.More(); anExp.Next()) {
68 if(anExp.Current().IsSame(aProfile)) {
69 hasShape = Standard_True;
76 const TopoDS_Shape& aGeneratedShape = aPipeBuilder->Generated(aSpine, aProfile);
77 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
78 aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
79 theHistory.push_back(aShape);
85 void GeomAlgoAPI_MakeShape::modified(
86 const std::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
88 BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
90 const TopTools_ListOfShape& aList = aBuilder->Modified(theShape->impl<TopoDS_Shape>());
91 TopTools_ListIteratorOfListOfShape it(aList);
92 for(;it.More();it.Next()) {
93 std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
94 aShape->setImpl(new TopoDS_Shape(it.Value()));
95 theHistory.push_back(aShape);
100 bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr<GeomAPI_Shape> theShape)
102 bool isDeleted(false);
103 BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
105 isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;