Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / GeomAPI / GeomAPI_PlanarEdges.cpp
1 // File:        GeomAPI_PlanarEdges.cpp
2 // Created:     06 Oct 2014
3 // Author:      Sergey BELASH
4
5 #include <GeomAPI_Interface.h>
6 #include <GeomAPI_PlanarEdges.h>
7
8 #include <Standard_TypeDef.hxx>
9 #include <TopAbs_ShapeEnum.hxx>
10
11 #include <TopoDS.hxx>
12 #include <TopoDS_Edge.hxx>
13 #include <TopoDS_Wire.hxx>
14 #include <BRep_Builder.hxx>
15 #include <BRepTools_WireExplorer.hxx>
16 #include <TopExp_Explorer.hxx>
17
18 #include <list>
19
20 GeomAPI_PlanarEdges::GeomAPI_PlanarEdges() : GeomAPI_Shape()
21 {
22   TopoDS_Compound aBigWireImpl;
23   BRep_Builder aBuilder;
24   aBuilder.MakeCompound(aBigWireImpl);
25   this->setImpl(new TopoDS_Shape(aBigWireImpl));
26 }
27
28 void GeomAPI_PlanarEdges::addEdge(std::shared_ptr<GeomAPI_Shape> theEdge)
29 {
30   const TopoDS_Edge& anEdge = theEdge->impl<TopoDS_Edge>();
31   if (anEdge.ShapeType() != TopAbs_EDGE)
32     return;
33   TopoDS_Shape& aWire = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
34   BRep_Builder aBuilder;
35   aBuilder.Add(aWire, anEdge);
36 }
37
38 std::list<std::shared_ptr<GeomAPI_Shape> > GeomAPI_PlanarEdges::getEdges()
39 {
40   TopoDS_Shape& aShape = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
41   //BRepTools_WireExplorer aWireExp(TopoDS::Wire(aShape));
42   TopExp_Explorer aWireExp(aShape, TopAbs_EDGE);
43   std::list<std::shared_ptr<GeomAPI_Shape> > aResult;
44   for (; aWireExp.More(); aWireExp.Next()) {
45     std::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
46     anEdge->setImpl(new TopoDS_Shape(aWireExp.Current()));
47     aResult.push_back(anEdge);
48   }
49   return aResult;
50 }