Salome HOME
Linux porting
[modules/shaper.git] / src / GeomAPI / GeomAPI_Lin.cpp
index b76131aa32695a01c70e5b2f54010de1b78dc173..5d31b18df67c33084c6726d907becdf8b253a288 100644 (file)
@@ -1,8 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        GeomAPI_Lin.cpp
-// Created:     29 May 2014
-// Author:      Artem ZHIDKOV
+// Copyright (C) 2014-2017  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pnt.h>
@@ -101,13 +115,24 @@ const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(
   const gp_XYZ& aPnt = thePoint->impl<gp_Pnt>().XYZ();
   double aParam = aDir.Dot(aPnt - aLoc);
 
-  gp_XYZ aResult = aPnt + aDir * aParam;
+  gp_XYZ aResult = aLoc + aDir * aParam;
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
 }
 
+bool GeomAPI_Lin::contains(const std::shared_ptr<GeomAPI_Pnt> thePoint,
+                           const double theLinearTolerance) const
+{
+  if(!thePoint.get()) {
+    return false;
+  }
+
+  return MY_LIN->Contains(thePoint->impl<gp_Pnt>(), theLinearTolerance) == Standard_True;
+}
+
 bool GeomAPI_Lin::isParallel(const std::shared_ptr<GeomAPI_Lin> theLin) const
 {
-  return MY_LIN->Direction().IsParallel(theLin->impl<gp_Lin>().Direction(), Precision::Confusion()) == Standard_True;
+  return MY_LIN->Direction().IsParallel(theLin->impl<gp_Lin>().Direction(),
+                                        Precision::Confusion()) == Standard_True;
 }
 
 bool GeomAPI_Lin::isCoplanar(const std::shared_ptr<GeomAPI_Lin> theLin) const