X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_PartitionDriver.cxx;h=b079521e8d52b52f7152fb4e6882f403e8f0ae04;hb=da257d8d0634353fccde683e9c2f72320dfd8df1;hp=db6b6e381aaf657f2669d65e1ba4ba2ee62389f7;hpb=1c87498d87e3427bff66dce69d228b23c9d1e26b;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx index db6b6e381..b079521e8 100644 --- a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -1,18 +1,18 @@ // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -36,12 +36,13 @@ #include #include +#include +#include #include #include #include #include -#include -#include +#include #include #include @@ -54,29 +55,54 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_PartitionDriver::GetID() { static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16"); - return aPartitionDriver; + return aPartitionDriver; } //======================================================================= //function : GEOMImpl_PartitionDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver() +GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver() { } +//======================================================================= +//function : SimplifyCompound +//purpose : +//======================================================================= +static void PrepareShapes (const TopoDS_Shape& theShape, + Standard_Integer theType, + TopTools_ListOfShape& theSimpleList) +{ + if (theType == PARTITION_NO_SELF_INTERSECTIONS || + theShape.ShapeType() != TopAbs_COMPOUND) { + theSimpleList.Append(theShape); + return; + } + + // explode compound on simple shapes to allow their intersections + TopoDS_Iterator It (theShape, Standard_True, Standard_True); + TopTools_MapOfShape mapShape; + for (; It.More(); It.Next()) { + if (mapShape.Add(It.Value())) { + TopoDS_Shape curSh = It.Value(); + PrepareShapes(curSh, theType, theSimpleList); + } + } +} + //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const { - if (Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IPartition aCI (aFunction); @@ -86,19 +112,21 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const //sklNMTAlgo_Splitter1 PS; GEOMAlgo_Splitter PS; - if (aType == PARTITION_PARTITION) { + if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS) + { Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetTools(); Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns(); Handle(TColStd_HSequenceOfTransient) aRemIns = aCI.GetRemoveIns(); Handle(TColStd_HArray1OfInteger) aMaterials = aCI.GetMaterials(); - //sklStandard_Boolean DoRemoveWebs = !aMaterials.IsNull(); - - unsigned int ind, nbshapes = 0; - nbshapes += aShapes->Length() + aTools->Length(); - nbshapes += aKeepIns->Length() + aRemIns->Length(); + //skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull(); - TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes); + unsigned int ind; + //unsigned int ind, nbshapes = 0; + //nbshapes += aShapes->Length() + aTools->Length(); + //nbshapes += aKeepIns->Length() + aRemIns->Length(); + //TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes); + TopTools_MapOfShape ShapesMap, ToolsMap; // add object shapes that are in ListShapes; for (ind = 1; ind <= aShapes->Length(); ind++) { @@ -107,12 +135,19 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const if (aShape_i.IsNull()) { Standard_NullObject::Raise("In Partition a shape is null"); } - if (ShapesMap.Add(aShape_i)) { - PS.AddShape(aShape_i); -//skl if (DoRemoveWebs) { -//skl if (aMaterials->Length() >= ind) -//skl PS.SetMaterial(aShape_i, aMaterials->Value(ind)); -//skl } + // + TopTools_ListOfShape aSimpleShapes; + PrepareShapes(aShape_i, aType, aSimpleShapes); + TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes); + for (; aSimpleIter.More(); aSimpleIter.Next()) { + const TopoDS_Shape& aSimpleSh = aSimpleIter.Value(); + if (ShapesMap.Add(aSimpleSh)) { + PS.AddShape(aSimpleSh); + //skl if (DoRemoveWebs) { + //skl if (aMaterials->Length() >= ind) + //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind)); + //skl } + } } } @@ -123,8 +158,15 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const if (aShape_i.IsNull()) { Standard_NullObject::Raise("In Partition a tool shape is null"); } - if (!ShapesMap.Contains(aShape_i) && ToolsMap.Add(aShape_i)) { - PS.AddTool(aShape_i); + // + TopTools_ListOfShape aSimpleShapes; + PrepareShapes(aShape_i, aType, aSimpleShapes); + TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes); + for (; aSimpleIter.More(); aSimpleIter.Next()) { + const TopoDS_Shape& aSimpleSh = aSimpleIter.Value(); + if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) { + PS.AddTool(aSimpleSh); + } } } @@ -135,8 +177,15 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const if (aShape_i.IsNull()) { Standard_NullObject::Raise("In Partition a Keep Inside shape is null"); } - if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i)) - PS.AddShape(aShape_i); + // + TopTools_ListOfShape aSimpleShapes; + PrepareShapes(aShape_i, aType, aSimpleShapes); + TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes); + for (; aSimpleIter.More(); aSimpleIter.Next()) { + const TopoDS_Shape& aSimpleSh = aSimpleIter.Value(); + if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh)) + PS.AddShape(aSimpleSh); + } } // add shapes that are in ListRemoveInside, as object shapes; @@ -146,16 +195,23 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const if (aShape_i.IsNull()) { Standard_NullObject::Raise("In Partition a Remove Inside shape is null"); } - if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i)) - PS.AddShape(aShape_i); + // + TopTools_ListOfShape aSimpleShapes; + PrepareShapes(aShape_i, aType, aSimpleShapes); + TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes); + for (; aSimpleIter.More(); aSimpleIter.Next()) { + const TopoDS_Shape& aSimpleSh = aSimpleIter.Value(); + if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh)) + PS.AddShape(aSimpleSh); + } } PS.SetLimit( (TopAbs_ShapeEnum)aCI.GetLimit() ); PS.Perform(); - //sklPS.Compute(); - //sklPS.SetRemoveWebs(!DoRemoveWebs); - //sklPS.Build((TopAbs_ShapeEnum) aCI.GetLimit()); + //skl PS.Compute(); + //skl PS.SetRemoveWebs(!DoRemoveWebs); + //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit()); /*skl // suppress result outside of shapes in KInsideMap for (ind = 1; ind <= aKeepIns->Length(); ind++) { @@ -172,7 +228,8 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const } */ } - else if (aType == PARTITION_HALF) { + else if (aType == PARTITION_HALF) + { Handle(GEOM_Function) aRefShape = aCI.GetShape(); Handle(GEOM_Function) aRefPlane = aCI.GetPlane(); TopoDS_Shape aShapeArg = aRefShape->GetValue(); @@ -188,7 +245,7 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const // add tool shapes that are in ListTools and not in ListShapes; PS.AddTool(aPlaneArg); - //sklPS.Compute(); + //skl PS.Compute(); PS.Perform(); //PS.SetRemoveWebs(Standard_False); //PS.Build(aShapeArg.ShapeType()); @@ -263,17 +320,17 @@ Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const //======================================================================= //function : GEOMImpl_PartitionDriver_Type_ //purpose : -//======================================================================= +//======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_() { static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PartitionDriver", @@ -288,7 +345,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_PartitionDriver) _anOtherObject;