]> OCCT Git - occt.git/commitdiff
0032619: [Regression] Modelling Algorithms - UnifySameDomain ignores shared face
authorjgv <jgv@opencascade.com>
Fri, 15 Oct 2021 04:53:48 +0000 (07:53 +0300)
committersmoskvin <smoskvin@opencascade.com>
Fri, 15 Oct 2021 16:50:25 +0000 (19:50 +0300)
Correct method ShapeUpgrade_UnifySameDomain::UnifyFaces: exclude free boundary edges from unification.

src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx
src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx
tests/bugs/heal/bug32619 [new file with mode: 0644]

index 9f66be38908b7b02e706ddca0cd84de73ad8eef7..8d0e45aedc8d4ccb39df2fe2dd106720ed2cf996 100644 (file)
@@ -2622,11 +2622,29 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
   TopExp::MapShapes (myShape, TopAbs_FACE, aFaceMap);
   for (Standard_Integer i = 1; i <= aFaceMap.Extent(); i++)
     TopExp::MapShapesAndAncestors (aFaceMap(i), TopAbs_EDGE, TopAbs_FACE, aGMapEdgeFaces);
+
+  // creating map of free boundaries
+  TopTools_MapOfShape aFreeBoundMap;
+  // look at only shells not belonging to solids
+  TopExp_Explorer anExplo (myShape, TopAbs_SHELL, TopAbs_SOLID);
+  for (; anExplo.More(); anExplo.Next())
+  {
+    const TopoDS_Shape& aShell = anExplo.Current();
+    TopTools_IndexedDataMapOfShapeListOfShape aEFmap;
+    TopExp::MapShapesAndAncestors (aShell, TopAbs_EDGE, TopAbs_FACE, aEFmap);
+    for (Standard_Integer ii = 1; ii <= aEFmap.Extent(); ii++)
+    {
+      const TopoDS_Edge& anEdge = TopoDS::Edge (aEFmap.FindKey(ii));
+      const TopTools_ListOfShape& aFaceList = aEFmap(ii);
+      if (!BRep_Tool::Degenerated (anEdge) && aFaceList.Extent() == 1)
+        aFreeBoundMap.Add (anEdge);
+    }
+  }
   
   // unify faces in each shell separately
   TopExp_Explorer exps;
   for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next())
-    IntUnifyFaces(exps.Current(), aGMapEdgeFaces);
+    IntUnifyFaces(exps.Current(), aGMapEdgeFaces, aFreeBoundMap);
 
   // gather all faces out of shells in one compound and unify them at once
   BRep_Builder aBB;
@@ -2637,7 +2655,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
     aBB.Add(aCmp, exps.Current());
 
   if (nbf > 0)
-    IntUnifyFaces(aCmp, aGMapEdgeFaces);
+    IntUnifyFaces(aCmp, aGMapEdgeFaces, aFreeBoundMap);
   
   myShape = myContext->Apply(myShape);
 }
@@ -2666,7 +2684,8 @@ static void SetFixWireModes(ShapeFix_Face& theSff)
 //=======================================================================
 
 void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape,
-   TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces)
+                                                 TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
+                                                 const TopTools_MapOfShape& theFreeBoundMap)
 {
   // creating map of edge faces for the shape
   TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
@@ -2723,7 +2742,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
 
       // get connectivity of the edge in the global shape
       const TopTools_ListOfShape& aGList = theGMapEdgeFaces.FindFromKey(edge);
-      if (!myAllowInternal && (aGList.Extent() != 2 || myKeepShapes.Contains(edge))) {
+      if (!myAllowInternal &&
+          (aGList.Extent() != 2 || myKeepShapes.Contains(edge) || theFreeBoundMap.Contains(edge)))
+      {
         // non manifold case is not processed unless myAllowInternal
         continue;
       }
@@ -2811,7 +2832,8 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
         if (aLF.Extent() == 2) {
           const TopoDS_Shape& aE = aMapEF.FindKey(i);
           const TopTools_ListOfShape& aGLF = theGMapEdgeFaces.FindFromKey(aE);
-          if (aGLF.Extent() > 2 || myKeepShapes.Contains(aE)) {
+          if (aGLF.Extent() > 2 || myKeepShapes.Contains(aE) || theFreeBoundMap.Contains(aE))
+          {
             aKeepEdges.Append(aE);
           }
         }
index cb2f6b7d12164a5d0620a599849cf1a4591e347d..d8b5a5a4902fe015afd40c10be1e428b0b70b658 100644 (file)
@@ -169,7 +169,8 @@ protected:
   Standard_EXPORT void UnifyEdges();
 
   void IntUnifyFaces(const TopoDS_Shape& theInpShape,
-                     TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces);
+                     TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
+                     const TopTools_MapOfShape& theFreeBoundMap);
 
   //! Splits the sequence of edges into the sequence of chains
   Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
diff --git a/tests/bugs/heal/bug32619 b/tests/bugs/heal/bug32619
new file mode 100644 (file)
index 0000000..3e4677e
--- /dev/null
@@ -0,0 +1,20 @@
+puts "============================================="
+puts "OCC32619: UnifySameDomain ignores shared face"
+puts "============================================="
+puts ""
+
+restore [locate_data_file bug32619.brep] a
+
+unifysamedom result a
+
+checkshape result
+
+checknbshapes result -t -shell 2 -face 3 -wire 3 -edge 12 -vertex 10
+
+set tolres [checkmaxtol result]
+
+if { ${tolres} > 2.e-7} {
+   puts "Error: bad tolerance of result"
+}
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file