From 4377133d99a5544c1aaa4172a3bc3cc8281dfa11 Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 7 Sep 2015 17:17:40 +0300 Subject: [PATCH] Now partition creates compsolids instead of compounds --- src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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()); -- 2.39.2