Salome HOME
Task #3005 : To be able to create a group on a whole result
[modules/shaper.git] / src / GeomAPI / GeomAPI_Angle.cpp
index 220141523e52ea07c71701e418dbc84375cbd89d..02e16ef892f84ca629299ab46c8edf1945477d5f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-20xx  CEA/DEN, EDF R&D
+// Copyright (C) 2018-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
 //
 // 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <GeomAPI_Angle.h>
@@ -58,12 +57,18 @@ GeomAPI_Angle::GeomAPI_Angle(const std::shared_ptr<GeomAPI_Edge>& theEdge1,
   gp_Pnt aP;
 
   GeomAPI_ProjectPointOnCurve aProj1(aPoint, aCurve1);
-  if (aProj1.NbPoints() > 0)
+  if (aProj1.NbPoints() > 0) {
     aCurve1->D1(aProj1.LowerDistanceParameter(), aP, anAngle->myDir1);
+    if (aCurve1->Value(aF1).SquareDistance(aPoint) < aCurve1->Value(aL1).SquareDistance(aPoint))
+      anAngle->myDir1.Reverse();
+  }
 
   GeomAPI_ProjectPointOnCurve aProj2(aPoint, aCurve2);
-  if (aProj2.NbPoints() > 0)
+  if (aProj2.NbPoints() > 0) {
     aCurve2->D1(aProj2.LowerDistanceParameter(), aP, anAngle->myDir2);
+    if (aCurve2->Value(aF2).SquareDistance(aPoint) < aCurve2->Value(aL2).SquareDistance(aPoint))
+      anAngle->myDir2.Reverse();
+  }
 
   setImpl(anAngle);
 }