From: emv Date: Thu, 25 Dec 2014 15:08:44 +0000 (+0300) Subject: 0025600: Wrong result of Boolean FUSE operation X-Git-Tag: V6_9_0_beta~214 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=b9f6147d7564d504caed1f8608edde75bee9ccd9 0025600: Wrong result of Boolean FUSE operation class BOPTools_AlgoTools 1. method Standard_Boolean FindPointInFace(const TopoDS_Face& aF, const gp_Pnt& aP, gp_Dir& aDB, gp_Pnt& aPOut, Handle(IntTools_Context)& theContext, GeomAPI_ProjectPointOnSurf& aProjPL, const Standard_Real aDt, const Standard_Real aTolE) Use different method of finding a point in the face if the start and projected points are close to each other. 2. method Standard_Real MinStep3D(const TopoDS_Edge& theE1, const TopoDS_Face& theF1, const BOPTools_ListOfCoupleOfShape& theLCS, const gp_Pnt& aP) The min 3D step has been increased for the spherical faces. Test case for issue CR25600 Correction of test case for issue CR25600 --- diff --git a/src/BOPTools/BOPTools_AlgoTools.cxx b/src/BOPTools/BOPTools_AlgoTools.cxx index f24ef626f4..8a5e9dc9cf 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -1860,7 +1860,7 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF, const Standard_Real aTolE) { Standard_Integer aNbItMax; - Standard_Real aDist, aDTol, aPM; + Standard_Real aDist, aDTol, aPM, anEps; Standard_Boolean bRet; gp_Pnt aP1, aPS; // @@ -1871,6 +1871,7 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF, } bRet = Standard_False; aNbItMax = 15; + anEps = Precision::SquareConfusion(); // GeomAPI_ProjectPointOnSurf& aProj=theContext->ProjPS(aF); // @@ -1884,7 +1885,7 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF, aPS=aProjPL.NearestPoint(); // aPS.SetXYZ(aPS.XYZ()+2.*aTolE*aDB.XYZ()); - aProj.Perform(aPS); + aProj.Perform(aPS); if (!aProj.IsDone()) { return bRet; } @@ -1892,7 +1893,6 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF, aProjPL.Perform(aPS); aPS=aProjPL.NearestPoint(); // - // do { aP1.SetXYZ(aPS.XYZ()+aDt*aDB.XYZ()); // @@ -1907,6 +1907,9 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF, aPOut = aProjPL.NearestPoint(); // gp_Vec aV(aPS, aPOut); + if (aV.SquareMagnitude() < anEps) { + return bRet; + } aDB.SetXYZ(aV.XYZ()); } while (aDist > aDTol && --aNbItMax); // @@ -1948,26 +1951,33 @@ Standard_Real MinStep3D(const TopoDS_Edge& theE1, aR = 0.; aBAS.Initialize(aF, Standard_False); GeomAbs_SurfaceType aSType = aBAS.GetType(); - if (aSType == GeomAbs_Cylinder) { + switch (aSType) { + case GeomAbs_Cylinder: { aR = aBAS.Cylinder().Radius(); + break; } - else if (aSType == GeomAbs_Cone) { + case GeomAbs_Cone: { gp_Lin aL(aBAS.Cone().Axis()); aR = aL.Distance(aP); + break; } - else if (aSType == GeomAbs_Sphere) { + case GeomAbs_Sphere: { + aDtMin = Max(aDtMin, 5.e-4); aR = aBAS.Sphere().Radius(); + break; } - else if (aSType == GeomAbs_Torus) { + case GeomAbs_Torus: { aR = aBAS.Torus().MajorRadius(); + break; } - else if (aSType == GeomAbs_SurfaceOfRevolution) { - aDtMin = 5.e-4; + default: + aDtMin = Max(aDtMin, 5.e-4); + break; } // if (aR > 100.) { - Standard_Real d = Precision::PConfusion(); - aDtMin = sqrt(d*d + 2*d*aR); + Standard_Real d = 10*Precision::PConfusion(); + aDtMin = Max(aDtMin, sqrt(d*d + 2*d*aR)); } // if (aDt > aDtMax) { diff --git a/tests/bugs/modalg_5/bug24154 b/tests/bugs/modalg_5/bug24154 index abe5d0fd21..0c8803c988 100644 --- a/tests/bugs/modalg_5/bug24154 +++ b/tests/bugs/modalg_5/bug24154 @@ -12,19 +12,17 @@ restore [locate_data_file bug24154_b.brep] b2 bop b1 b2 bopcut result -#set square 2.68434e+06 -set square 5.21269e+06 -set volume 7.35468e+07 +set square 2.68434e+06 # Analysis of "nbshapes res" set nb_v_good 18 -set nb_e_good 36 -set nb_w_good 18 -set nb_f_good 18 +set nb_e_good 27 +set nb_w_good 11 +set nb_f_good 11 set nb_sh_good 1 set nb_sol_good 1 set nb_compsol_good 0 set nb_compound_good 1 -set nb_shape_good 93 +set nb_shape_good 70 set 2dviewer 1 diff --git a/tests/bugs/modalg_5/bug25600 b/tests/bugs/modalg_5/bug25600 new file mode 100644 index 0000000000..307abc8181 --- /dev/null +++ b/tests/bugs/modalg_5/bug25600 @@ -0,0 +1,31 @@ +puts "==========" +puts "OCC25600" +puts "==========" +puts "" +#################################################### +# Wrong result of Boolean FUSE operation +#################################################### + +restore [locate_data_file bug25600_helix_pipe.brep] b1 +restore [locate_data_file bug25600_sphere_2.brep] b2 + +bclearobjects +bcleartools +baddobjects b1 +baddtools b2 +bfillds -s +bbop result 1 + +set square 12.2258 + +set nb_v_good 3 +set nb_e_good 6 +set nb_w_good 3 +set nb_f_good 3 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 18 + +set 2dviewer 1