0026408: Exception during fixshape procedure.
authorgka <gka@opencascade.com>
Tue, 21 Jul 2015 07:35:52 +0000 (10:35 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 21 Jul 2015 07:37:07 +0000 (10:37 +0300)
Attached invalid shape is represented by solid containing one face twice.
Protection from such case was added in ShapeFix_Shell class.
Creation of COMPSOLID was modified for case when shells composing COMPSOLID have the same shared faces in order to prevent hanging.
Small modification.Protection to avoid exception
Test-case for issue #26408

src/ShapeFix/ShapeFix_Shell.cxx
src/ShapeFix/ShapeFix_Solid.cxx
tests/bugs/heal/bug26408 [new file with mode: 0644]

index b5e594b..75ca24e 100644 (file)
@@ -863,8 +863,16 @@ Standard_Boolean ShapeFix_Shell::FixFaceOrientation(const TopoDS_Shell& shell,co
   myShell = shell;
   myShape = shell;
   Standard_Integer aNumMultShell =0;
-  for (TopoDS_Iterator iter(shell); iter.More(); iter.Next()) 
-    Lface.Append(iter.Value());
+  Standard_Integer nbF = 0;
+  TopTools_MapOfShape aMapAdded;
+  for (TopoDS_Iterator iter(shell); iter.More(); iter.Next(),nbF++) 
+  {
+    if(aMapAdded.Add(iter.Value()))
+      Lface.Append(iter.Value());
+  }
+  if(Lface.Length() < nbF)
+    done = Standard_True;
+
   TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
   TopExp::MapShapesAndAncestors(myShell,TopAbs_EDGE,TopAbs_FACE,aMapEdgeFaces);
   TopTools_MapOfShape aMapMultiConnectEdges;
index ce72c5a..f8a6f48 100644 (file)
@@ -344,13 +344,30 @@ static Standard_Boolean CreateSolids(const TopoDS_Shape aShape,TopTools_IndexedM
     BRep_Builder aB;
     aB.MakeCompSolid(aCompSolid);
     isDone = (aShape.ShapeType() != TopAbs_COMPSOLID || isDone);
+    Standard_Integer nbSol = 0;
+
     for(TopTools_ListIteratorOfListOfShape lItSh(lshells);lItSh.More(); lItSh.Next()) {
       if(ShellSolid.Contains(lItSh.Value())) {
-        for(TopExp_Explorer aExpSol(ShellSolid.FindFromKey(lItSh.Value()),TopAbs_SOLID);aExpSol.More(); aExpSol.Next())
+        const TopoDS_Shape& aShape = ShellSolid.FindFromKey(lItSh.Value());
+        TopExp_Explorer aExpSol(aShape, TopAbs_SOLID);
+       
+        for(;aExpSol.More(); aExpSol.Next())
+        {
           aB.Add(aCompSolid,aExpSol.Current());
-        ShellSolid.ChangeFromKey(lItSh.Value()) = aCompSolid;
+          nbSol++;
+        }
+      
       }
     }
+    if(nbSol >1)
+    {
+      for(TopTools_ListIteratorOfListOfShape lItSh1(lshells);lItSh1.More(); lItSh1.Next()) 
+      {
+        if(ShellSolid.Contains(lItSh1.Value())) 
+          ShellSolid.ChangeFromKey(lItSh1.Value()) = aCompSolid;
+      }
+    }
+    
   }
   for(Standard_Integer kk =1 ; kk <= ShellSolid.Extent();kk++)
     if(!aMapSolids.Contains(ShellSolid.FindFromIndex(kk)))
@@ -448,6 +465,8 @@ Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)
       mySolid  = TopoDS::Solid(tmpShape);
     }
     else {
+      status = Standard_True;
+      myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
       TopoDS_Iterator aIt(tmpShape,Standard_False);
       Context()->Replace(tmpShape,aIt.Value());
       SendFail (Message_Msg ("FixAdvSolid.FixShell.MSG10")); // Solid can not be created from open shell. 
diff --git a/tests/bugs/heal/bug26408 b/tests/bugs/heal/bug26408
new file mode 100644 (file)
index 0000000..fea262f
--- /dev/null
@@ -0,0 +1,10 @@
+puts "========"
+puts "OCC26408"
+puts "========"
+puts ""
+#######################################
+# Exception during fixshape procedure
+#######################################
+
+restore [locate_data_file OCC26408-shape_1.brep] a
+fixshape r a 1.e-7 1.