Implement Group Substraction feature.
CollectionAPI_Group.h
CollectionAPI_GroupAddition.h
CollectionAPI_GroupIntersection.h
+ CollectionAPI_GroupSubstraction.h
CollectionAPI_Field.h
)
CollectionAPI_Group.cpp
CollectionAPI_GroupAddition.cpp
CollectionAPI_GroupIntersection.cpp
+ CollectionAPI_GroupSubstraction.cpp
CollectionAPI_Field.cpp
)
#include "CollectionAPI_Group.h"
#include "CollectionAPI_GroupAddition.h"
#include "CollectionAPI_GroupIntersection.h"
+ #include "CollectionAPI_GroupSubstraction.h"
#include "CollectionAPI_Field.h"
#endif // CollectionAPI_swig_H_
%shared_ptr(CollectionAPI_Group)
%shared_ptr(CollectionAPI_GroupAddition)
%shared_ptr(CollectionAPI_GroupIntersection)
+%shared_ptr(CollectionAPI_GroupSubstraction)
%shared_ptr(CollectionAPI_Field)
// all supported interfaces
%include "CollectionAPI_Group.h"
%include "CollectionAPI_GroupAddition.h"
%include "CollectionAPI_GroupIntersection.h"
+%include "CollectionAPI_GroupSubstraction.h"
%include "CollectionAPI_Field.h"
--- /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
+//
+
+#include "CollectionAPI_GroupSubstraction.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+CollectionAPI_GroupSubstraction::CollectionAPI_GroupSubstraction(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature)
+ : ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+CollectionAPI_GroupSubstraction::CollectionAPI_GroupSubstraction(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theObjectsList,
+ const std::list<ModelHighAPI_Selection>& theToolsList)
+ : ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setObjectsList(theObjectsList);
+ setToolsList(theToolsList);
+ }
+}
+
+CollectionAPI_GroupSubstraction::~CollectionAPI_GroupSubstraction()
+{
+}
+
+void CollectionAPI_GroupSubstraction::setObjectsList(
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ fillAttribute(theGroupList, myobjectsList);
+ execute();
+}
+
+void CollectionAPI_GroupSubstraction::setToolsList(
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ fillAttribute(theGroupList, mytoolsList);
+ execute();
+}
+
+void CollectionAPI_GroupSubstraction::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeSelectionListPtr anObjectsList =
+ aBase->selectionList(CollectionPlugin_GroupSubstraction::LIST_ID());
+ AttributeSelectionListPtr aToolsList =
+ aBase->selectionList(CollectionPlugin_GroupSubstraction::TOOLS_ID());
+
+ theDumper << aBase << " = model.addGroupSubstraction(" << aDocName << ", "
+ << anObjectsList << ", " << aToolsList << ")" << std::endl;
+}
+
+GroupSubstractionPtr addGroupSubstraction(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theObjectsList,
+ const std::list<ModelHighAPI_Selection>& theToolsList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(CollectionAPI_GroupSubstraction::ID());
+ return GroupSubstractionPtr(new CollectionAPI_GroupSubstraction(
+ aFeature, theObjectsList, theToolsList));
+}
--- /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
+//
+
+#ifndef CollectionAPI_GroupSubstraction_H_
+#define CollectionAPI_GroupSubstraction_H_
+
+#include "CollectionAPI.h"
+
+#include <CollectionPlugin_GroupSubstraction.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class CollectionAPI_GroupSubstraction
+/// \ingroup CPPHighAPI
+/// \brief Interface for Group Intersection feature.
+class CollectionAPI_GroupSubstraction : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ COLLECTIONAPI_EXPORT
+ explicit CollectionAPI_GroupSubstraction(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ COLLECTIONAPI_EXPORT
+ CollectionAPI_GroupSubstraction(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theObjectsList,
+ const std::list<ModelHighAPI_Selection>& theToolsList);
+
+ /// Destructor.
+ COLLECTIONAPI_EXPORT
+ virtual ~CollectionAPI_GroupSubstraction();
+
+ INTERFACE_2(CollectionPlugin_GroupSubstraction::ID(),
+ objectsList, CollectionPlugin_GroupSubstraction::LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Objects list*/,
+ toolsList, CollectionPlugin_GroupSubstraction::TOOLS_ID(),
+ ModelAPI_AttributeSelectionList, /** Tools list*/)
+
+ /// Set main objects.
+ COLLECTIONAPI_EXPORT
+ void setObjectsList(const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Set tools.
+ COLLECTIONAPI_EXPORT
+ void setToolsList(const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Dump wrapped feature
+ COLLECTIONAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Group Addition object.
+typedef std::shared_ptr<CollectionAPI_GroupSubstraction> GroupSubstractionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Group Substraction feature.
+COLLECTIONAPI_EXPORT
+GroupSubstractionPtr addGroupSubstraction(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theObjectsList,
+ const std::list<ModelHighAPI_Selection>& theToolsList);
+
+#endif // CollectionAPI_GroupSubstraction_H_
CollectionPlugin_Group.h
CollectionPlugin_GroupAddition.h
CollectionPlugin_GroupIntersection.h
+ CollectionPlugin_GroupSubstraction.h
CollectionPlugin_Field.h
CollectionPlugin_WidgetCreator.h
CollectionPlugin_WidgetField.h
CollectionPlugin_Group.cpp
CollectionPlugin_GroupAddition.cpp
CollectionPlugin_GroupIntersection.cpp
+ CollectionPlugin_GroupSubstraction.cpp
CollectionPlugin_Field.cpp
CollectionPlugin_WidgetCreator.cpp
CollectionPlugin_WidgetField.cpp
TestGroupAddition_Error.py
TestGroupIntersection.py
TestGroupIntersection_Error.py
+ TestGroupSubstraction.py
+ TestGroupSubstraction_Error1.py
+ TestGroupSubstraction_Error2.py
)
--- /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
+//
+
+#include "CollectionPlugin_GroupSubstraction.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
+
+#include <GeomAPI_ShapeIterator.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_ShapeTools.h>
+
+typedef std::set<GeomShapePtr, GeomAPI_Shape::ComparatorWithOri> SetOfShape;
+
+CollectionPlugin_GroupSubstraction::CollectionPlugin_GroupSubstraction()
+{
+}
+
+void CollectionPlugin_GroupSubstraction::initAttributes()
+{
+ data()->addAttribute(CollectionPlugin_GroupSubstraction::LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
+ data()->addAttribute(CollectionPlugin_GroupSubstraction::TOOLS_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
+}
+
+static void explodeCompound(const GeomShapePtr& theCompound, SetOfShape& theSet)
+{
+ for (GeomAPI_ShapeIterator anIt(theCompound); anIt.more(); anIt.next())
+ theSet.insert(anIt.current());
+}
+
+static void subtractLists(const GeomShapePtr& theCompound,
+ const SetOfShape& theExclude,
+ ListOfShape& theResult)
+{
+ for (GeomAPI_ShapeIterator anIt(theCompound); anIt.more(); anIt.next()) {
+ GeomShapePtr aCurrent = anIt.current();
+ if (theExclude.find(aCurrent) != theExclude.end())
+ continue; // shape has to be excluded
+ // check the shape is already in the list
+ ListOfShape::iterator anIt2 = theResult.begin();
+ for (; anIt2 != theResult.end(); ++anIt2)
+ if (aCurrent->isEqual(*anIt2))
+ break;
+ if (anIt2 == theResult.end())
+ theResult.push_back(aCurrent);
+ }
+}
+
+void CollectionPlugin_GroupSubstraction::execute()
+{
+ ResultGroupPtr aGroup = document()->createGroup(data());
+ // clean the result of the operation
+ aGroup->store(GeomShapePtr());
+
+ // collect shapes to be excluded (tools)
+ SetOfShape aShapesToExclude;
+ AttributeSelectionListPtr aTools = selectionList(TOOLS_ID());
+ for (int anIndex = 0; anIndex < aTools->size(); ++anIndex) {
+ AttributeSelectionPtr aCurSelection = aTools->value(anIndex);
+ ResultGroupPtr aCurGroup =
+ std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aCurSelection->context());
+ explodeCompound(aCurGroup->shape(), aShapesToExclude);
+ }
+
+ // keep only shapes that should not be excluded
+ ListOfShape aCut;
+ AttributeSelectionListPtr anObjects = selectionList(LIST_ID());
+ for (int anIndex = 0; anIndex < anObjects->size(); ++anIndex) {
+ AttributeSelectionPtr aCurSelection = anObjects->value(anIndex);
+ ResultGroupPtr aCurGroup =
+ std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aCurSelection->context());
+ subtractLists(aCurGroup->shape(), aShapesToExclude, aCut);
+ if (aCut.empty())
+ break;
+ }
+
+ if (aCut.empty()) {
+ setError("Error: Empty result.");
+ removeResults(0);
+ }
+ else {
+ GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aCut);
+ aGroup->store(aCompound);
+ setResult(aGroup);
+ }
+}
--- /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
+//
+
+#ifndef COLLECTIONPLUGIN_GROUPSUBSTRACTION_H_
+#define COLLECTIONPLUGIN_GROUPSUBSTRACTION_H_
+
+#include "CollectionPlugin.h"
+#include "CollectionPlugin_Group.h"
+
+/**\class CollectionPlugin_GroupSubstraction
+ * \ingroup Plugins
+ * \brief Remove all elements in "objects" groups which contain in "tools" groups.
+ */
+class CollectionPlugin_GroupSubstraction : public CollectionPlugin_Group
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("GroupSubstraction");
+ return MY_GROUP_ID;
+ }
+ /// attribute name of selected objects list
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("group_list");
+ return MY_GROUP_LIST_ID;
+ }
+ /// attribute name of selected tools list
+ inline static const std::string& TOOLS_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("tools_list");
+ return MY_GROUP_LIST_ID;
+ }
+
+ /// Returns the kind of a feature
+ COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = CollectionPlugin_GroupSubstraction::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new group result if needed
+ COLLECTIONPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ COLLECTIONPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Result of groups is created on the fly and don't stored to the document
+ COLLECTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
+
+ /// Use plugin manager for features creation
+ CollectionPlugin_GroupSubstraction();
+
+};
+
+#endif
#include <CollectionPlugin_Group.h>
#include <CollectionPlugin_GroupAddition.h>
#include <CollectionPlugin_GroupIntersection.h>
+#include <CollectionPlugin_GroupSubstraction.h>
#include <CollectionPlugin_Field.h>
#include <CollectionPlugin_Validators.h>
#include <ModelAPI_Session.h>
return FeaturePtr(new CollectionPlugin_GroupAddition);
} else if (theFeatureID == CollectionPlugin_GroupIntersection::ID()) {
return FeaturePtr(new CollectionPlugin_GroupIntersection);
+ } else if (theFeatureID == CollectionPlugin_GroupSubstraction::ID()) {
+ return FeaturePtr(new CollectionPlugin_GroupSubstraction);
}
// feature of such kind is not found
return false;
}
+static bool isGroupTypeCorrect(const AttributeSelectionPtr& theSelection,
+ std::string& theType,
+ Events_InfoMessage& theError)
+{
+ // applicable the groups only
+ ResultPtr aGroupResult = theSelection->context();
+ if (aGroupResult->groupName() != ModelAPI_ResultGroup::group()) {
+ theError = "Error: Groups can be selected only.";
+ return false;
+ }
+ // groups of same type can be selected only
+ FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aGroupResult->data()->owner());
+ std::string aGroupType =
+ aGroupFeature->selectionList(CollectionPlugin_Group::LIST_ID())->selectionType();
+ if (theType.empty())
+ theType = aGroupType;
+ else if (theType != aGroupType) {
+ theError = "Error: Groups should have same type";
+ return false;
+ }
+ return true;
+}
+
bool CollectionPlugin_GroupOperationAttributeValidator::isValid(
const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
std::string aType;
for (int anIndex = 0; anIndex < aSelList->size(); ++anIndex) {
AttributeSelectionPtr aCurSelection = aSelList->value(anIndex);
- // applicable the groups only
- ResultPtr aGroupResult = aCurSelection->context();
- if (aGroupResult->groupName() != ModelAPI_ResultGroup::group()) {
- theError = "Error: Groups can be selected only.";
+ if (!isGroupTypeCorrect(aCurSelection, aType, theError))
return false;
- }
- // groups of same type can be selected only
- FeaturePtr aGroupFeature = ModelAPI_Feature::feature(aGroupResult->data()->owner());
- std::string aGroupType =
- aGroupFeature->selectionList(CollectionPlugin_Group::LIST_ID())->selectionType();
- if (aType.empty())
- aType = aGroupType;
- else if (aType != aGroupType) {
- theError = "Error: Groups should have same type";
+ }
+ // check types of all selection lists are the same
+ for (std::list<std::string>::const_iterator aParIt = theArguments.begin();
+ aParIt != theArguments.end() && !aType.empty(); ++aParIt) {
+ AttributeSelectionListPtr aCurList = anOwner->selectionList(*aParIt);
+ if (aCurList->size() == 0)
+ continue;
+ AttributeSelectionPtr aCurSelection = aCurList->value(0);
+ if (!isGroupTypeCorrect(aCurSelection, aType, theError))
return false;
- }
}
return true;
}
Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Left")])
Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Top")])
GroupAddition_1 = model.addGroupAddition(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
-model.end
+model.end()
from GeomAPI import *
Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]")])
GroupAddition_1 = model.addGroupAddition(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
GroupAddition_2 = model.addGroupAddition(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("FACE", "Box_1_1/Front")])
-model.end
+model.end()
assert(GroupAddition_1.feature().error() != "")
--- /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
+#
+
+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_objects = [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]")]
+Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
+Group_2_objects = [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")]
+Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
+Group_3_objects = [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]")]
+Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
+Group_4_objects = [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Right][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]")]
+Group_4 = model.addGroup(Part_1_doc, Group_4_objects)
+GroupSubstraction_1 = model.addGroupSubstraction(Part_1_doc, [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")], [model.selection("COMPOUND", "Group_3"), model.selection("COMPOUND", "Group_4")])
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(GroupSubstraction_1, 1)
+model.testNbSubResults(GroupSubstraction_1, [0])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.FACE, [0])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.EDGE, [3])
+model.testNbSubShapes(GroupSubstraction_1, GeomAPI_Shape.VERTEX, [6])
+
+assert(model.checkPythonDump())
--- /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
+#
+
+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, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Left")])
+Group_2_objects = [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Left]")]
+Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
+GroupSubstraction_1 = model.addGroupSubstraction(Part_1_doc, [model.selection("COMPOUND", "Group_1")], [model.selection("COMPOUND", "Group_2")])
+model.end()
+
+assert(GroupSubstraction_1.feature().error() != "")
--- /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
+#
+
+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, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Box_1_1/Left")])
+Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Box_1_1/Front")])
+Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Top")])
+GroupSubstraction_1 = model.addGroupSubstraction(Part_1_doc, [model.selection("COMPOUND", "Group_1")], [model.selection("COMPOUND", "Group_2"), model.selection("COMPOUND", "Group_3")])
+model.end()
+
+assert(GroupSubstraction_1.feature().error() != "")
<source>
<namevalue id="name"
- label="Name"
- placeholder="Please input the group name">
+ label="Name"
+ placeholder="Please input the group name">
</namevalue>
<multi_selector id="group_list"
- tooltip="Select a set of objects"
- type_choice="Vertices Edges Faces Solids"
- use_choice="true"
- clear_in_neutral_point="false"
- filter_points="false"
- same_topology="true">
- <validator id="GeomValidators_BodyShapes"/>
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute" parameters="tools_list"/>
</multi_selector>
-</source>
\ No newline at end of file
+ <multi_selector id="tools_list"
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute" parameters="group_list"/>
+ </multi_selector>
+</source>
helpfile="groupIntersectionFeature.html">
<source path="group_intersection_widget.xml"/>
</feature>
+
+ <feature id="GroupSubstraction"
+ title="Group Substraction"
+ tooltip="Exclude elements existing tool groups"
+ icon="icons/Collection/group_substraction.png"
+ apply_continue="true"
+ helpfile="groupSubstractionFeature.html">
+ <source path="group_substraction_widget.xml"/>
+ </feature>
</group>
</workbench>
</plugin>
"""
from CollectionAPI import addGroup, addField
-from CollectionAPI import addGroupAddition, addGroupIntersection
+from CollectionAPI import addGroupAddition, addGroupIntersection, addGroupSubstraction