Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin2d.cpp
index 2d698c089a4c23149e1294cebacec7820a5a58ee..5267000f3be66ce32a4042b8148834d4b46780cd 100644 (file)
@@ -45,7 +45,7 @@ const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::intersect(
   IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl<gp_Lin2d>());
   if (!anInter.IsDone() || anInter.IsEmpty())
     return boost::shared_ptr<GeomAPI_Pnt2d>();
-  const gp_Pnt2d& aResult = anInter.Point(0).Value();
+  const gp_Pnt2d& aResult = anInter.Point(1).Value();
   return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
 }
 
@@ -56,7 +56,15 @@ const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::project(const boost::share
   const gp_XY& aPnt = thePoint->impl<gp_Pnt2d>().XY();
   double aParam = aDir.Dot(aPnt - aLoc);
 
-  gp_XY aResult = aPnt + aDir * aParam;
+  gp_XY aResult = aLoc + aDir * aParam;
   return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
 }
 
+bool GeomAPI_Lin2d::isRight(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
+{
+  const gp_XY& aDir = MY_LIN2D->Direction().XY();
+  const gp_XY& aLoc = MY_LIN2D->Location().XY();
+  const gp_XY& aPnt = thePoint->impl<gp_Pnt2d>().XY();
+
+  return aDir.Crossed(aPnt - aLoc) > 0;
+}