From 82894c21d3367e5055f6d302e9162382ca3ea95c Mon Sep 17 00:00:00 2001 From: rraphael Date: Thu, 17 Dec 2020 10:53:12 +0100 Subject: [PATCH] group shape: remove COMPOUND on single shape result, activate python plugin --- .../CollectionPlugin_GroupShape.cpp | 18 ++++++++++++++++++ src/PythonAPI/model/collection/__init__.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp index a44ecdba7..0a0f90d25 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp +++ b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp @@ -19,12 +19,30 @@ #include "CollectionPlugin_GroupShape.h" #include "ModelAPI_ResultBody.h" +#include +#include void CollectionPlugin_GroupShape::execute() { ResultGroupPtr aGroup; CollectionPlugin_GroupMerge::execute(aGroup); GeomShapePtr aCompound = aGroup->shape(); + + const TopoDS_Shape & aShape = aCompound->impl(); + + if(aShape.NbChildren() == 1) + { + /// unique shape, remove compound on type + + TopoDS_Iterator anIt(aShape); + TopoDS_Shape aShape = anIt.Value(); + std::shared_ptr aRes(new GeomAPI_Shape); + aRes->setImpl(new TopoDS_Shape(aShape)); + aGroup->store(GeomShapePtr()); + aGroup->store(aRes); + aCompound = aGroup->shape(); + } + std::shared_ptr theResultBody = document()->createBody(data()); theResultBody->store(GeomShapePtr()); if(!aCompound->empty()) diff --git a/src/PythonAPI/model/collection/__init__.py b/src/PythonAPI/model/collection/__init__.py index 9b71ec825..b6f4ed153 100644 --- a/src/PythonAPI/model/collection/__init__.py +++ b/src/PythonAPI/model/collection/__init__.py @@ -20,4 +20,4 @@ """ from CollectionAPI import addGroup, addField -from CollectionAPI import addGroupAddition, addGroupIntersection, addGroupSubstraction +from CollectionAPI import addGroupAddition, addGroupIntersection, addGroupSubstraction, addGroupShape -- 2.39.2