Salome HOME
Improve removing point-point coincidence (issue #1548)
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin.cpp
index 79db6e1860b0cb21735d55a06bdd6340767665ce..a9fe074d086af9cb2df9e840bde3c8aa070163bb 100644 (file)
@@ -43,6 +43,15 @@ GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr<GeomAPI_Pnt>& theStart,
 {
 }
 
+GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
+                         const std::shared_ptr<GeomAPI_Dir>& theDirection)
+    : GeomAPI_Interface(newLine(theOrigin->x(), theOrigin->y(), theOrigin->z(),
+                                theOrigin->x() + theDirection->x(),
+                                theOrigin->y() + theDirection->y(),
+                                theOrigin->z() + theDirection->z()))
+{
+}
+
 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::location()
 {
   gp_Pnt aLoc = impl<gp_Lin>().Location();
@@ -74,10 +83,10 @@ const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::intersect(
   gp_Lin2d aPrjLine1 = ProjLib::Project(aPlane, *MY_LIN);
   gp_Lin2d aPrjLine2 = ProjLib::Project(aPlane, theLine->impl<gp_Lin>());
 
-  IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine1);
+  IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine2);
   if (!anInter.IsDone() || anInter.IsEmpty())
   return std::shared_ptr<GeomAPI_Pnt>();
-  const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value();
+  const gp_Pnt2d& anIntPnt2d = anInter.Point(1).Value();
   gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane);
 
   return std::shared_ptr<GeomAPI_Pnt>(