Salome HOME
Documentation update
[modules/shaper.git] / src / GeomAPI / GeomAPI_Circ.cpp
index dca0897977df88670c05901bb2d102540c16f65f..4346391bd457e6cec033ed857763870f12106d63 100644 (file)
@@ -70,11 +70,11 @@ const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::project(
   GeomAPI_ProjectPointOnCurve aProj(aPoint, aCircle);
   Standard_Integer aNbPoint = aProj.NbPoints();
   if (aNbPoint > 0) {
-    double aMinDistance = 0, aDistance;
+    double aMinDistance = Precision::Infinite(), aDistance;
     for (Standard_Integer j = 1; j <= aNbPoint; j++) {
       gp_Pnt aNewPoint = aProj.Point(j);
       aDistance = aNewPoint.Distance(aPoint);
-      if (!aMinDistance || aDistance < aMinDistance) {
+      if (aDistance < aMinDistance) {
         aMinDistance = aDistance;
         aResult = std::shared_ptr<GeomAPI_Pnt>(
             new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z()));
@@ -92,3 +92,11 @@ const bool GeomAPI_Circ::parameter(const std::shared_ptr<GeomAPI_Pnt> thePoint,
   Handle(Geom_Circle) aCurve = new Geom_Circle(*MY_CIRC);
   return GeomLib_Tool::Parameter(aCurve, thePoint->impl<gp_Pnt>(), theTolerance, theParameter) == Standard_True;
 }
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Circ::normal() const
+{
+  const gp_Ax1& anAxis = MY_CIRC->Axis();
+  const gp_Dir& aDir = anAxis.Direction();
+  return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}