Salome HOME
Edit sketch by popup menu.
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_EdgeBuilder.cpp
1 // File:        GeomAlgoAPI_EdgeBuilder.cpp
2 // Created:     23 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include <GeomAlgoAPI_EdgeBuilder.h>
6 #include <gp_Pln.hxx>
7 #include <BRepBuilderAPI_MakeEdge.hxx>
8 #include <TopoDS_Edge.hxx>
9 #include <TopoDS.hxx>
10 #include <BRep_Tool.hxx>
11 #include <Geom_Plane.hxx>
12
13 boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_EdgeBuilder::line(
14   boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd)
15 {
16   const gp_Pnt& aStart = theStart->impl<gp_Pnt>();
17   const gp_Pnt& anEnd = theEnd->impl<gp_Pnt>();
18
19   if (aStart.IsEqual(anEnd, Precision::Confusion()))
20     return boost::shared_ptr<GeomAPI_Shape>();
21   if (Abs(aStart.SquareDistance(anEnd)) > 1.e+100)
22     return boost::shared_ptr<GeomAPI_Shape>();
23   BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
24   boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
25   TopoDS_Edge anEdge = anEdgeBuilder.Edge();
26   aRes->setImpl(new TopoDS_Shape(anEdge));
27   return aRes;
28 }