Salome HOME
Add ModelAPI_AttributeIntArray to SWIG
[modules/shaper.git] / src / GeomAPI / GeomAPI_Circ2d.cpp
index d5a67b8f81ec27ffa666ca3400702d061d1d8b71..c809e567e843c9b099b546887e4f33c6931df122 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Circ2d.cpp
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
 #include <gp_Circ2d.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Ax2d.hxx>
+#include <GeomLib_Tool.hxx>
 #include <Geom2d_Circle.hxx>
 #include <Geom2dAPI_ProjectPointOnCurve.hxx>
 #include <Precision.hxx>
 
 #include <IntAna2d_AnaIntersection.hxx>
 
-#define MY_CIRC2D static_cast<gp_Circ2d*>(myImpl)
+#define MY_CIRC2D implPtr<gp_Circ2d>()
 
 static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, const gp_Dir2d theDir,
                             const double theRadius)
@@ -41,25 +44,25 @@ static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY,
   return newCirc2d(theCenterX, theCenterY, aDir, aRadius);
 }
 
-GeomAPI_Circ2d::GeomAPI_Circ2d(const boost::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                               const boost::shared_ptr<GeomAPI_Pnt2d>& theCirclePoint)
+GeomAPI_Circ2d::GeomAPI_Circ2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                               const std::shared_ptr<GeomAPI_Pnt2d>& theCirclePoint)
     : GeomAPI_Interface(
         newCirc2d(theCenter->x(), theCenter->y(), theCirclePoint->x(), theCirclePoint->y()))
 {
 }
 
-GeomAPI_Circ2d::GeomAPI_Circ2d(const boost::shared_ptr<GeomAPI_Pnt2d>& theCenter,
-                               const boost::shared_ptr<GeomAPI_Dir2d>& theDir, double theRadius)
+GeomAPI_Circ2d::GeomAPI_Circ2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+                               const std::shared_ptr<GeomAPI_Dir2d>& theDir, double theRadius)
     : GeomAPI_Interface(
         newCirc2d(theCenter->x(), theCenter->y(), theDir->impl<gp_Dir2d>(), theRadius))
 {
 
 }
 
-const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(
-    const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
+const std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(
+    const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
 {
-  boost::shared_ptr<GeomAPI_Pnt2d> aResult;
+  std::shared_ptr<GeomAPI_Pnt2d> aResult;
   if (!MY_CIRC2D)
     return aResult;
 
@@ -72,22 +75,22 @@ const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(
 
   if (Abs(aDist - MY_CIRC2D->Radius()) < Precision::Confusion()) {
     // Point on the circle
-    aResult = boost::shared_ptr<GeomAPI_Pnt2d>(
+    aResult = std::shared_ptr<GeomAPI_Pnt2d>(
         new GeomAPI_Pnt2d(thePoint->x(), thePoint->y()));
   } else {
     gp_Dir2d aDir(aPoint.XY() - aCenter.XY());
     gp_XY aNewPoint = aCenter.XY() + aDir.XY() * MY_CIRC2D->Radius();
-    aResult = boost::shared_ptr<GeomAPI_Pnt2d>(
+    aResult = std::shared_ptr<GeomAPI_Pnt2d>(
         new GeomAPI_Pnt2d(aNewPoint.X(), aNewPoint.Y()));
   }
 
   return aResult;
 }
 
-const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::center() const
+const std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::center() const
 {
   const gp_Pnt2d& aCenter = MY_CIRC2D->Location();
-  return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
+  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aCenter.X(), aCenter.Y()));
 }
 
 double GeomAPI_Circ2d::radius() const
@@ -95,3 +98,21 @@ double GeomAPI_Circ2d::radius() const
   return MY_CIRC2D->Radius();
 }
 
+//=================================================================================================
+const bool GeomAPI_Circ2d::parameter(const std::shared_ptr<GeomAPI_Pnt2d> thePoint,
+                                   const double theTolerance,
+                                   double& theParameter) const
+{
+  Handle(Geom2d_Circle) aCurve = new Geom2d_Circle(*MY_CIRC2D);
+  return GeomLib_Tool::Parameter(aCurve, thePoint->impl<gp_Pnt2d>(), theTolerance, theParameter) == Standard_True;
+}
+
+//=================================================================================================
+void GeomAPI_Circ2d::D0(const double theU, std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+  Handle(Geom2d_Circle) aCurve = new Geom2d_Circle(*MY_CIRC2D);
+  gp_Pnt2d aPnt;
+  aCurve->D0(theU, aPnt);
+  thePoint.reset(new GeomAPI_Pnt2d(aPnt.X(), aPnt.Y()));
+}
+