From 3150ecbf3bf32fe4223942184e22bb25103d016e Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 5 Feb 2015 13:57:09 +0300 Subject: [PATCH] Fix pb with 'make test' (complex_objs_ex06.py script): a regression has been introduced with implementation of issue 0022745 --- src/GEOMImpl/GEOMImpl_HealingDriver.cxx | 17 +++------- src/ShHealOper/ShHealOper_Sewing.cxx | 42 +++++++++++-------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index edce49658..bc60c781a 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -450,26 +450,19 @@ Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, { Standard_Real aTol = theHI->GetTolerance(); - TopoDS_Compound faceCompound; + TopoDS_Compound aCompound; BRep_Builder builder; - builder.MakeCompound( faceCompound ); + builder.MakeCompound( aCompound ); - TopExp_Explorer faceExp( theOriginalShape, TopAbs_FACE ); - for ( ; faceExp.More(); faceExp.Next() ) - builder.Add( faceCompound, faceExp.Current() ); - + builder.Add( aCompound, theOriginalShape ); Handle(TColStd_HSequenceOfTransient) otherObjs = theHI->GetShapes(); for ( int ind = 1; ind <= otherObjs->Length(); ind++) { Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(otherObjs->Value(ind)); - TopoDS_Shape aShape = aRefShape->GetValue(); - if (aShape.IsNull()) - Standard_NullObject::Raise("Null object given"); - for ( faceExp.Init( aShape, TopAbs_FACE ); faceExp.More(); faceExp.Next() ) - builder.Add( faceCompound, faceExp.Current() ); + builder.Add( aCompound, aRefShape->GetValue() ); } - ShHealOper_Sewing aHealer (faceCompound, aTol); + ShHealOper_Sewing aHealer (aCompound, aTol); // Set non-manifold mode. aHealer.SetNonManifoldMode(isAllowNonManifold); diff --git a/src/ShHealOper/ShHealOper_Sewing.cxx b/src/ShHealOper/ShHealOper_Sewing.cxx index 156808c15..0c2aad55f 100644 --- a/src/ShHealOper/ShHealOper_Sewing.cxx +++ b/src/ShHealOper/ShHealOper_Sewing.cxx @@ -37,12 +37,26 @@ #include #include #include + +namespace +{ + bool cmpNbSubShapes( const TopoDS_Shape& s1, const TopoDS_Shape& s2, TopAbs_ShapeEnum t) + { + int nbNew = 0, nbOld = 0; + TopExp_Explorer exp; + TopTools_MapOfShape shMap; + for ( exp.Init( s1, t ); exp.More(); exp.Next() ) if ( shMap.Add( exp.Current() ) ) ++nbNew; + shMap.Clear(); + for ( exp.Init( s2, t ); exp.More(); exp.Next() ) if ( shMap.Add( exp.Current() ) ) ++nbOld; + return nbNew != nbOld; + } +} + //======================================================================= //function : ShHealOper_Sewing() //purpose : Constructor //======================================================================= - ShHealOper_Sewing::ShHealOper_Sewing (const TopoDS_Shape& theShape, const Standard_Real theTolerance) { @@ -248,29 +262,9 @@ Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShap Standard_Boolean ShHealOper_Sewing::isSewed(const TopoDS_Shape& theShape) const { - // Standard_Integer nbNewShells =0; - // Standard_Integer nbOldShells =0; - // TopExp_Explorer aExpShells(theShape,TopAbs_SHELL); - // for( ; aExpShells.More(); aExpShells.Next()) - // nbNewShells++; - // for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next()) - // nbOldShells++; - // return (nbNewShells != nbOldShells); - - // EAP, 22745: [EDF] Improvement of Sewing operation - // now myInitShape is ALWAYS a compound of faces -> no shells - int nbNew = 0, nbOld = 0; - TopExp_Explorer exp; - for ( exp.Init( theShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbNew; - for ( exp.Init( myInitShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbOld; - if ( nbNew != nbOld ) - return true; - for ( exp.Init( theShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbNew; - for ( exp.Init( myInitShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbOld; - if ( nbNew != nbOld ) - return true; - - return false; + return cmpNbSubShapes( theShape, myInitShape, TopAbs_SHELL ) || + cmpNbSubShapes( theShape, myInitShape, TopAbs_EDGE ) || + cmpNbSubShapes( theShape, myInitShape, TopAbs_VERTEX ); } //======================================================================= -- 2.39.2