0029400: Fuse of two edges creates self-interfered shape
authoremv <emv@opencascade.com>
Mon, 25 Dec 2017 08:47:53 +0000 (11:47 +0300)
committeremv <emv@opencascade.com>
Mon, 25 Dec 2017 08:47:53 +0000 (11:47 +0300)
Avoid creation of the edges with too small valid range (not allowing to split the edge) and interfering vertices.
Test case for the issue.

src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx
tests/bugs/modalg_7/bug29400 [new file with mode: 0644]

index cea0789..3ba7b42 100644 (file)
@@ -392,21 +392,42 @@ void BOPAlgo_PaveFiller::SplitPaveBlocks(const TColStd_MapOfInteger& theMEdges,
         myDS->UpdatePaveBlockWithSDVertices(aPBN);
         FillShrunkData(aPBN);
         //
-        if (!aPBN->HasShrunkData()) {
-          // No valid range, unify vertices
+        Standard_Boolean bHasValidRange = aPBN->HasShrunkData();
+        // Take into account that the edge could have really small valid range,
+        // so that the Pave Block cannot be further split. In this case, check if
+        // the vertices of the Pave Block do not interfere. And if they are, unify them.
+        Standard_Boolean bCheckDist = (bHasValidRange && !aPBN->IsSplittable());
+        if (!bHasValidRange || bCheckDist)
+        {
           Standard_Integer nV1, nV2;
           aPBN->Indices(nV1, nV2);
-          if (nV1 != nV2) {
+          if (nV1 == nV2)
+            // Same vertices -> no valid range, no need to unify vertices
+            continue;
+
+          // Decide whether to unify vertices or not
+          if (bCheckDist)
+          {
+            const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
+            const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
+            if (BOPTools_AlgoTools::ComputeVV(aV1, aV2, myFuzzyValue) == 0)
+              // vertices are interfering -> no valid range, unify vertices
+              bHasValidRange = Standard_False;
+          }
+
+          if (!bHasValidRange)
+          {
             BOPDS_Pair aPair;
             aPair.SetIndices(nV1, nV2);
-            if (aMPairs.Add(aPair)) {
+            if (aMPairs.Add(aPair))
+            {
               TColStd_ListOfInteger aLV;
               aLV.Append(nV1);
               aLV.Append(nV2);
               MakeSDVertices(aLV, theAddInterfs);
             }
+            continue;
           }
-          continue;
         }
         //
         // Update the list with new pave block
diff --git a/tests/bugs/modalg_7/bug29400 b/tests/bugs/modalg_7/bug29400
new file mode 100644 (file)
index 0000000..59ff3f0
--- /dev/null
@@ -0,0 +1,21 @@
+puts "========"
+puts "OCC29400"
+puts "========"
+puts ""
+#################################################
+# Fuse of two edges creates self-interfered shape
+#################################################
+
+restore [locate_data_file bug29400_edges.brep] le
+bclearobjects
+bcleartools
+baddcompound le
+bfillds
+bbuild result
+
+checkshape result
+checknbshapes result -vertex 3 -edge 2
+checkprops result -l 1.78839
+if {![regexp "OK" [bopcheck result]]} {
+  puts "Error: the result is self-interfered"
+}