Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAPI / GeomAPI_Cylinder.cpp
index 35b23e73bf922061f6f45107cd16cec9bb337242..3d73978997f05ef9a4ee8917ea6aea9f9ac9f5d7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-2019  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
@@ -81,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;
+}