Salome HOME
Issue #2208: Fix for perpendicular constraint
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin.cpp
index 5d31b18df67c33084c6726d907becdf8b253a288..d3f44a404aedef61c6d26e1c8625bf2a247f79d6 100644 (file)
@@ -107,14 +107,21 @@ const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::intersect(
   new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
 }
 
-const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(
-    const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
+double GeomAPI_Lin::projParam(
+      const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
 {
   const gp_XYZ& aDir = MY_LIN->Direction().XYZ();
   const gp_XYZ& aLoc = MY_LIN->Location().XYZ();
   const gp_XYZ& aPnt = thePoint->impl<gp_Pnt>().XYZ();
-  double aParam = aDir.Dot(aPnt - aLoc);
+  return aDir.Dot(aPnt - aLoc);
+}
 
+const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(
+    const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
+{
+  const gp_XYZ& aDir = MY_LIN->Direction().XYZ();
+  const gp_XYZ& aLoc = MY_LIN->Location().XYZ();
+  double aParam = projParam(thePoint);
   gp_XYZ aResult = aLoc + aDir * aParam;
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
 }