Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAPI / GeomAPI_Cylinder.cpp
index 0e043bbc7126e294a5238fc70483434518de174d..3d73978997f05ef9a4ee8917ea6aea9f9ac9f5d7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-20xx  CEA/DEN, EDF R&D
+// Copyright (C) 2018-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
 //
 // 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <GeomAPI_Cylinder.h>
@@ -82,3 +81,26 @@ bool GeomAPI_Cylinder::isInfinite() const
 {
   return Precision::IsInfinite(myHeight);
 }
+
+//=================================================================================================
+bool GeomAPI_Cylinder::isCoincident(const GeomCylinderPtr theCylinder, const double theTolerance)
+{
+  if (!theCylinder)
+    return false;
+
+  gp_Cylinder* anOther = theCylinder->implPtr<gp_Cylinder>();
+  if (fabs(MY_CYL->Radius() - anOther->Radius()) < theTolerance) {
+    gp_Dir aDir1 = MY_CYL->Position().Direction();
+    gp_Dir aDir2 = anOther->Position().Direction();
+    if (aDir1.IsParallel(aDir2, Precision::Angular())) {
+      gp_Pnt aLoc1 = MY_CYL->Location();
+      gp_Pnt aLoc2 = anOther->Location();
+      gp_Vec aVec12(aLoc1, aLoc2);
+      if (aVec12.SquareMagnitude() < theTolerance * theTolerance ||
+          aVec12.IsParallel(aDir1, Precision::Angular())) {
+        return true;
+      }
+    }
+  }
+  return false;
+}