1 // File: GeomAPI_PlanarEdges.cpp
2 // Created: 06 Oct 2014
3 // Author: Sergey BELASH
5 #include <GeomAPI_Interface.h>
6 #include <GeomAPI_PlanarEdges.h>
8 #include <Standard_TypeDef.hxx>
9 #include <TopAbs_ShapeEnum.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>
20 GeomAPI_PlanarEdges::GeomAPI_PlanarEdges() : GeomAPI_Shape()
22 TopoDS_Compound aBigWireImpl;
23 BRep_Builder aBuilder;
24 aBuilder.MakeCompound(aBigWireImpl);
25 this->setImpl(new TopoDS_Shape(aBigWireImpl));
28 void GeomAPI_PlanarEdges::addEdge(std::shared_ptr<GeomAPI_Shape> theEdge)
30 const TopoDS_Edge& anEdge = theEdge->impl<TopoDS_Edge>();
31 if (anEdge.ShapeType() != TopAbs_EDGE)
33 TopoDS_Shape& aWire = const_cast<TopoDS_Shape&>(impl<TopoDS_Shape>());
34 BRep_Builder aBuilder;
35 aBuilder.Add(aWire, anEdge);
38 std::list<std::shared_ptr<GeomAPI_Shape> > GeomAPI_PlanarEdges::getEdges()
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);
52 bool GeomAPI_PlanarEdges::hasPlane() const {
53 return myOrigin && myNorm && myDirX && myDirY;
56 bool GeomAPI_PlanarEdges::isVertex() const {
60 bool GeomAPI_PlanarEdges::isEdge() const {
64 void GeomAPI_PlanarEdges::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
68 std::shared_ptr<GeomAPI_Pnt> GeomAPI_PlanarEdges::origin() const {
71 void GeomAPI_PlanarEdges::setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX) {
74 std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirX() const {
77 void GeomAPI_PlanarEdges::setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY) {
80 std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::dirY() const {
83 void GeomAPI_PlanarEdges::setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm) {
86 std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::norm() const {