]> OCCT Git - occt.git/commitdiff
0030522: Modeling Algorithms - BRepBuilderAPI_MakeWire produces different wires depen... IR-2019-03-22
authoremv <emv@opencascade.com>
Tue, 26 Feb 2019 11:06:30 +0000 (14:06 +0300)
committerapn <apn@opencascade.com>
Fri, 22 Mar 2019 14:21:01 +0000 (17:21 +0300)
The following improvements have been implemented in BRepLib_MakeWire class to make it more reliable:
1. Quit adding edges of a wire into result if the current edges have not been added. Return NotDone status.
2. Allow merging not only bounding vertices (connected to only one edge) but also the middle ones, so the multi-connected vertices may appear in the result.

Test case for the issue.

src/BRepLib/BRepLib_MakeWire.cxx
src/BRepLib/BRepLib_MakeWire.hxx
src/BRepLib/BRepLib_MakeWire_1.cxx
tests/bugs/modalg_7/bug30522 [new file with mode: 0644]

index 46f0b4d0f3862743bc7e57ccd241b44e791e0016..949e4b8757ada7e2f37bea9700627d9816164053 100644 (file)
@@ -131,10 +131,10 @@ BRepLib_MakeWire::BRepLib_MakeWire(const TopoDS_Wire& W,
 
 void  BRepLib_MakeWire::Add(const TopoDS_Wire& W)
 {
-  TopExp_Explorer ex(W,TopAbs_EDGE);
-  while (ex.More()) {
-    Add(TopoDS::Edge(ex.Current()));
-    ex.Next();
+  for (TopoDS_Iterator it(W); it.More(); it.Next()) {
+    Add(TopoDS::Edge(it.Value()));
+    if (myError != BRepLib_WireDone)
+      break;
   }
 }
 
index fc498cc1455779da98df26e3f392e0c515d8c6fc..0cf4f27b0a74f2345d02d890dcfad70311daffb2 100644 (file)
 #include <BRepLib_WireError.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <BRepLib_MakeShape.hxx>
 #include <TopTools_ListOfShape.hxx>
-#include <NCollection_Map.hxx>
 #include <Bnd_Box.hxx>
 #include <NCollection_UBTree.hxx>
 
@@ -172,14 +172,14 @@ private:
   };
 
   void CollectCoincidentVertices(const TopTools_ListOfShape& theL,
-    NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
+                                 NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL);
 
   void CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL, 
-    NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV);
+                         TopTools_DataMapOfShapeShape& theO2NV);
 
   void CreateNewListOfEdges(const TopTools_ListOfShape& theL,
-    const NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV,
-    TopTools_ListOfShape& theNewEList);
+                            const TopTools_DataMapOfShapeShape& theO2NV,
+                            TopTools_ListOfShape& theNewEList);
 
   void Add(const TopoDS_Edge& E, Standard_Boolean IsCheckGeometryProximity);
 
index 2ddf25997f07722a260e51ae4e707fcb911890b1..b30ed8f183c7012e5accc8bd9c243c5c380bfd52 100644 (file)
@@ -58,7 +58,7 @@ void  BRepLib_MakeWire::Add(const TopTools_ListOfShape& L)
 
     CollectCoincidentVertices(L, aGrVL);
 
-    NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex> anO2NV; 
+    TopTools_DataMapOfShapeShape anO2NV; 
 
     CreateNewVertices(aGrVL, anO2NV);
 
@@ -188,17 +188,13 @@ void BRepLib_MakeWire::CollectCoincidentVertices(const TopTools_ListOfShape& the
   NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL)
 {
   TopTools_IndexedMapOfShape anAllV;
-  TopTools_ListIteratorOfListOfShape anItL;
   TopTools_IndexedDataMapOfShapeListOfShape aMV2EL;
 
-  TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMV2EL);
-  TopExp_Explorer exp;
-  for (anItL.Initialize(theL); anItL.More(); anItL.Next()) 
-    TopExp::MapShapesAndAncestors(anItL.Value(), TopAbs_VERTEX, TopAbs_EDGE, aMV2EL);
+  TopExp::MapShapes(myShape, TopAbs_VERTEX, anAllV);
 
-  for (int i = 1; i <= aMV2EL.Extent(); i++)
-    if (aMV2EL(i).Extent() == 1)
-      anAllV.Add(aMV2EL.FindKey(i));
+  TopTools_ListIteratorOfListOfShape anItL(theL);
+  for (; anItL.More(); anItL.Next()) 
+    TopExp::MapShapes(anItL.Value(), TopAbs_VERTEX, anAllV);
 
   //aV2CV : vertex <-> its coincident vertices
   NCollection_DataMap<TopoDS_Vertex, NCollection_Map<TopoDS_Vertex>> aV2CV; 
@@ -303,8 +299,8 @@ void BRepLib_MakeWire::CollectCoincidentVertices(const TopTools_ListOfShape& the
 //function : CreateNewVertices
 //purpose  : 
 //=======================================================================
-void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL, 
-                                         NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV)
+void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List<TopoDS_Vertex>>& theGrVL,
+                                         TopTools_DataMapOfShapeShape& theO2NV)
 {
   //map [old vertex => new vertex]
   //note that already existing shape (i.e. the original ones)
@@ -356,7 +352,7 @@ void BRepLib_MakeWire::CreateNewVertices(const NCollection_List<NCollection_List
 //purpose  : 
 //=======================================================================
 void BRepLib_MakeWire::CreateNewListOfEdges(const TopTools_ListOfShape& theL,
-  const NCollection_DataMap<TopoDS_Vertex, TopoDS_Vertex>& theO2NV,
+  const TopTools_DataMapOfShapeShape& theO2NV,
   TopTools_ListOfShape& theNewEList)
 {
   ///create the new list (theNewEList) from the input list L
diff --git a/tests/bugs/modalg_7/bug30522 b/tests/bugs/modalg_7/bug30522
new file mode 100644 (file)
index 0000000..3f3a08c
--- /dev/null
@@ -0,0 +1,30 @@
+puts "REQUIRED All: Wire not done with an error"
+
+puts "========"
+puts "0030522: Modeling Algorithms - BRepBuilderAPI_MakeWire produces different wires depending on the order of parameters"
+puts "========"
+puts ""
+
+restore [locate_data_file bug30522_w_line12.brep] w1
+restore [locate_data_file bug30522_w_line21.brep] w2
+
+if {![regexp "Wire not done with an error" [wire r12 w1 w2]]} {
+  if {[lindex [nbshapes r12] 10] != 8} {
+    puts "Error: The wires have been unified incorrectly"
+  }
+}
+
+wire r21 w2 w1
+
+wire r12u -unsorted w1 w2
+
+wire r21u -unsorted w2 w1
+
+foreach r {r21 r12u r21u} {
+  checkshape $r
+  checknbshapes $r -edge 8 -vertex 8
+}
+
+smallview +Y+Z
+donly r21; fit
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png