Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pln.cpp
index 41bf4e1c45de4cb3ac099c818e350da862a8b0d5..b21d4a9bbf87d6becd32324e17ca6184c18762a3 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        GeomAPI_Pln.cpp
-// Created:     23 Apr 2014
-// Author:      Mikhail PONIKAROV
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// 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
+//
 
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Ax3.h>
@@ -15,8 +28,6 @@
 
 #include <IntAna_QuadQuadGeo.hxx>
 
-using namespace std;
-
 GeomAPI_Pln::GeomAPI_Pln(const std::shared_ptr<GeomAPI_Ax3>& theAxis)
 : GeomAPI_Interface(new gp_Ax3(theAxis->impl<gp_Ax3>()))
 {
@@ -56,7 +67,7 @@ void GeomAPI_Pln::coefficients(double& theA, double& theB, double& theC, double&
   impl<gp_Pln>().Coefficients(theA, theB, theC, theD);
 }
 
-bool GeomAPI_Pln::isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane, 
+bool GeomAPI_Pln::isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane,
                                const double theTolerance)
 {
   if(!thePlane.get()) {
@@ -65,23 +76,11 @@ bool GeomAPI_Pln::isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane,
 
   const gp_Pln& aMyPln = impl<gp_Pln>();
   const gp_Pln& anOtherPln = thePlane->impl<gp_Pln>();
-  return (aMyPln.Contains(anOtherPln.Location(), theTolerance) && 
+  return (aMyPln.Contains(anOtherPln.Location(), theTolerance) &&
     aMyPln.Axis().IsParallel(anOtherPln.Axis(), theTolerance));
 }
 
-bool GeomAPI_Pln::isParallel(const std::shared_ptr<GeomAPI_Lin> theLine)
-{
-  std::shared_ptr<GeomAPI_XYZ> aLineDir = theLine->direction()->xyz();
-  std::shared_ptr<GeomAPI_XYZ> aLineLoc = theLine->location()->xyz();
-
-  std::shared_ptr<GeomAPI_XYZ> aNormal = direction()->xyz();
-  std::shared_ptr<GeomAPI_XYZ> aLocation = location()->xyz();
-
-  double aDot = aNormal->dot(aLineDir);
-  return Abs(aDot) < Precision::SquareConfusion();
-}
-
-std::shared_ptr<GeomAPI_Pnt> 
+std::shared_ptr<GeomAPI_Pnt>
   GeomAPI_Pln::intersect(const std::shared_ptr<GeomAPI_Lin>& theLine) const
 {
   std::shared_ptr<GeomAPI_XYZ> aLineDir = theLine->direction()->xyz();
@@ -99,7 +98,7 @@ std::shared_ptr<GeomAPI_Pnt>
     new GeomAPI_Pnt(aLineLoc->added(aLineDir->multiplied(aParam))));
 }
 
-std::shared_ptr<GeomAPI_Pnt> 
+std::shared_ptr<GeomAPI_Pnt>
   GeomAPI_Pln::project(const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
 {
   std::shared_ptr<GeomAPI_XYZ> aNormal = direction()->xyz();
@@ -107,7 +106,7 @@ std::shared_ptr<GeomAPI_Pnt>
 
   std::shared_ptr<GeomAPI_XYZ> aVec = thePoint->xyz()->decreased(aLocation);
   double aDot = aNormal->dot(aVec);
-  std::shared_ptr<GeomAPI_XYZ> aProjection = 
+  std::shared_ptr<GeomAPI_XYZ> aProjection =
       aLocation->added(aVec->decreased(aNormal->multiplied(aDot)));
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aProjection));
 }
@@ -120,6 +119,13 @@ double GeomAPI_Pln::distance(const std::shared_ptr<GeomAPI_Pln> thePlane) const
   return aMyPln.Distance(anOtherPln);
 }
 
+double GeomAPI_Pln::distance(const std::shared_ptr<GeomAPI_Pnt> thePoint) const
+{
+  const gp_Pln& aMyPln = impl<gp_Pln>();
+  const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
+  return aMyPln.Distance(aPnt);
+}
+
 void GeomAPI_Pln::translate(const std::shared_ptr<GeomAPI_Dir> theDir, double theDist)
 {
   gp_Vec aVec(theDir->impl<gp_Dir>());