X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Cylinder.cpp;h=3d73978997f05ef9a4ee8917ea6aea9f9ac9f5d7;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=0e043bbc7126e294a5238fc70483434518de174d;hpb=1e2eaa713f139d2617c80eba9ede62d4e9976bb7;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Cylinder.cpp b/src/GeomAPI/GeomAPI_Cylinder.cpp index 0e043bbc7..3d7397899 100644 --- a/src/GeomAPI/GeomAPI_Cylinder.cpp +++ b/src/GeomAPI/GeomAPI_Cylinder.cpp @@ -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 @@ -12,10 +12,9 @@ // // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -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(); + 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; +}