From cf8096eccb631a8502da024c5dd1f7c13ff50e6e Mon Sep 17 00:00:00 2001 From: gka Date: Tue, 21 Jul 2015 10:35:52 +0300 Subject: [PATCH] 0026408: Exception during fixshape procedure. 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 | 12 ++++++++++-- src/ShapeFix/ShapeFix_Solid.cxx | 23 +++++++++++++++++++++-- tests/bugs/heal/bug26408 | 10 ++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/heal/bug26408 diff --git a/src/ShapeFix/ShapeFix_Shell.cxx b/src/ShapeFix/ShapeFix_Shell.cxx index b5e594bb6d..75ca24ea42 100644 --- a/src/ShapeFix/ShapeFix_Shell.cxx +++ b/src/ShapeFix/ShapeFix_Shell.cxx @@ -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; diff --git a/src/ShapeFix/ShapeFix_Solid.cxx b/src/ShapeFix/ShapeFix_Solid.cxx index ce72c5a3eb..f8a6f48c21 100644 --- a/src/ShapeFix/ShapeFix_Solid.cxx +++ b/src/ShapeFix/ShapeFix_Solid.cxx @@ -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 index 0000000000..fea262fd92 --- /dev/null +++ b/tests/bugs/heal/bug26408 @@ -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.