From 9ae5b722cae3fda6da510016c1ccfbf418bb4ced Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 23 Mar 2010 11:08:13 +0000 Subject: [PATCH] Mantis issue 0020706: EDF 1263 GEOM: Suppress faces does notremove faces and adds some more. --- src/GEOMImpl/GEOMImpl_HealingDriver.cxx | 80 ++++++++++++++++++++----- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index 2b937b450..cc54d8189 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -35,8 +35,11 @@ #include #include -#include +#include + #include +#include +#include #include #include @@ -181,21 +184,74 @@ Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI, //function : SupressFaces //purpose : //======================================================================= +void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) +{ + if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND && + theOriginalShape.ShapeType() != TopAbs_COMPSOLID)) + { + ShHealOper_RemoveFace aHealer (theOriginalShape); + Standard_Boolean aResult = aHealer.Perform(theShapesFaces); + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption(aHealer.GetErrorStatus()); + } + else + { + BRep_Builder BB; + TopoDS_Compound CC; + BB.MakeCompound(CC); + + TopTools_MapOfShape mapShape; + TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True); + + for (; It.More(); It.Next()) { + TopoDS_Shape aShape_i = It.Value(); + if (mapShape.Add(aShape_i)) { + // check, if current shape contains at least one of faces to be removed + bool isFound = false; + TopTools_IndexedMapOfShape aShapes_i; + TopExp::MapShapes(aShape_i, aShapes_i); + for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) { + const TopoDS_Shape& aFace_i = theShapesFaces.Value(i); + if (aShapes_i.Contains(aFace_i)) isFound = true; + } + if (isFound) { + TopoDS_Shape anOutSh_i; + SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i); + BB.Add(CC, anOutSh_i); + } + else { + // nothing to do + BB.Add(CC, aShape_i); + } + } + } + theOutShape = CC; + } +} + Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI, const TopoDS_Shape& theOriginalShape, TopoDS_Shape& theOutShape) const { Handle(TColStd_HArray1OfInteger) aFaces = theHI->GetFaces(); - ShHealOper_RemoveFace aHealer (theOriginalShape); - Standard_Boolean aResult = Standard_False; - if (aFaces.IsNull()) // remove all faces - { + + if (aFaces.IsNull()) { + ShHealOper_RemoveFace aHealer (theOriginalShape); aResult = aHealer.Perform(); + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption(aHealer.GetErrorStatus()); } - else - { + else { TopTools_SequenceOfShape aShapesFaces; TopTools_IndexedMapOfShape aShapes; TopExp::MapShapes(theOriginalShape, aShapes); @@ -204,16 +260,10 @@ Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI TopoDS_Shape aFace = aShapes.FindKey(indexOfFace); aShapesFaces.Append(aFace); } - - aResult = aHealer.Perform(aShapesFaces); + SuppressFacesRec(aShapesFaces, theOriginalShape, theOutShape); } - if ( aResult ) - theOutShape = aHealer.GetResultShape(); - else - raiseNotDoneExeption( aHealer.GetErrorStatus() ); - - return aResult; + return Standard_True; } //======================================================================= -- 2.39.2