0029387: Incorrect result of cut a face with several shapes
authoremv <emv@opencascade.com>
Thu, 21 Dec 2017 14:24:28 +0000 (17:24 +0300)
committerapn <apn@opencascade.com>
Tue, 26 Dec 2017 16:06:10 +0000 (19:06 +0300)
Remove section edges having no valid range.
Test case for the issue.

src/BOPAlgo/BOPAlgo_PaveFiller.hxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
tests/bugs/modalg_7/bug29387 [new file with mode: 0644]

index 6bde207..6269e6d 100644 (file)
@@ -490,6 +490,21 @@ protected:
   //! due to being rejected by bounding boxes intersection.
   Standard_EXPORT void ForceInterfEE();
 
+  //! When all section edges are created and no increase of the tolerance
+  //! of vertices put on the section edges is expected, make sure that
+  //! the created sections have valid range.
+  //! If any of the section edges do not have valid range, remove them
+  //! from Face/Face intersection info and from the input <theMSCPB> map.
+  //! Put such edges into <aMicroEdges> map for further unification of their
+  //! vertices in the PostTreatFF method.
+  //!
+  //! All these section edges have already been checked to have valid range.
+  //! Current check is necessary for the edges whose vertices have also
+  //! been put on other section edges with greater tolerance, which has caused
+  //! increase of the tolerance value of the vertices.
+  Standard_EXPORT void RemoveMicroSectionEdges(BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
+                                               TopTools_IndexedMapOfShape& theMicroEdges);
+
 
   TopTools_ListOfShape myArguments;
   BOPDS_PDS myDS;
index ce4e2b9..930e1a8 100644 (file)
@@ -690,7 +690,10 @@ void BOPAlgo_PaveFiller::MakeBlocks()
       }
     }
   }//for (i=0; i<aNbFF; ++i) {
-  // 
+
+  // Remove "micro" section edges
+  RemoveMicroSectionEdges(aMSCPB, aMicroEdges);
+
   // post treatment
   MakeSDVerticesFF(aDMVLV, aDMNewSD);
   PostTreatFF(aMSCPB, aDMExEdges, aDMNewSD, aMicroEdges, aVertsOnRejectedPB, aAllocator);
@@ -3233,3 +3236,79 @@ void BOPAlgo_PaveFiller::PutSEInOtherFaces()
     }
   }
 }
+
+//=======================================================================
+//function : RemoveMicroSectionEdges
+//purpose  : 
+//=======================================================================
+void BOPAlgo_PaveFiller::RemoveMicroSectionEdges
+  (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMSCPB,
+   TopTools_IndexedMapOfShape& theMicroEdges)
+{
+  if (theMSCPB.IsEmpty())
+    // no section edges
+    return;
+
+  // Get all F/F interferences
+  BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
+
+  // Build the new map of section edges avoiding the micro edges
+  BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aSEPBMap;
+  // Analyze all section edges
+  Standard_Integer aNbCPB = theMSCPB.Extent();
+  for (Standard_Integer i = 1; i <= aNbCPB; ++i)
+  {
+    const TopoDS_Shape& aSI = theMSCPB.FindKey(i);
+    const BOPDS_CoupleOfPaveBlocks& aCPB = theMSCPB(i);
+
+    if (aSI.ShapeType() != TopAbs_EDGE)
+    {
+      // Not an edge
+      aSEPBMap.Add(aSI, aCPB);
+      continue;
+    }
+
+    // Get pave block for analysis
+    const Handle(BOPDS_PaveBlock)& aPB = aCPB.PaveBlock1();
+    if (aPB->HasEdge())
+    {
+      // Not a real section edge
+      aSEPBMap.Add(aSI, aCPB);
+      continue;
+    }
+
+    if (!BOPTools_AlgoTools::IsMicroEdge(TopoDS::Edge(aSI), myContext, Standard_False))
+    {
+      // Normal edge
+      aSEPBMap.Add(aSI, aCPB);
+      continue;
+    }
+
+    // Micro edge is found, avoid it in the <theMSCPB> map
+    // and remove from the F/F Intersection info structure
+
+    // Get F/F interference which created this micro edge
+    BOPDS_InterfFF& aFF = aFFs(aCPB.IndexInterf());
+    // Get curve from which this edge has been created
+    BOPDS_Curve& aCurve = aFF.ChangeCurves().ChangeValue(aCPB.Index());
+    // Get all section pave blocks created from this curve
+    BOPDS_ListOfPaveBlock& aLPBC = aCurve.ChangePaveBlocks();
+    // Remove pave block from the list
+    for (BOPDS_ListIteratorOfListOfPaveBlock it(aLPBC); it.More(); it.Next())
+    {
+      if (it.Value() == aPB)
+      {
+        aLPBC.Remove(it);
+        break;
+      }
+    }
+
+    // Add the "micro" edge to the map of "micro" edges for
+    // unification of its vertices in the PostTreatFF method
+    theMicroEdges.Add(aSI);
+  }
+
+  // Overwrite the old map if necessary
+  if (aSEPBMap.Extent() != theMSCPB.Extent())
+    theMSCPB = aSEPBMap;
+}
diff --git a/tests/bugs/modalg_7/bug29387 b/tests/bugs/modalg_7/bug29387
new file mode 100644 (file)
index 0000000..169d311
--- /dev/null
@@ -0,0 +1,29 @@
+puts "========"
+puts "OCC29387"
+puts "========"
+puts ""
+#################################################
+# Incorrect result of cut a face with several shapes
+#################################################
+
+restore [locate_data_file bug29387_obj.brep] s
+restore [locate_data_file bug29387_tools.brep] t
+bclearobjects
+bcleartools
+baddobjects s
+baddctools t
+bfillds
+
+# perform GF operation
+bbuild rgf
+checkshape rgf
+checknbshapes rgf -wire 289 -face 288 -shell 14 -solid 14 -t
+checkprops rgf -s 529.587 -v 0.604529
+
+# perform CUT operation
+bbop result 2
+checkshape result
+checknbshapes result -wire 2 -face 1
+checkprops result -s 470.719
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file