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 diff --git a/tests/bugs/modalg_7/bug28123 b/tests/bugs/modalg_7/bug28123 index ce29b7d5b6..7f634f803d 100644 --- a/tests/bugs/modalg_7/bug28123 +++ b/tests/bugs/modalg_7/bug28123 @@ -26,7 +26,7 @@ foreach r {r0 r1 r2 r3 r4} { } checknbshapes r0 -wire 6 -face 6 -shell 1 -solid 1 -checkprops r0 -s 5.2 -v 0.42 +checkprops r0 -s 4.8 -v 0.405134 checknbshapes r1 -wire 25 -face 25 -shell 1 -solid 1 checkprops r1 -s 45921.2 -v 6839.09 @@ -37,6 +37,6 @@ checkprops r2 -s 45780.6 -v 6784.77 checknbshapes r3 -wire 10 -face 10 -shell 2 -solid 2 checkprops r3 -s 142.969 -v 39.5572 -checkprops r4 -l 14.2568 +checkprops r4 -l 14.8225 checkview -display r2 -2d -path ${imagedir}/${test_image}.png