]> OCCT Git - occt-copy.git/commitdiff
0028113: BOPAlgo_Builder produces invalid shape
authoremv <emv@opencascade.com>
Tue, 17 Jul 2018 09:07:59 +0000 (12:07 +0300)
committeremv <emv@opencascade.com>
Fri, 20 Jul 2018 11:18:54 +0000 (14:18 +0300)
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
tests/bugs/modalg_7/bug28113_1 [new file with mode: 0644]
tests/bugs/modalg_7/bug28113_2 [new file with mode: 0644]

index fcc64ed2a7767fcba0a5a594c39fbf10d4174d7e..9048f0cb35f62f5726fc052ad377b072fcf1295a 100644 (file)
@@ -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 (file)
index 0000000..650fe4b
--- /dev/null
@@ -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 (file)
index 0000000..2bb5cf5
--- /dev/null
@@ -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