Salome HOME
Regression: do not rotate viewer if sketch plane is selected from a face of a shape
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin.cpp
index 27bd3e0e297fdee97d63db8ed18e4d9ed2661d41..dba5834abc1b7cb596f0cd088ddb4d954480f437 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
 
 #include <gp_Dir.hxx>
 #include <gp_Lin.hxx>
@@ -19,7 +20,7 @@
 #include <Precision.hxx>
 #include <ProjLib.hxx>
 
-#define MY_LIN static_cast<gp_Lin*>(myImpl)
+#define MY_LIN implPtr<gp_Lin>()
 
 static gp_Lin* newLine(const double theStartX, const double theStartY, const double theStartZ,
                        const double theEndX, const double theEndY, const double theEndZ)
@@ -42,6 +43,18 @@ GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr<GeomAPI_Pnt>& theStart,
 {
 }
 
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::location()
+{
+  gp_Pnt aLoc = impl<gp_Lin>().Location();
+  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+}
+
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Lin::direction()
+{
+  const gp_Dir& aDir = impl<gp_Lin>().Direction();
+  return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
+
 double GeomAPI_Lin::distance(const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
 {
   return MY_LIN->Distance(thePoint->impl<gp_Pnt>());
@@ -61,10 +74,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>(