From 47e3009da9a2d86bdcf01f166e552adeee57af12 Mon Sep 17 00:00:00 2001 From: nbv Date: Fri, 11 Dec 2015 17:53:43 +0300 Subject: [PATCH] 0026841: Boolean operation "bsection" produce invalid result on the attached cases 1. Intersection curve was not bounded by faces domain. It was the reason of big edge tolerance. This problem has been fixed. 2. Interface bopcurves DRAW-command has been changed in order to make possible to reproduce intersection problem. Creation of test case for this issue. --- src/BOPTest/BOPTest_BOPCommands.cxx | 28 ++++++++++++---- src/IntPatch/IntPatch_WLineTool.cxx | 5 +-- src/IntTools/IntTools_FaceFace.cxx | 6 ++-- tests/boolean/bsection/M3 | 47 +++++++++++++++++++++++--- tests/bugs/modalg_6/bug26841_1 | 50 ++++++++++++++++++++++++++++ tests/bugs/modalg_6/bug26841_2 | 51 +++++++++++++++++++++++++++++ 6 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 tests/bugs/modalg_6/bug26841_1 create mode 100644 tests/bugs/modalg_6/bug26841_2 diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index 068c2cb90b..b7bc787e9b 100644 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -104,7 +104,7 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c theCommands.Add("bsection", "use bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]", __FILE__, bsection, g); // - theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2]", + theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] [-p u1 v1 u2 v2]", __FILE__, bopcurves, g); theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni]", __FILE__, mkvolume , g); @@ -562,29 +562,44 @@ Standard_Integer bopcurves (Draw_Interpretor& di, Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone; Standard_Integer i, aNbCurves, aNbPoints; Standard_Real anAppTol, aTolR; + IntSurf_ListOfPntOn2S aListOfPnts; TCollection_AsciiString aNm("c_"), aNp("p_"); // anAppTol = 0.0000001; aToApproxC3d = Standard_True; aToApproxC2dOnS1 = Standard_False; aToApproxC2dOnS2 = Standard_False; + // - if (n > 3) { - if (!strcasecmp(a[3],"-2d")) { + for(Standard_Integer i = 3; i < n; i++) + { + if (!strcasecmp(a[i],"-2d")) { aToApproxC2dOnS1 = Standard_True; aToApproxC2dOnS2 = Standard_True; } - else if (!strcasecmp(a[3],"-2d1")) { + else if (!strcasecmp(a[i],"-2d1")) { aToApproxC2dOnS1 = Standard_True; } - else if (!strcasecmp(a[3],"-2d2")) { + else if (!strcasecmp(a[i],"-2d2")) { aToApproxC2dOnS2 = Standard_True; } + else if (!strcasecmp(a[i],"-p")) { + IntSurf_PntOn2S aPt; + const Standard_Real aU1 = Draw::Atof(a[++i]); + const Standard_Real aV1 = Draw::Atof(a[++i]); + const Standard_Real aU2 = Draw::Atof(a[++i]); + const Standard_Real aV2 = Draw::Atof(a[++i]); + + aPt.SetValue(aU1, aV1, aU2, aV2); + aListOfPnts.Append(aPt); + } else { - di << "Wrong key. To build 2d curves use: bopcurves F1 F2 -2d/-2d1/-2d2 \n"; + di << "Wrong key. To build 2d curves use: bopcurves F1 F2 [-2d/-2d1/-2d2] [-p u1 v1 u2 v2]\n"; return 1; } + } + // IntTools_FaceFace aFF; // @@ -592,6 +607,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di, aToApproxC2dOnS1, aToApproxC2dOnS2, anAppTol); + aFF.SetList(aListOfPnts); // aFF.Perform (aF1, aF2); // diff --git a/src/IntPatch/IntPatch_WLineTool.cxx b/src/IntPatch/IntPatch_WLineTool.cxx index 02208c1f68..49d8635eae 100644 --- a/src/IntPatch/IntPatch_WLineTool.cxx +++ b/src/IntPatch/IntPatch_WLineTool.cxx @@ -448,8 +448,9 @@ static Handle(IntPatch_WLine) Standard_Integer aHashIdx = Standard_Integer(anIdx * theWLine->NbPnts() / 9); - //Store this point. - aNewPointsHash(aHashIdx) = 0; + //Vertex must be stored as VERTEX (HASH = -1) + if (aNewPointsHash(aHashIdx) != -1) + aNewPointsHash(aHashIdx) = 0; } } diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index 2ad7420f69..c309e91d27 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -875,9 +875,9 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, L = aWLine; // - if(!myListOfPnts.IsEmpty()) { - bAvoidLineConstructor = Standard_True; - } + //if(!myListOfPnts.IsEmpty()) { + // bAvoidLineConstructor = Standard_True; + //} Standard_Integer nbp = aWLine->NbPnts(); const IntSurf_PntOn2S& p1 = aWLine->Point(1); diff --git a/tests/boolean/bsection/M3 b/tests/boolean/bsection/M3 index fa0d8193d5..458d847759 100644 --- a/tests/boolean/bsection/M3 +++ b/tests/boolean/bsection/M3 @@ -1,8 +1,47 @@ -puts "TODO #OCC26777 ALL: Error : The length of result shape is" - restore [locate_data_file GEN758_nofog.rle] a -explode a +explode a f + +# see issue #26777 +set GoodNbCurv 1 + +set log [bopcurves a_1 a_2 -2d -p 0.20639206339545224 0.69260832843385300 0.0 0.017002507022347624] +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Tolerance_Reached NbCurv + +set expected_Tolerance_Reached 2.2797192759881918e-005 +set tol_abs_Tolerance_Reached 0.0 +set tol_rel_Tolerance_Reached 1.0e-2 +checkreal "Tolerance Reached" ${Tolerance_Reached} ${expected_Tolerance_Reached} ${tol_abs_Tolerance_Reached} ${tol_rel_Tolerance_Reached} + +if {${NbCurv} != ${GoodNbCurv}} { + puts "Error: ${GoodNbCurv} curves are expected but ${NbCurv} are found!" +} + +smallview +clear + +if {${NbCurv} == 1} { + display c_1 + fit +} else { + for { set i 1 } { ${i} <= ${NbCurv} } {incr i} { + bounds c_$i u1 u2 + cvalue c_$i u2 xx yy zz + point p$i xx yy zz + } + + fit + + for { set i 1 } { ${i} <= ${NbCurv} } {incr i} { + erase p$i + display c_$i + } +} + +xwd ${imagedir}/${casename}_curv.png + +donly a_1 a_2 + bsection result a_1 a_2 checkprops result -l 22.2575 -checksection result +checksection result \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug26841_1 b/tests/bugs/modalg_6/bug26841_1 new file mode 100644 index 0000000000..48c57e89ce --- /dev/null +++ b/tests/bugs/modalg_6/bug26841_1 @@ -0,0 +1,50 @@ +puts "============" +puts "OCC26841" +puts "============" +puts "" +############################### +## Wrong result obtained by intersection algorithm. +############################### + +restore [locate_data_file bug26841c1-prism.brep] p1 +restore [locate_data_file bug26841c1-deck.brep] a1 + +bsection result a1 p1 -n2d2 + +smallview +donly result +fit +display a1 p1 + +set nbshapes_expected " +Number of shapes in shape + VERTEX : 5 + EDGE : 5 + WIRE : 0 + FACE : 0 + SHELL : 0 + SOLID : 0 + COMPSOLID : 0 + COMPOUND : 1 + SHAPE : 11 +" + +checknbshapes result -ref ${nbshapes_expected} -t -m "SECTION" + +regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance +puts "MaxTolerance=$MaxTolerance" + +set expected_MaxTolerance 4.8861509475438473e-005 +set tol_abs_MaxTolerance 0.0 +set tol_rel_MaxTolerance 0.01 +checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance} + +set log [checksection result] + +if { [string compare -nocase $log " nb alone Vertices : 0\n\n"] } { + puts "ERROR: the section is not closed" +} else { + puts "The section is OK" +} + +set only_screen_axo 1 \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug26841_2 b/tests/bugs/modalg_6/bug26841_2 new file mode 100644 index 0000000000..591aec9400 --- /dev/null +++ b/tests/bugs/modalg_6/bug26841_2 @@ -0,0 +1,51 @@ +puts "============" +puts "OCC26841" +puts "============" +puts "" +############################### +## Wrong result obtained by intersection algorithm. +############################### + +restore [locate_data_file bug26841c3-prism.brep] p3 +restore [locate_data_file bug26841c3-deck.brep] a3 + +bsection result a3 p3 -n2d2 + +smallview +donly result +fit +display a3 p3 + + +set nbshapes_expected " +Number of shapes in shape + VERTEX : 10 + EDGE : 10 + WIRE : 0 + FACE : 0 + SHELL : 0 + SOLID : 0 + COMPSOLID : 0 + COMPOUND : 1 + SHAPE : 21 +" + +checknbshapes result -ref ${nbshapes_expected} -t -m "SECTION" + +regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance +puts "MaxTolerance=$MaxTolerance" + +set expected_MaxTolerance 0.00010145423883977269 +set tol_abs_MaxTolerance 0.0 +set tol_rel_MaxTolerance 0.001 +checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance} + +set log [checksection result] + +if { [string compare -nocase $log " nb alone Vertices : 0\n\n"] } { + puts "ERROR: the section is not closed" +} else { + puts "The section is OK" +} + +set only_screen_axo 1 \ No newline at end of file