SET(PROJECT_HEADERS
CollectionAPI.h
CollectionAPI_Group.h
+ CollectionAPI_GroupAddition.h
+ CollectionAPI_GroupIntersection.h
+ CollectionAPI_GroupSubstraction.h
CollectionAPI_Field.h
)
SET(PROJECT_SOURCES
CollectionAPI_Group.cpp
+ CollectionAPI_GroupAddition.cpp
+ CollectionAPI_GroupIntersection.cpp
+ CollectionAPI_GroupSubstraction.cpp
CollectionAPI_Field.cpp
)
#include "CollectionAPI.h"
#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 pointers
%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_GroupAddition.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+CollectionAPI_GroupAddition::CollectionAPI_GroupAddition(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature)
+ : ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+CollectionAPI_GroupAddition::CollectionAPI_GroupAddition(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+ : ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setGroupList(theGroupList);
+ }
+}
+
+CollectionAPI_GroupAddition::~CollectionAPI_GroupAddition()
+{
+}
+
+void CollectionAPI_GroupAddition::setGroupList(
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ fillAttribute(theGroupList, mygroupList);
+ execute();
+}
+
+void CollectionAPI_GroupAddition::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeSelectionListPtr anAttrList =
+ aBase->selectionList(CollectionPlugin_GroupAddition::LIST_ID());
+
+ theDumper << aBase << " = model.addGroupAddition(" << aDocName << ", "
+ << anAttrList << ")" << std::endl;
+}
+
+GroupAdditionPtr addGroupAddition(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(CollectionAPI_GroupAddition::ID());
+ return GroupAdditionPtr(new CollectionAPI_GroupAddition(aFeature, theGroupList));
+}
--- /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_GroupAddition_H_
+#define CollectionAPI_GroupAddition_H_
+
+#include "CollectionAPI.h"
+
+#include <CollectionPlugin_GroupAddition.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class CollectionAPI_GroupAddition
+/// \ingroup CPPHighAPI
+/// \brief Interface for Group Addition feature.
+class CollectionAPI_GroupAddition : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ COLLECTIONAPI_EXPORT
+ explicit CollectionAPI_GroupAddition(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ COLLECTIONAPI_EXPORT
+ CollectionAPI_GroupAddition(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Destructor.
+ COLLECTIONAPI_EXPORT
+ virtual ~CollectionAPI_GroupAddition();
+
+ INTERFACE_1(CollectionPlugin_GroupAddition::ID(),
+ groupList, CollectionPlugin_GroupAddition::LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Group list*/)
+
+ /// Set main objects.
+ COLLECTIONAPI_EXPORT
+ void setGroupList(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_GroupAddition> GroupAdditionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Group Addition feature.
+COLLECTIONAPI_EXPORT
+GroupAdditionPtr addGroupAddition(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupsList);
+
+#endif // CollectionAPI_GroupAddition_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_GroupIntersection.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+CollectionAPI_GroupIntersection::CollectionAPI_GroupIntersection(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature)
+ : ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+CollectionAPI_GroupIntersection::CollectionAPI_GroupIntersection(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+ : ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ setGroupList(theGroupList);
+ }
+}
+
+CollectionAPI_GroupIntersection::~CollectionAPI_GroupIntersection()
+{
+}
+
+void CollectionAPI_GroupIntersection::setGroupList(
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ fillAttribute(theGroupList, mygroupList);
+ execute();
+}
+
+void CollectionAPI_GroupIntersection::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeSelectionListPtr anAttrList =
+ aBase->selectionList(CollectionPlugin_GroupIntersection::LIST_ID());
+
+ theDumper << aBase << " = model.addGroupIntersection(" << aDocName << ", "
+ << anAttrList << ")" << std::endl;
+}
+
+GroupIntersectionPtr addGroupIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature =
+ thePart->addFeature(CollectionAPI_GroupIntersection::ID());
+ return GroupIntersectionPtr(new CollectionAPI_GroupIntersection(aFeature, theGroupList));
+}
--- /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_GroupIntersection_H_
+#define CollectionAPI_GroupIntersection_H_
+
+#include "CollectionAPI.h"
+
+#include <CollectionPlugin_GroupIntersection.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+
+/// \class CollectionAPI_GroupIntersection
+/// \ingroup CPPHighAPI
+/// \brief Interface for Group Intersection feature.
+class CollectionAPI_GroupIntersection : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ COLLECTIONAPI_EXPORT
+ explicit CollectionAPI_GroupIntersection(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ COLLECTIONAPI_EXPORT
+ CollectionAPI_GroupIntersection(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theGroupList);
+
+ /// Destructor.
+ COLLECTIONAPI_EXPORT
+ virtual ~CollectionAPI_GroupIntersection();
+
+ INTERFACE_1(CollectionPlugin_GroupIntersection::ID(),
+ groupList, CollectionPlugin_GroupIntersection::LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Group list*/)
+
+ /// Set main objects.
+ COLLECTIONAPI_EXPORT
+ void setGroupList(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_GroupIntersection> GroupIntersectionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Group Intersection feature.
+COLLECTIONAPI_EXPORT
+GroupIntersectionPtr addGroupIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::list<ModelHighAPI_Selection>& theGroupsList);
+
+#endif // CollectionAPI_GroupIntersection_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.h
CollectionPlugin_Plugin.h
CollectionPlugin_Group.h
+ CollectionPlugin_GroupAddition.h
+ CollectionPlugin_GroupIntersection.h
+ CollectionPlugin_GroupSubstraction.h
CollectionPlugin_Field.h
CollectionPlugin_WidgetCreator.h
CollectionPlugin_WidgetField.h
SET(PROJECT_SOURCES
CollectionPlugin_Plugin.cpp
CollectionPlugin_Group.cpp
+ CollectionPlugin_GroupAddition.cpp
+ CollectionPlugin_GroupIntersection.cpp
+ CollectionPlugin_GroupSubstraction.cpp
CollectionPlugin_Field.cpp
CollectionPlugin_WidgetCreator.cpp
CollectionPlugin_WidgetField.cpp
SET(XML_RESOURCES
plugin-Collection.xml
group_widget.xml
+ group_addition_widget.xml
+ group_intersection_widget.xml
+ group_substraction_widget.xml
)
SET(TEXT_RESOURCES
TestGroupMove19.py
TestGroupMove20.py
TestGroupShareTopology.py
+ TestGroupAddition.py
+ 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_GroupAddition.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>
+
+CollectionPlugin_GroupAddition::CollectionPlugin_GroupAddition()
+{
+}
+
+void CollectionPlugin_GroupAddition::initAttributes()
+{
+ data()->addAttribute(CollectionPlugin_GroupAddition::LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
+}
+
+static void explodeCompound(const GeomShapePtr& theCompound, ListOfShape& theSubs)
+{
+ if (theCompound->isCompound()) {
+ GeomAPI_ShapeIterator anIt(theCompound);
+ for (; anIt.more(); anIt.next())
+ explodeCompound(anIt.current(), theSubs);
+ }
+ else
+ theSubs.push_back(theCompound);
+}
+
+static void keepUniqueShapes(ListOfShape& theShapes)
+{
+ ListOfShape::iterator anIt = theShapes.begin();
+ while (anIt != theShapes.end()) {
+ GeomShapePtr aCurrent = *anIt;
+ ListOfShape::iterator anIt2 = theShapes.begin();
+ for (; anIt2 != anIt; ++anIt2)
+ if (aCurrent->isEqual(*anIt2))
+ break;
+ if (anIt2 != anIt) {
+ // the same shape is found
+ ListOfShape::iterator aRemoveIt = anIt++;
+ theShapes.erase(aRemoveIt);
+ }
+ else
+ ++anIt;
+ }
+}
+
+void CollectionPlugin_GroupAddition::execute()
+{
+ ResultGroupPtr aGroup = document()->createGroup(data());
+ // clean the result of the operation
+ aGroup->store(GeomShapePtr());
+
+ // collect all unique sub-shapes
+ GeomShapePtr aCompound = aGroup->shape();
+ ListOfShape aSubs;
+ explodeCompound(aCompound, aSubs);
+ keepUniqueShapes(aSubs);
+ aCompound = aSubs.empty() ? GeomShapePtr() : GeomAlgoAPI_CompoundBuilder::compound(aSubs);
+ 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_GROUPADDITION_H_
+#define COLLECTIONPLUGIN_GROUPADDITION_H_
+
+#include "CollectionPlugin.h"
+#include "CollectionPlugin_Group.h"
+
+/**\class CollectionPlugin_GroupAddition
+ * \ingroup Plugins
+ * \brief Merge several groups of same shape type into single group.
+ */
+class CollectionPlugin_GroupAddition : public CollectionPlugin_Group
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("GroupAddition");
+ return MY_GROUP_ID;
+ }
+ /// attribute name of selected entities list
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("group_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_GroupAddition::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_GroupAddition();
+
+};
+
+#endif
--- /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_GroupIntersection.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_GroupIntersection::CollectionPlugin_GroupIntersection()
+{
+}
+
+void CollectionPlugin_GroupIntersection::initAttributes()
+{
+ data()->addAttribute(CollectionPlugin_GroupIntersection::LIST_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 keepCommonShapes(const GeomShapePtr& theCompound, ListOfShape& theShapes)
+{
+ if (theShapes.empty()) {
+ for (GeomAPI_ShapeIterator anIt(theCompound); anIt.more(); anIt.next())
+ theShapes.push_back(anIt.current());
+ }
+ else {
+ SetOfShape aSubs;
+ explodeCompound(theCompound, aSubs);
+
+ ListOfShape::iterator anIt = theShapes.begin();
+ while (anIt != theShapes.end()) {
+ if (aSubs.find(*anIt) == aSubs.end()) {
+ // the shape is not found
+ ListOfShape::iterator aRemoveIt = anIt++;
+ theShapes.erase(aRemoveIt);
+ }
+ else
+ ++anIt;
+ }
+ }
+}
+
+void CollectionPlugin_GroupIntersection::execute()
+{
+ ResultGroupPtr aGroup = document()->createGroup(data());
+ // clean the result of the operation
+ aGroup->store(GeomShapePtr());
+
+ // shapes containing in each group
+ ListOfShape aCommon;
+
+ // collect shapes containing in all groups
+ AttributeSelectionListPtr aSelectedGroups = selectionList(LIST_ID());
+ for (int anIndex = 0; anIndex < aSelectedGroups->size(); ++anIndex) {
+ AttributeSelectionPtr aCurSelection = aSelectedGroups->value(anIndex);
+ ResultGroupPtr aCurGroup =
+ std::dynamic_pointer_cast<ModelAPI_ResultGroup>(aCurSelection->context());
+ keepCommonShapes(aCurGroup->shape(), aCommon);
+ if (aCommon.empty())
+ break;
+ }
+
+ if (aCommon.empty()) {
+ setError("Error: Empty result.");
+ removeResults(0);
+ }
+ else {
+ GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aCommon);
+ 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_GROUPINTERSECTION_H_
+#define COLLECTIONPLUGIN_GROUPINTERSECTION_H_
+
+#include "CollectionPlugin.h"
+#include "CollectionPlugin_Group.h"
+
+/**\class CollectionPlugin_GroupIntersection
+ * \ingroup Plugins
+ * \brief Merge several groups of same shape type into single group.
+ */
+class CollectionPlugin_GroupIntersection : public CollectionPlugin_Group
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("GroupIntersection");
+ return MY_GROUP_ID;
+ }
+ /// attribute name of selected entities list
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("group_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_GroupIntersection::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_GroupIntersection();
+
+};
+
+#endif
--- /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_Plugin.h>
#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>
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("CollectionPlugin_FieldValidator",
new CollectionPlugin_FieldValidator);
+ aFactory->registerValidator("CollectionPlugin_OperationAttribute",
+ new CollectionPlugin_GroupOperationAttributeValidator);
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
return FeaturePtr(new CollectionPlugin_Group);
} else if (theFeatureID == CollectionPlugin_Field::ID()) {
return FeaturePtr(new CollectionPlugin_Field);
+ } else if (theFeatureID == CollectionPlugin_GroupAddition::ID()) {
+ 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
//
#include "CollectionPlugin_Validators.h"
+#include "CollectionPlugin_Group.h"
#include "CollectionPlugin_Field.h"
#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultGroup.h>
#include <Events_InfoMessage.h>
theError = "Selection list is not initialized";
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,
+ Events_InfoMessage& theError) const
+{
+ AttributeSelectionListPtr aSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if (!aSelList) {
+ theError = "Error: This validator can only work with selection list of attributes";
+ return false;
+ }
+
+ FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
+ // check selected items
+ std::string aType;
+ for (int anIndex = 0; anIndex < aSelList->size(); ++anIndex) {
+ AttributeSelectionPtr aCurSelection = aSelList->value(anIndex);
+ if (!isGroupTypeCorrect(aCurSelection, aType, theError))
+ return false;
+ }
+ // 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;
+}
#define CollectionPlugin_Validators_H
#include "CollectionPlugin.h"
+#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_FeatureValidator.h>
-/**\class SketchPlugin_SolverErrorValidator
-* \ingroup Validators
-* \brief Validator for the solver error.
-*
-* Simply checks that solver error attribute is empty. Returns the attribute value as an error.
-*/
+/**\class CollectionPlugin_FieldValidator
+ * \ingroup Validators
+ * \brief Validator for the field.
+ */
class CollectionPlugin_FieldValidator : public ModelAPI_FeatureValidator
{
public:
Events_InfoMessage& theError) const;
};
+/**\class CollectionPlugin_GroupOperationAttributeValidator
+ * \ingroup Validators
+ * \brief Validator for the parameters of operation on groups.
+ */
+class CollectionPlugin_GroupOperationAttributeValidator : public ModelAPI_AttributeValidator
+{
+ //! Returns true if attribute is ok.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
+};
+
#endif
\ No newline at end of file
<translation>Components are not selected</translation>
</message>
</context>
+ <context>
+ <name>GroupIntersection:EmptyResult</name>
+ <message>
+ <source>Error: Empty result.</source>
+ <translation>Error: Empty result.</translation>
+ </message>
+ </context>
</TS>
--- /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/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()
+
+from GeomAPI import *
+
+model.testNbResults(GroupAddition_1, 1)
+model.testNbSubResults(GroupAddition_1, [0])
+model.testNbSubShapes(GroupAddition_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(GroupAddition_1, GeomAPI_Shape.FACE, [3])
+model.testNbSubShapes(GroupAddition_1, GeomAPI_Shape.EDGE, [12])
+model.testNbSubShapes(GroupAddition_1, GeomAPI_Shape.VERTEX, [24])
+model.testResultsVolumes(GroupAddition_1, [300])
+
+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 = 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()
+
+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 = 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")])
+Group_3_objects = [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Right"), model.selection("FACE", "Box_1_1/Top")]
+Group_3 = model.addGroup(Part_1_doc, Group_3_objects)
+GroupIntersection_1_objects = [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2"), model.selection("COMPOUND", "Group_3")]
+GroupIntersection_1 = model.addGroupIntersection(Part_1_doc, GroupIntersection_1_objects)
+model.end()
+
+from GeomAPI import *
+
+model.testNbResults(GroupIntersection_1, 1)
+model.testNbSubResults(GroupIntersection_1, [0])
+model.testNbSubShapes(GroupIntersection_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(GroupIntersection_1, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(GroupIntersection_1, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(GroupIntersection_1, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(GroupIntersection_1, [100])
+
+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 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Top")])
+Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"), model.selection("FACE", "Box_1_1/Right")])
+GroupIntersection_1_objects = [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2"), model.selection("COMPOUND", "Group_3")]
+GroupIntersection_1 = model.addGroupIntersection(Part_1_doc, GroupIntersection_1_objects)
+model.end()
+
+assert(GroupIntersection_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() != "")
fieldFeature.rst
groupFeature.rst
+ groupAdditionFeature.rst
+ groupIntersectionFeature.rst
+ groupSubstractionFeature.rst
--- /dev/null
+
+ .. _tui_create_group_addition:
+
+Create Group Addition
+=====================
+
+.. literalinclude:: examples/group_addition.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/group_addition.py>`
--- /dev/null
+
+ .. _tui_create_group_intersection:
+
+Create Group Intersection
+=========================
+
+.. literalinclude:: examples/group_intersection.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/group_intersection.py>`
--- /dev/null
+
+ .. _tui_create_group_substraction:
+
+Create Group Substraction
+=========================
+
+.. literalinclude:: examples/group_substraction.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/group_substraction.py>`
--- /dev/null
+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/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()
--- /dev/null
+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/Front"),
+ model.selection("FACE", "Box_1_1/Top")])
+Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Box_1_1/Front"),
+ model.selection("FACE", "Box_1_1/Right"),
+ model.selection("FACE", "Box_1_1/Top")])
+GroupIntersection_1_objects = [model.selection("COMPOUND", "Group_1"),
+ model.selection("COMPOUND", "Group_2"),
+ model.selection("COMPOUND", "Group_3")]
+GroupIntersection_1 = model.addGroupIntersection(Part_1_doc, GroupIntersection_1_objects)
+model.end()
--- /dev/null
+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()
--- /dev/null
+.. |group_addition.icon| image:: images/group_addition.png
+
+Group Addition
+==============
+
+Group addition produces a union of all the elements of the selected groups.
+To create a Group Addition in the active part:
+
+#. select in the Main Menu *Features - > Group Addition* item or
+#. click |group_addition.icon| **Group Addition** button in the toolbar:
+
+The following property panel appears.
+
+.. image:: images/group_addition_property_panel.png
+ :align: center
+
+.. centered::
+ Create a group addition operation
+
+Input fields:
+
+- **Name** defines the name of the group, by default, it is **GroupAddition_n**.
+- The list of selected groups of the same type. Multiple selection can be done manually in OCC 3D Viewer by mouse click with Shift button pressed or by rectangle selection. To delete entities from the list, select them and call pop-up menu *Delete* item.
+
+Note, that operation is valid only for the groups of the same type.
+
+**TUI Command**:
+
+.. py:function:: model.addGroupAddition(Part_1_doc,
+ [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
+
+ :param part: The current part object
+ :param list: A list of selected groups
+ :return: Created object.
+
+
+**See Also** a sample TUI Script of :ref:`tui_create_group_addition` operation.
--- /dev/null
+.. |group_intersection.icon| image:: images/group_intersection.png
+
+Group Intersection
+==================
+
+Group intersection produces a group of elements present in all the selected groups.
+To create a Group Intersection in the active part:
+
+#. select in the Main Menu *Features - > Group Intersection* item or
+#. click |group_intersection.icon| **Group Intersection** button in the toolbar:
+
+The following property panel appears.
+
+.. image:: images/group_intersection_property_panel.png
+ :align: center
+
+.. centered::
+ Create a group intersection operation
+
+Input fields:
+
+- **Name** defines the name of the group, by default, it is **GroupIntersection_n**.
+- The list of selected groups of the same type. Multiple selection can be done manually in OCC 3D Viewer by mouse click with Shift button pressed or by rectangle selection. To delete entities from the list, select them and call pop-up menu *Delete* item.
+
+Note, that operation is valid only for the groups of the same type.
+
+**TUI Command**:
+
+.. py:function:: model.addGroupIntersection(Part_1_doc,
+ [model.selection("COMPOUND", "Group_1"), model.selection("COMPOUND", "Group_2")])
+
+ :param part: The current part object
+ :param list: A list of selected groups
+ :return: Created object.
+
+
+**See Also** a sample TUI Script of :ref:`tui_create_group_intersection` operation.
--- /dev/null
+.. |group_substraction.icon| image:: images/group_substraction.png
+
+Group Substraction
+==================
+
+Group substraction produces a group containing all elements of the main groups but not present in the tool groups.
+To create a Group Substraction in the active part:
+
+#. select in the Main Menu *Features - > Group Substraction* item or
+#. click |group_substraction.icon| **Group Substraction** button in the toolbar:
+
+The following property panel appears.
+
+.. image:: images/group_substraction_property_panel.png
+ :align: center
+
+.. centered::
+ Create a group substraction operation
+
+Input fields:
+
+- **Name** defines the name of the group, by default, it is **GroupSubstraction_n**.
+- The list of main groups. Multiple selection can be done manually in OCC 3D Viewer by mouse click with Shift button pressed or by rectangle selection. To delete entities from the list, select them and call pop-up menu *Delete* item.
+- The list of tool groups. Selection approaches are the same as for the main groups.
+
+Note, that operation is valid only if all the main groups and all the tool groups have the same type.
+
+**TUI Command**:
+
+.. py:function:: 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")])
+
+ :param part: The current part object
+ :param list: A list of main groups
+ :param list: A list of tool groups
+ :return: Created object.
+
+
+**See Also** a sample TUI Script of :ref:`tui_create_group_substraction` operation.
--- /dev/null
+<source>
+ <namevalue id="name"
+ label="Name"
+ placeholder="Please input the group name">
+ </namevalue>
+ <multi_selector id="group_list"
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute"/>
+ </multi_selector>
+</source>
--- /dev/null
+<source>
+ <namevalue id="name"
+ label="Name"
+ placeholder="Please input the group name">
+ </namevalue>
+ <multi_selector id="group_list"
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute"/>
+ </multi_selector>
+</source>
--- /dev/null
+<source>
+ <namevalue id="name"
+ label="Name"
+ placeholder="Please input the group name">
+ </namevalue>
+ <multi_selector id="group_list"
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute" parameters="tools_list"/>
+ </multi_selector>
+ <multi_selector id="tools_list"
+ tooltip="Select a set of groups"
+ type_choice="objects">
+ <validator id="CollectionPlugin_OperationAttribute" parameters="group_list"/>
+ </multi_selector>
+</source>
</field-panel>
<validator id="CollectionPlugin_FieldValidator"/>
</feature>
+
+ <feature id="GroupAddition"
+ title="Group Addition"
+ tooltip="Join several groups to single group"
+ icon="icons/Collection/group_addition.png"
+ helpfile="groupAdditionFeature.html">
+ <source path="group_addition_widget.xml"/>
+ </feature>
+
+ <feature id="GroupIntersection"
+ title="Group Intersection"
+ tooltip="Get elements existing in all groups"
+ icon="icons/Collection/group_intersection.png"
+ 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"
+ helpfile="groupSubstractionFeature.html">
+ <source path="group_substraction_widget.xml"/>
+ </feature>
</group>
</workbench>
</plugin>
//
#include "FeaturesPlugin_Pipe.h"
+#include "FeaturesPlugin_Tools.h"
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
// Store from shapes.
- storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, thePipeAlgo->fromShapes(), ListOfShape(),
+ thePipeAlgo, thePipeAlgo->shape(), "From");
// Store to shapes.
- storeShapes(aResultBody, theBaseShapes.back()->shapeType(), thePipeAlgo->toShapes(), "To_");
-
+ FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, thePipeAlgo->toShapes(), ListOfShape(),
+ thePipeAlgo, thePipeAlgo->shape(), "To");
setResult(aResultBody, theResultIndex);
}
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Tools.h>
aSelLab.ForgetAllAttributes(true);
TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID);
selectPart(std::dynamic_pointer_cast<ModelAPI_Result>(theContext), theSubShape);
+ } else if (theContext->groupName() == ModelAPI_ResultGroup::group()) {
+ aSelLab.ForgetAllAttributes(true);
+ TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
} else { // check the feature context: parent-Part of this feature should not be used
FeaturePtr aFeatureContext = std::dynamic_pointer_cast<ModelAPI_Feature>(theContext);
if (aFeatureContext.get()) {
// the whole result selection check
if (aSubShapeName.find('/') == std::string::npos) {
ObjectPtr aRes = aDoc->objectByName(ModelAPI_ResultConstruction::group(), aSubShapeName);
- if (!aRes.get())
+ if (!aRes.get()) {
aRes = aDoc->objectByName(ModelAPI_ResultBody::group(), aSubShapeName);
+ if (!aRes.get())
+ aRes = aDoc->objectByName(ModelAPI_ResultGroup::group(), aSubShapeName);
+ }
if (aRes.get()) {
setValue(aRes, anEmptyShape);
return;
//
#include <Model_ResultGroup.h>
+#include <Model_Data.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <Config_PropManager.h>
+#include <TDF_Label.hxx>
+#include <TDF_Reference.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+
Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> theOwnerData)
{
myOwnerData = theOwnerData;
std::shared_ptr<GeomAPI_Shape> Model_ResultGroup::shape()
{
std::shared_ptr<GeomAPI_Shape> aResult;
- if (myOwnerData) {
+ // obtain stored shape
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+ if (aData && aData->isValid()) {
+ TDF_Label aShapeLab = aData->shapeLab();
+ Handle(TDF_Reference) aRef;
+ if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
+ aShapeLab = aRef->Get();
+ }
+ Handle(TNaming_NamedShape) aName;
+ if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+ TopoDS_Shape aShape = aName->Get();
+ if (!aShape.IsNull()) {
+ aResult.reset(new GeomAPI_Shape);
+ aResult->setImpl(new TopoDS_Shape(aShape));
+ }
+ }
+ }
+ // collect shapes selected in group
+ if (!aResult && myOwnerData) {
AttributeSelectionListPtr aList = myOwnerData->selectionList("group_list");
if (aList) {
std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
}
return aResult;
}
+
+void Model_ResultGroup::store(const GeomShapePtr& theShape)
+{
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+ if (aData) {
+ TDF_Label aShapeLab = aData->shapeLab();
+ aShapeLab.ForgetAttribute(TDF_Reference::GetID());
+ aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID());
+
+ if (!theShape)
+ return; // bad shape
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if (aShape.IsNull())
+ return; // null shape inside
+
+ // store the new shape as primitive
+ TNaming_Builder aBuilder(aShapeLab);
+ aBuilder.Generated(aShape);
+ }
+}
/// Returns the compound of selected entities
MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+ /// \brief Stores the result of operation made on groups.
+ /// Cleans the storage if empty shape is given.
+ /// param[in] theShape shape to store.
+ MODEL_EXPORT virtual void store(const GeomShapePtr& theShape);
+
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_ResultGroup() {}
return RESULT_GROUP_COLOR;
}
+ /// \brief Stores the result of operation made on groups.
+ /// Cleans the storage if empty shape is given.
+ /// param[in] theShape shape to store.
+ MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape)
+ {}
};
//! Pointer on feature object
#include <ModelAPI_Result.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
if (theAttrSelect->isGeometricalSelection() &&
theShape.get() && theShape->shapeType() == GeomAPI_Shape::COMPOUND &&
theContext.get() && !theShape->isEqual(theContext->shape()) &&
- theContext->groupName() != ModelAPI_ResultPart::group()) {
+ theContext->groupName() != ModelAPI_ResultPart::group() &&
+ theContext->groupName() != ModelAPI_ResultGroup::group()) {
GeomAPI_ShapeIterator anIt(theShape);
theShape = anIt.current();
}
return aName;
}
+bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
+{
+ // In case of compound we cannot rely on simple comparison method.
+ // If the compound is generated by Group feature then this compound is alwais new.
+ // So, we have to compare content of these compounds
+ if (theShape1.ShapeType() != theShape2.ShapeType())
+ return false;
+
+ if (theShape1.ShapeType() != TopAbs_COMPOUND)
+ return theShape1.IsSame(theShape2);
+
+ TopoDS_Iterator aIt1(theShape1);
+ TopoDS_Iterator aIt2(theShape2);
+
+ for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) {
+ if (!(aIt1.Value()).IsSame(aIt2.Value()))
+ return false;
+ }
+ return true;
+}
+
+
} // namespace ModuleBase_Tools
/// \theName a name of parameter
FeaturePtr MODULEBASE_EXPORT findParameter(const QString& theName);
+/// Returns true if both shapes are the same. In case of compounds it
+/// compares their contents.
+/// \param theShape1 a first shape to compare
+/// \param theShape2 a second shape to compare
+/// \return true if both shapes are the same
+bool MODULEBASE_EXPORT isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2);
//----------- Class members -------------
/// Returns a name in the next form: attribute_feature_name/attribute_id
if (aResultGroupName == ModelAPI_ResultPart::group()) {
SessionPtr aMgr = ModelAPI_Session::get();
aValid = aMgr->activeDocument() == aMgr->moduleDocument();
- } else if (aResultGroupName == ModelAPI_ResultGroup::group() ||
- aResultGroupName == ModelAPI_ResultField::group()) {
+ } else if (aResultGroupName == ModelAPI_ResultField::group()) {
aValid = Standard_False;
} else
aValid = Standard_True;
#include <ModuleBase_ActionInfo.h>
#include <ModuleBase_Tools.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultBody.h>
#include <Config_FeatureMessage.h>
#include <Events_Loop.h>
-#include <CollectionPlugin_Group.h>
-
QMap<QString, QString> PartSet_IconFactory::myIcons;
PartSet_IconFactory::PartSet_IconFactory(PartSet_Module* theModule)
if(aShape.get()) {
switch(aShape->shapeType()) {
case GeomAPI_Shape::COMPOUND: {
- FeaturePtr aFeature = ModelAPI_Feature::feature(theObj);
- if (aFeature.get() && aFeature->getKind() == CollectionPlugin_Group::ID()) {
+ if (aResult->groupName() == ModelAPI_ResultGroup::group()) {
switch (aShape->typeOfCompoundShapes()) {
case GeomAPI_Shape::VERTEX:
return QIcon(":icons/group_vertex.png");
"""
from CollectionAPI import addGroup, addField
+from CollectionAPI import addGroupAddition, addGroupIntersection, addGroupSubstraction
::Iterator aShapeIt(theShapesToBeSelected);
for (; aShapeIt.More(); aShapeIt.Next()) {
const TopoDS_Shape& aParameterShape = aShapeIt.Key();
- // isSame should be used here as it does not check orientation of shapes
- // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
- // different for Edges shapes in model shape and owner even if this is the same shape
- if (aParameterShape.IsSame(aShape)) {
+ // In case of compound we cannot rely on simple comparison method.
+ // If the compound is generated by Group feature then this compound is alwais new.
+ // So, we have to compare content of these compounds
+
+ // isSame should be used here as it does not check orientation of shapes
+ // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
+ // different for Edges shapes in model shape and owner even if this is the same shape
+ if (ModuleBase_Tools::isSameShape(aParameterShape, aShape)) {
Handle(AIS_InteractiveObject) anOwnerPresentation =
- Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
- theShapesToBeSelected.Find(aParameterShape);
+ theShapesToBeSelected.Find(aParameterShape);
if (aPresentations.Contains(anOwnerPresentation)) {
theContext->AddOrRemoveSelected(anOwner, Standard_False);
- anOwner->SetSelected (Standard_True);
+ anOwner->SetSelected(Standard_True);
// collect selected presentations to do not select them if compsolid is selected
if (!aSelectedPresentations.Contains(anOwnerPresentation))
aSelectedPresentations.Add(anOwnerPresentation);