Salome HOME
Merge remote-tracking branch 'origin/CEA_2019'
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_EdgeBuilder.cpp
index f782c16d3be0091c7cce391c6dbe5c4a9e2c9614..9bfc1a50a20364ac3d8c4af28ca2c23fb34d9bd8 100644 (file)
 //
 
 #include <GeomAlgoAPI_EdgeBuilder.h>
+
+#include <GeomAPI_Ax2.h>
+#include <GeomAPI_Ellipse.h>
+
 #include <gp_Pln.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <TopoDS_Edge.hxx>
@@ -132,7 +136,9 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::cylinderAxis(
   aParamMax += aDelta * 0.1;
 
   gp_Pnt aStart(aParamMin * anAxis.Direction().XYZ() + anAxis.Location().XYZ());
+  aStart.Transform(aLoc.Transformation());
   gp_Pnt anEnd(aParamMax * anAxis.Direction().XYZ() + anAxis.Location().XYZ());
+  anEnd.Transform(aLoc.Transformation());
   /*
   gp_Pnt aStart(anAxis.Location().Transformed(aLoc.Transformation()));
   // edge length is 100, "-" because cylinder of extrusion has negative direction with the cylinder
@@ -234,3 +240,29 @@ std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::ellipse(
   aRes->setImpl(new TopoDS_Shape(anEdge));
   return aRes;
 }
+
+std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::ellipticArc(
+    const std::shared_ptr<GeomAPI_Pnt>& theCenter,
+    const std::shared_ptr<GeomAPI_Dir>& theNormal,
+    const std::shared_ptr<GeomAPI_Dir>& theMajorAxis,
+    const double                        theMajorRadius,
+    const double                        theMinorRadius,
+    const std::shared_ptr<GeomAPI_Pnt>& theStart,
+    const std::shared_ptr<GeomAPI_Pnt>& theEnd)
+{
+  std::shared_ptr<GeomAPI_Ax2> anAx2(new GeomAPI_Ax2(theCenter, theNormal, theMajorAxis));
+  GeomAPI_Ellipse anEllipse(anAx2, theMajorRadius, theMinorRadius);
+
+  GeomPointPtr aStartPnt = anEllipse.project(theStart);
+  GeomPointPtr aEndPnt   = anEllipse.project(theEnd);
+
+  double aStartParam, aEndParam;
+  anEllipse.parameter(aStartPnt, Precision::Confusion(), aStartParam);
+  anEllipse.parameter(aEndPnt, Precision::Confusion(), aEndParam);
+
+  BRepBuilderAPI_MakeEdge anEdgeBuilder(anEllipse.impl<gp_Elips>(), aStartParam, aEndParam);
+  GeomEdgePtr aRes(new GeomAPI_Edge);
+  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  aRes->setImpl(new TopoDS_Shape(anEdge));
+  return aRes;
+}