From 7bdd5aa22bfc433b84c46bc8499e1d5779d2fbe0 Mon Sep 17 00:00:00 2001 From: emv Date: Tue, 17 Jul 2018 12:07:59 +0300 Subject: [PATCH] 0028113: BOPAlgo_Builder produces invalid shape Boolean operations - avoid fast rebuilding of the face in case its edges have been unified during the intersection. Proceed with the BuilderFace algorithm in this case. Test case for the issue. --- src/BOPAlgo/BOPAlgo_Builder_2.cxx | 17 +++++++++-- tests/bugs/modalg_7/bug28113_1 | 47 +++++++++++++++++++++++++++++++ tests/bugs/modalg_7/bug28113_2 | 20 +++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 tests/bugs/modalg_7/bug28113_1 create mode 100644 tests/bugs/modalg_7/bug28113_2 diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index fcc64ed2a7..9048f0cb35 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -865,6 +865,10 @@ TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace, // possibility of split. TopTools_DataMapOfShapeListOfShape aVerticesCounter; + // Check that the edges of the initial face have not been unified during intersection. + // Otherwise, it will be necessary to check validity of the new wires. + TopTools_MapOfShape aMEdges; + // Update wires of the original face and add them to draft face TopoDS_Iterator aItW(theFace.Oriented(TopAbs_FORWARD)); for (; aItW.More(); aItW.Next()) @@ -895,6 +899,8 @@ TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace, // Check if the original edge is degenerated Standard_Boolean bIsDegenerated = BRep_Tool::Degenerated(aE); + // Check if the original edge is closed on the face + Standard_Boolean bIsClosed = BRep_Tool::IsClosed(aE, theFace); // Check for the splits of the edge const TopTools_ListOfShape* pLEIm = theImages.Seek(aE); @@ -904,13 +910,14 @@ TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace, if (!bIsDegenerated && HasMultiConnected(aE, aVerticesCounter)) return TopoDS_Face(); + // Check edges unification + if (!bIsClosed && !aMEdges.Add(aE)) + return TopoDS_Face(); + aBB.Add(aNewWire, aE); continue; } - // Check if the original edge is closed on the face - Standard_Boolean bIsClosed = BRep_Tool::IsClosed(aE, theFace); - TopTools_ListIteratorOfListOfShape aItLEIm(*pLEIm); for (; aItLEIm.More(); aItLEIm.Next()) { @@ -920,6 +927,10 @@ TopoDS_Face BuildDraftFace(const TopoDS_Face& theFace, if (!bIsDegenerated && HasMultiConnected(aSp, aVerticesCounter)) return TopoDS_Face(); + // Check edges unification + if (!bIsClosed && !aMEdges.Add(aSp)) + return TopoDS_Face(); + aSp.Orientation(anOriE); if (bIsDegenerated) { diff --git a/tests/bugs/modalg_7/bug28113_1 b/tests/bugs/modalg_7/bug28113_1 new file mode 100644 index 0000000000..650fe4be69 --- /dev/null +++ b/tests/bugs/modalg_7/bug28113_1 @@ -0,0 +1,47 @@ +puts "=======" +puts "OCC28113: BOPAlgo_Builder produces invalid shape" +puts "=======" +puts "" + + +restore [locate_data_file bug28113_shapes.brep] s +explode s + +# fix the first shape in compound +# 1. exclude s_1_3 from compsolid +eval compound [lrange [explode s_1 so] 0 1] [lrange [explode s_1 so] 3 end] comp +# fix SI in compound +eval mkvolume v [explode comp f] +checkshape v +checknbshapes v -solid 18 -shell 18 +if {![regexp "OK" [bopcheck v]]} { + puts "Error: unable to rebuild the shape" +} + +# create Compsolid +shape s1 CS +foreach s [explode v so] { add $s s1} + +# perform the operation +bclearobjects +bcleartools +baddobjects s1 +baddtools s_2 s_3 s_4 s_5 +bfillds +bbuild gf +bsplit result + +foreach r {gf result} { + checkshape $r + if {![regexp "OK" [bopcheck $r]]} { + puts "Error: result is a self-interfering shape" + } +} + +checknbshapes gf -wire 417 -face 417 -shell 91 -solid 90 +checkprops gf -s 259559 -v 690192 + +checknbshapes result -wire 417 -face 417 -shell 90 -solid 90 +checkprops result -s 226564 -v 669028 + +checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_7/bug28113_2 b/tests/bugs/modalg_7/bug28113_2 new file mode 100644 index 0000000000..2bb5cf5e78 --- /dev/null +++ b/tests/bugs/modalg_7/bug28113_2 @@ -0,0 +1,20 @@ +puts "=======" +puts "OCC28113: BOPAlgo_Builder produces invalid shape" +puts "=======" +puts "" + + +restore [locate_data_file bug28113_shapes_2.brep] s +explode s +bclearobjects +bcleartools +baddobjects s_1 +baddtools s_2 +bfillds +bsplit result + +checkshape result +checknbshapes result -wire 34 -face 34 -shell 3 -solid 3 +checkprops result -s 26451 -v 107642 + +checkview -display result -2d -path ${imagedir}/${test_image}.png -- 2.39.5