From: skv Date: Fri, 13 Dec 2013 11:22:44 +0000 (+0000) Subject: 0022436: EDF 2438 GEOM: Internal X-Git-Tag: V7_3_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ffe552847944515016a605f8d0d4aa4b9bf8e0da;p=modules%2Fgeom.git 0022436: EDF 2438 GEOM: Internal --- diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx index 4b7520984..0cf6e5ba0 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn1.cxx @@ -635,12 +635,10 @@ void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF, aP2=aNodes(aN2).Transformed(aTrsf); // if (aType==GeomAbs_Cylinder) { - Standard_Real aTolSM; gp_Cylinder aCyl; // - aTolSM=1.523e-6;//~1.-cos(0.1 deg) aCyl=aGAS.Cylinder(); - if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) { + if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) { continue; } } diff --git a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx index 06fdbeff9..3ede89403 100644 --- a/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx +++ b/src/GEOMAlgo/GEOMAlgo_FinderShapeOn2.cxx @@ -881,12 +881,10 @@ if (!aNb && myNbPntsMin) { aP2=aNodes(aN2).Transformed(aTrsf); // if (aType==GeomAbs_Cylinder) { - Standard_Real aTolSM; gp_Cylinder aCyl; // - aTolSM=1.523e-6;//~1.-cos(0.1 deg) aCyl=aGAS.Cylinder(); - if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) { + if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, myTolerance)) { continue; } } diff --git a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx index e50fc4c7c..21e6877b8 100644 --- a/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_SurfaceTools.cxx @@ -140,21 +140,34 @@ Standard_Boolean GEOMAlgo_SurfaceTools::IsCoaxial(const gp_Pnt& aP1, const gp_Cylinder& aCyl, const Standard_Real aTol) { - Standard_Boolean bRet=Standard_False; - Standard_Real aSM; - // - gp_Vec aV12(aP1, aP2); - gp_Dir aD12(aV12); - // - const gp_Ax1& aAxis=aCyl.Axis(); - const gp_Dir& aDAxis=aAxis.Direction(); - // - aSM=fabs(aD12*aDAxis); - if (fabs(1.-aSM) > aTol) { - return bRet; + const gp_XYZ &aLoc = aCyl.Location().XYZ(); + const gp_Ax1 &aAxis = aCyl.Axis(); + const gp_XYZ &aDAxis = aAxis.Direction().XYZ(); + gp_XYZ aDP1 = aP1.XYZ().Subtracted(aLoc); + gp_XYZ aDP2 = aP2.XYZ().Subtracted(aLoc); + Standard_Real aDot1 = aDP1.Dot(aDAxis); + Standard_Real aDot2 = aDP1.Dot(aDAxis); + Standard_Real aTol2 = aTol*aTol; + + // Project P1 and P2 onto a plane with location aLoc and Norm aDAxis. + aDP1.Subtract(aDAxis.Multiplied(aDot1)); + aDP2.Subtract(aDAxis.Multiplied(aDot2)); + + Standard_Real aRadius1 = aDP1.Modulus(); + Standard_Real aRadius2 = aDP2.Modulus(); + Standard_Boolean isOn = Standard_False; + + if (fabs(aRadius1 - aRadius2) <= aTol) { + // Check the deflection of the middle point. + gp_XYZ aMidP = 0.5*(aDP1 + aDP2); + Standard_Real aMidRadius1 = aMidP.Modulus(); + + if (fabs(aRadius1 - aRadius2) <= aTol) { + isOn = Standard_True; + } } - // - return !bRet; + + return isOn; } //======================================================================= //function : IsAnalytic