Salome HOME
Merge remote-tracking branch 'remotes/origin/HigherLevelObjectsHistory'
[modules/shaper.git] / src / GeomAPI / GeomAPI_Curve.cpp
index 9b4f4e26d8e8869945df7aa7a5b24ef34bb93ff5..07fb93d65c858bfc5b3be00cf2bdc4f9ab91ad77 100644 (file)
@@ -1,10 +1,24 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        GeomAPI_Curve.cpp
-// Created:     04 Sep 2014
-// Author:      Mikhail PONIKAROV
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include<GeomAPI_Curve.h>
+#include<GeomAPI_Pnt.h>
 
 #include <TopoDS_Shape.hxx>
 #include <Geom_Curve.hxx>
 #include <BRep_Tool.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS.hxx>
+#include <GeomAdaptor_Curve.hxx>
 
-#define MY_CURVE (*(static_cast<Handle_Geom_Curve*>(myImpl)))
+#define MY_CURVE (*(implPtr<Handle_Geom_Curve>()))
 
 GeomAPI_Curve::GeomAPI_Curve()
-    : GeomAPI_Interface(new Handle_Geom_Curve())
+    : GeomAPI_Interface(new Handle_Geom_Curve()), myStart(0), myEnd(1)
 {
 }
 
@@ -27,8 +42,7 @@ GeomAPI_Curve::GeomAPI_Curve(const std::shared_ptr<GeomAPI_Shape>& theShape)
   const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
   TopoDS_Edge anEdge = TopoDS::Edge(aShape);
   if (!anEdge.IsNull()) {
-    Standard_Real aStart, anEnd;
-    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aStart, anEnd);
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, myStart, myEnd);
     if (!aCurve.IsNull()) {
       setImpl(new Handle(Geom_Curve)(aCurve));
     }
@@ -49,3 +63,10 @@ bool GeomAPI_Curve::isCircle() const
 {
   return !isNull() && MY_CURVE->DynamicType() == STANDARD_TYPE(Geom_Circle);
 }
+
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Curve::getPoint(double theParam)
+{
+  GeomAdaptor_Curve aAdaptor(MY_CURVE, myStart, myEnd);
+  gp_Pnt aPnt = aAdaptor.Value(theParam);
+  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+}