--- /dev/null
+# Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+#
+# 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
+# version 2.1 of the License, or (at your option) any later version.
+#
+# 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
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+import sys
+import salome
+
+salome.salome_init()
+###
+### SHAPER component
+###
+from salome.shaper import model
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Box_1_1/Left")])
+Group_2 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Box_1_1/Front")])
+GroupAddition_1 = model.addGroupAddition(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
+model.end()
+
+###
+### SHAPERSTUDY component
+###
+
+model.publishToShaperStudy()
+# check that addition is in the SHAPERSTUDY
+
+from SHAPERSTUDY_utils import findOrCreateComponent, getStudy
+c = findOrCreateComponent()
+aSOIter = getStudy().NewChildIterator(c)
+aSO = aSOIter.Value()
+aSOIter = getStudy().NewChildIterator(aSO)
+aSOIter.Next()
+aSOIter.Next()
+aSOIter.Next()
+assert(aSOIter.Value().GetName() == GroupAddition_1.name())
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultPart.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_Events.h>
#include <GeomAPI_ShapeHierarchy.h>
+#include <GeomAPI_ShapeIterator.h>
#define RECURSE_TOP_LEVEL 50
if (aFeat.get() && (theFeatureKind.empty() || aFeat->getKind() == theFeatureKind))
aResSet.insert(aFeat);
}
+ // check also Group-operations that may refer to groups - add them for theFeatureKind "Group"
+ if (theFeatureKind == "Group") {
+ std::set<FeaturePtr> aGroupOperations;
+ for(bool aNeedIterate = true; aNeedIterate; ) {
+ std::set<FeaturePtr>::iterator aResIter = aResSet.begin();
+ for(; aResIter != aResSet.end(); aResIter++) {
+ std::list<ResultPtr>::const_iterator aGroupRes = (*aResIter)->results().cbegin();
+ for(; aGroupRes != (*aResIter)->results().cend(); aGroupRes++) {
+ const std::set<AttributePtr>& aRefs = (*aGroupRes)->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aRef = aRefs.cbegin();
+ for(; aRef != aRefs.cend(); aRef++) {
+ FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
+ if (aFeat.get() && !aGroupOperations.count(aFeat) && !aFeat->results().empty() &&
+ aFeat->firstResult()->groupName() == ModelAPI_ResultGroup::group()) {
+ // iterate results of this group operation because it may be without theTarget shape
+ GeomShapePtr aTargetShape = theTarget->shape();
+ bool anIsIn = false;
+ std::list<ResultPtr>::const_iterator anOpRes = aFeat->results().cbegin();
+ for(; anOpRes != aFeat->results().cend() && !anIsIn; anOpRes++) {
+ GeomShapePtr anOpShape = (*anOpRes)->shape();
+ if (!anOpShape.get() || anOpShape->isNull())
+ continue;
+ for(GeomAPI_ShapeIterator aSubIt(anOpShape); aSubIt.more(); aSubIt.next()) {
+ if (aTargetShape->isSubShape(aSubIt.current(), false)) {
+ anIsIn = true;
+ break;
+ }
+ }
+ }
+ if (anIsIn)
+ aGroupOperations.insert(aFeat);
+ }
+ }
+ }
+ }
+ // insert all new group operations into result and if they are, check for next dependencies
+ aNeedIterate = false;
+ std::set<FeaturePtr>::iterator aGroupOpIter = aGroupOperations.begin();
+ for(; aGroupOpIter != aGroupOperations.end(); aGroupOpIter++) {
+ if (aResSet.find(*aGroupOpIter) == aResSet.end()) {
+ aResSet.insert(*aGroupOpIter);
+ aNeedIterate = true;
+ }
+ }
+ }
+ }
std::list<FeaturePtr> aResList;
std::set<FeaturePtr>::iterator aResIter = aResSet.begin();