]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0022375: [CEA 973] UnionFaces shall not suppress an edge between 2 continuous faces...
authorskv <skv@opencascade.com>
Wed, 23 Oct 2013 14:29:57 +0000 (14:29 +0000)
committerskv <skv@opencascade.com>
Wed, 23 Oct 2013 14:29:57 +0000 (14:29 +0000)
src/BlockFix/BlockFix_UnionFaces.cxx

index 962a776ecdb07f72c726b1b4f2a54317ff3a9a7b..c2d0459f85eff6b22503037be53a4ed63c2c7a07 100644 (file)
@@ -189,6 +189,50 @@ static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
   return aSurface;
 }
 
+//=======================================================================
+//function : IsFacesOfSameSolids
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean IsFacesOfSameSolids
+       (const TopoDS_Face                               &theFace1,
+        const TopoDS_Face                               &theFace2,
+        const TopTools_IndexedDataMapOfShapeListOfShape &theMapFaceSolids)
+{
+  Standard_Boolean isSame = Standard_False;
+
+  if (theMapFaceSolids.Contains(theFace1) &&
+      theMapFaceSolids.Contains(theFace2)) {
+    const TopTools_ListOfShape& aList1 = theMapFaceSolids.FindFromKey(theFace1);
+    const TopTools_ListOfShape& aList2 = theMapFaceSolids.FindFromKey(theFace2);
+
+    if (aList1.Extent() == aList2.Extent()) {
+      TopTools_ListIteratorOfListOfShape anIter1(aList1);
+
+      isSame = Standard_True;
+
+      for (; anIter1.More(); anIter1.Next()) {
+        const TopoDS_Shape                 &aSolid1 = anIter1.Value();
+        TopTools_ListIteratorOfListOfShape  anIter2(aList2);
+
+        for (; anIter2.More(); anIter2.Next()) {
+          if (aSolid1.IsSame(anIter2.Value())) {
+            // Same solid is detected. Break the loop
+            break;
+          }
+        }
+
+        if (!anIter2.More()) {
+          // No same solid is detected. Break the loop.
+          isSame = Standard_False;
+          break;
+        }
+      }
+    }
+  }
+
+  return isSame;
+}
+
 //=======================================================================
 //function : Perform
 //purpose  :
@@ -198,6 +242,12 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
   Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape;
   TopoDS_Shape aResShape = myContext->Apply(Shape);
 
+  // Fill Map of faces as keys and list of solids as items.
+  TopTools_IndexedDataMapOfShapeListOfShape aMapFaceSolids;
+
+  TopExp::MapShapesAndAncestors
+    (Shape, TopAbs_FACE, TopAbs_SOLID, aMapFaceSolids);
+
   // processing each solid
   TopExp_Explorer exps;
   for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
@@ -265,6 +315,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
           if (aProcessed.Contains(anCheckedFace))
             continue;
 
+          // Check if faces belong to same solids.
+          if (!IsFacesOfSameSolids(aFace, anCheckedFace, aMapFaceSolids)) {
+            continue;
+          }
+
           if (IsSameDomain(aFace,anCheckedFace)) {
 
             if (aList.Extent() != 2) {