From: dbv Date: Mon, 7 Sep 2015 14:17:40 +0000 (+0300) Subject: Now partition creates compsolids instead of compounds X-Git-Tag: V_1.4.0_beta4~87 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4377133d99a5544c1aaa4172a3bc3cc8281dfa11;p=modules%2Fshaper.git Now partition creates compsolids instead of compounds --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp index cd1e00d28..edc34324b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp @@ -7,11 +7,13 @@ #include "GeomAlgoAPI_Partition.h" #include +#include #include #include #include +#include #include //================================================================================================= @@ -69,6 +71,26 @@ void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects, if(aResult.ShapeType() == TopAbs_COMPOUND) { aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); } + if(aResult.ShapeType() == TopAbs_COMPOUND) { + std::shared_ptr aCompound(new GeomAPI_Shape); + aCompound->setImpl(new TopoDS_Shape(aResult)); + ListOfShape aCompSolids, aFreeSolids; + GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids); + if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) { + aResult = aCompSolids.front()->impl(); + } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) { + TopoDS_Compound aResultComp; + TopoDS_Builder aBuilder; + aBuilder.MakeCompound(aResultComp); + for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) { + aBuilder.Add(aResultComp, (*anIter)->impl()); + } + for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) { + aBuilder.Add(aResultComp, (*anIter)->impl()); + } + aResult = aResultComp; + } + } // fill data map to keep correct orientation of sub-shapes myMap.reset(new GeomAPI_DataMapOfShapeShape());