From d8a24e8394aa8d81638428e25926f32dd32871d0 Mon Sep 17 00:00:00 2001 From: emv Date: Mon, 14 Apr 2014 15:52:02 +0400 Subject: [PATCH] 0024798: Boolean operation CUT produces incorrect result Face classifier has been used to check adjustment of 2d curve for the face. Test case for issue CR24798 --- src/BOPTools/BOPTools_AlgoTools2D.cxx | 37 +++++++++++++++++++++++++++ tests/bugs/modalg_5/bug24798 | 28 ++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/bugs/modalg_5/bug24798 diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cxx b/src/BOPTools/BOPTools_AlgoTools2D.cxx index ecbdcd5a8f..b6b1087b64 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.cxx @@ -53,6 +53,7 @@ #include #include #include +#include static @@ -348,6 +349,42 @@ static //xt } // + { + //check the point with classifier + Standard_Real u,v; + u = u2 + du; + v = v2 + dv; + if (aBAS.IsUPeriodic()) { + aUPeriod = aBAS.UPeriod(); + if ((UMax - UMin - 2*aDelta) > aUPeriod) { + if ((u > (UMin + aDelta + aUPeriod)) || + (u < (UMax - aDelta - aUPeriod))) { + BRepClass_FaceClassifier aClassifier; + aClassifier.Perform(aF, gp_Pnt2d(u, v), aDelta); + TopAbs_State Status = aClassifier.State(); + if (Status == TopAbs_OUT) { + du += (u > (UMin + aDelta + aUPeriod)) ? -aUPeriod : aUPeriod; + } + } + } + } + // + u = u2 + du; + if (aBAS.IsVPeriodic()) { + Standard_Real aVPeriod = aBAS.VPeriod(); + if ((VMax - VMin - 2*aDelta) > aVPeriod) { + if ((v > (VMin + aDelta + aVPeriod)) || + (v < (VMax - aDelta - aVPeriod))) { + BRepClass_FaceClassifier aClassifier; + aClassifier.Perform(aF, gp_Pnt2d(u, v), aDelta); + TopAbs_State Status = aClassifier.State(); + if (Status == TopAbs_OUT) { + dv += (v > (VMin + aDelta + aVPeriod)) ? -aVPeriod : aVPeriod; + } + } + } + } + } // Translation if necessary Handle(Geom2d_Curve) aC2Dx=aC2D; diff --git a/tests/bugs/modalg_5/bug24798 b/tests/bugs/modalg_5/bug24798 new file mode 100644 index 0000000000..235bdeb5b5 --- /dev/null +++ b/tests/bugs/modalg_5/bug24798 @@ -0,0 +1,28 @@ +puts "============" +puts "OCC24798" +puts "============" +puts "" +###################################################### +# Boolean operation CUT produces incorrect result +###################################################### + +restore [locate_data_file bug24798_r1_cut.brep] b1 +restore [locate_data_file bug24798_rectBranch.brep] b2 + +bop b1 b2 +bopcut result + +set square 1826.15 + +# Analysis of "nbshapes res" +set nb_v_good 44 +set nb_e_good 67 +set nb_w_good 29 +set nb_f_good 22 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 1 +set nb_shape_good 165 + +set 2dviewer 1 -- 2.20.1