From: rraphael Date: Thu, 10 Dec 2020 16:48:16 +0000 (+0100) Subject: add new shape creation from groups X-Git-Tag: V9_7_0a1~13^2~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2d91aa2caad5712070cb3d1ae556a920747929b8;p=modules%2Fshaper.git add new shape creation from groups --- diff --git a/src/CollectionAPI/CMakeLists.txt b/src/CollectionAPI/CMakeLists.txt index 5e1a416db..ea0383b90 100644 --- a/src/CollectionAPI/CMakeLists.txt +++ b/src/CollectionAPI/CMakeLists.txt @@ -23,6 +23,7 @@ SET(PROJECT_HEADERS CollectionAPI.h CollectionAPI_Group.h CollectionAPI_GroupAddition.h + CollectionAPI_GroupShape.h CollectionAPI_GroupIntersection.h CollectionAPI_GroupSubstraction.h CollectionAPI_Field.h @@ -31,6 +32,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES CollectionAPI_Group.cpp CollectionAPI_GroupAddition.cpp + CollectionAPI_GroupShape.cpp CollectionAPI_GroupIntersection.cpp CollectionAPI_GroupSubstraction.cpp CollectionAPI_Field.cpp diff --git a/src/CollectionAPI/CollectionAPI.i b/src/CollectionAPI/CollectionAPI.i index 055cc22aa..6d19f650f 100644 --- a/src/CollectionAPI/CollectionAPI.i +++ b/src/CollectionAPI/CollectionAPI.i @@ -30,6 +30,7 @@ #include "CollectionAPI.h" #include "CollectionAPI_Group.h" #include "CollectionAPI_GroupAddition.h" + #include "CollectionAPI_GroupShape.h" #include "CollectionAPI_GroupIntersection.h" #include "CollectionAPI_GroupSubstraction.h" #include "CollectionAPI_Field.h" @@ -66,6 +67,7 @@ // shared pointers %shared_ptr(CollectionAPI_Group) %shared_ptr(CollectionAPI_GroupAddition) +%shared_ptr(CollectionAPI_GroupShape) %shared_ptr(CollectionAPI_GroupIntersection) %shared_ptr(CollectionAPI_GroupSubstraction) %shared_ptr(CollectionAPI_Field) @@ -73,6 +75,7 @@ // all supported interfaces %include "CollectionAPI_Group.h" %include "CollectionAPI_GroupAddition.h" +%include "CollectionAPI_GroupShape.h" %include "CollectionAPI_GroupIntersection.h" %include "CollectionAPI_GroupSubstraction.h" %include "CollectionAPI_Field.h" diff --git a/src/CollectionAPI/CollectionAPI_GroupShape.cpp b/src/CollectionAPI/CollectionAPI_GroupShape.cpp new file mode 100644 index 000000000..ba561f3b8 --- /dev/null +++ b/src/CollectionAPI/CollectionAPI_GroupShape.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2014-2020 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_GroupShape.h" + +#include +#include + +CollectionAPI_GroupShape::CollectionAPI_GroupShape( + const std::shared_ptr& theFeature) + : ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +CollectionAPI_GroupShape::CollectionAPI_GroupShape( + const std::shared_ptr& theFeature, + const std::list& theGroupList) + : ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setGroupList(theGroupList); + } +} + +CollectionAPI_GroupShape::~CollectionAPI_GroupShape() +{ +} + +void CollectionAPI_GroupShape::setGroupList( + const std::list& theGroupList) +{ + fillAttribute(theGroupList, mygroupList); + execute(); +} + +void CollectionAPI_GroupShape::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + AttributeSelectionListPtr anAttrList = + aBase->selectionList(CollectionPlugin_GroupShape::LIST_ID()); + + theDumper << aBase << " = model.addGroupShape(" << aDocName << ", " + << anAttrList << ")" << std::endl; +} + +GroupShapePtr addGroupShape(const std::shared_ptr& thePart, + const std::list& theGroupList) +{ + std::shared_ptr aFeature = + thePart->addFeature(CollectionAPI_GroupShape::ID()); + return GroupShapePtr(new CollectionAPI_GroupShape(aFeature, theGroupList)); +} diff --git a/src/CollectionAPI/CollectionAPI_GroupShape.h b/src/CollectionAPI/CollectionAPI_GroupShape.h new file mode 100644 index 000000000..f2d32a0a6 --- /dev/null +++ b/src/CollectionAPI/CollectionAPI_GroupShape.h @@ -0,0 +1,74 @@ +// Copyright (C) 2014-2020 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_GroupShape_H_ +#define CollectionAPI_GroupShape_H_ + +#include "CollectionAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Dumper; +class ModelHighAPI_Selection; + +/// \class CollectionAPI_GroupShape +/// \ingroup CPPHighAPI +/// \brief Interface for Group Shape feature. +class CollectionAPI_GroupShape : public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + COLLECTIONAPI_EXPORT + explicit CollectionAPI_GroupShape(const std::shared_ptr& theFeature); + + /// Constructor with values. + COLLECTIONAPI_EXPORT + CollectionAPI_GroupShape(const std::shared_ptr& theFeature, + const std::list& theGroupList); + + /// Destructor. + COLLECTIONAPI_EXPORT + virtual ~CollectionAPI_GroupShape(); + + INTERFACE_1(CollectionPlugin_GroupShape::ID(), + groupList, CollectionPlugin_GroupShape::LIST_ID(), + ModelAPI_AttributeSelectionList, /** Group list*/) + + /// Set main objects. + COLLECTIONAPI_EXPORT + void setGroupList(const std::list& theGroupList); + + /// Dump wrapped feature + COLLECTIONAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Group Shape object. +typedef std::shared_ptr GroupShapePtr; + +/// \ingroup CPPHighAPI +/// \brief Create Group Shape feature. +COLLECTIONAPI_EXPORT +GroupShapePtr addGroupShape(const std::shared_ptr& thePart, + const std::list& theGroupsList); + +#endif // CollectionAPI_GroupShape_H_ diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index bd65ca86a..21b3fbe07 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -32,6 +32,8 @@ SET(PROJECT_HEADERS CollectionPlugin_Plugin.h CollectionPlugin_Group.h CollectionPlugin_GroupAddition.h + CollectionPlugin_GroupMerge.h + CollectionPlugin_GroupShape.h CollectionPlugin_GroupIntersection.h CollectionPlugin_GroupOperation.h CollectionPlugin_GroupSubstraction.h @@ -49,6 +51,8 @@ SET(PROJECT_SOURCES CollectionPlugin_Plugin.cpp CollectionPlugin_Group.cpp CollectionPlugin_GroupAddition.cpp + CollectionPlugin_GroupMerge.cpp + CollectionPlugin_GroupShape.cpp CollectionPlugin_GroupIntersection.cpp CollectionPlugin_GroupOperation.cpp CollectionPlugin_GroupSubstraction.cpp diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp b/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp index 4fb6cab7f..4799bd3b0 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp +++ b/src/CollectionPlugin/CollectionPlugin_GroupAddition.cpp @@ -19,72 +19,10 @@ #include "CollectionPlugin_GroupAddition.h" -#include -#include -#include -#include -#include -#include - -#include -#include - -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); - - // update the type of selection - updateGroupType(LIST_ID()); - + ResultGroupPtr aGroup; + CollectionPlugin_GroupMerge::execute(aGroup); setResult(aGroup); } diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.h b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h index 74f1be90f..d52da423b 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupAddition.h +++ b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h @@ -22,12 +22,13 @@ #include "CollectionPlugin.h" #include "CollectionPlugin_GroupOperation.h" +#include "CollectionPlugin_GroupMerge.h" /**\class CollectionPlugin_GroupAddition * \ingroup Plugins * \brief Merge several groups of same shape type into single group. */ -class CollectionPlugin_GroupAddition : public CollectionPlugin_GroupOperation +class CollectionPlugin_GroupAddition : public CollectionPlugin_GroupMerge { public: /// Extrusion kind @@ -35,13 +36,7 @@ public: { 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() @@ -51,13 +46,10 @@ public: } /// 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(); + COLLECTIONPLUGIN_EXPORT void execute(); /// Use plugin manager for features creation - CollectionPlugin_GroupAddition(); + CollectionPlugin_GroupAddition() = default; }; diff --git a/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp b/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp new file mode 100644 index 000000000..cfef811bb --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp @@ -0,0 +1,84 @@ +// Copyright (C) 2014-2020 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_GroupMerge.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +void CollectionPlugin_GroupMerge::initAttributes() +{ + data()->addAttribute(CollectionPlugin_GroupMerge::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_GroupMerge::execute(ResultGroupPtr & aGroup) +{ + 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); + + // update the type of selection + updateGroupType(LIST_ID()); +} diff --git a/src/CollectionPlugin/CollectionPlugin_GroupMerge.h b/src/CollectionPlugin/CollectionPlugin_GroupMerge.h new file mode 100644 index 000000000..e56f40fdb --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupMerge.h @@ -0,0 +1,54 @@ +// Copyright (C) 2014-2020 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_GROUPMERGE_H_ +#define COLLECTIONPLUGIN_GROUPMERGE_H_ + +#include "CollectionPlugin.h" +#include "CollectionPlugin_GroupOperation.h" +#include "ModelAPI_ResultGroup.h" + +/**\class CollectionPlugin_GroupMerge + * \ingroup Plugins + * \brief Merge several groups of same or different shape type, + * \the validator being used for the shape type. + */ +class CollectionPlugin_GroupMerge: public CollectionPlugin_GroupOperation +{ +public: + /// 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; + } + + + /// Creates a new group result if needed + COLLECTIONPLUGIN_EXPORT void execute(ResultGroupPtr & aGroup); + + /// Request for initialization of data model of the feature: adding all attributes + COLLECTIONPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + CollectionPlugin_GroupMerge() = default; + +}; + +#endif diff --git a/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp new file mode 100644 index 000000000..a44ecdba7 --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2014-2020 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_GroupShape.h" +#include "ModelAPI_ResultBody.h" + +void CollectionPlugin_GroupShape::execute() +{ + ResultGroupPtr aGroup; + CollectionPlugin_GroupMerge::execute(aGroup); + GeomShapePtr aCompound = aGroup->shape(); + std::shared_ptr theResultBody = document()->createBody(data()); + theResultBody->store(GeomShapePtr()); + if(!aCompound->empty()) + theResultBody->store(aCompound); + setResult(theResultBody); +} diff --git a/src/CollectionPlugin/CollectionPlugin_GroupShape.h b/src/CollectionPlugin/CollectionPlugin_GroupShape.h new file mode 100644 index 000000000..a69a7a2ba --- /dev/null +++ b/src/CollectionPlugin/CollectionPlugin_GroupShape.h @@ -0,0 +1,56 @@ +// Copyright (C) 2014-2020 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_GROUPSHAPE_H_ +#define COLLECTIONPLUGIN_GROUPSHAPE_H_ + +#include "CollectionPlugin.h" +#include "CollectionPlugin_GroupOperation.h" +#include "CollectionPlugin_GroupMerge.h" + +/**\class CollectionPlugin_GroupShape + * \ingroup Plugins + * \brief Merge several groups of different shape type into a single shape. + */ +class CollectionPlugin_GroupShape: public CollectionPlugin_GroupMerge +{ +public: + /// Extrusion kind + inline static const std::string& ID() + { + static const std::string MY_GROUP_ID("GroupShape"); + return MY_GROUP_ID; + } + + /// Returns the kind of a feature + COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = CollectionPlugin_GroupShape::ID(); + return MY_KIND; + } + + /// Creates a new group result if needed + COLLECTIONPLUGIN_EXPORT void execute(); + + /// Use plugin manager for features creation + CollectionPlugin_GroupShape() = default; + +}; + +#endif diff --git a/src/CollectionPlugin/CollectionPlugin_Plugin.cpp b/src/CollectionPlugin/CollectionPlugin_Plugin.cpp index c1da40739..aea358c62 100644 --- a/src/CollectionPlugin/CollectionPlugin_Plugin.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Plugin.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,9 @@ FeaturePtr CollectionPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new CollectionPlugin_GroupIntersection); } else if (theFeatureID == CollectionPlugin_GroupSubstraction::ID()) { return FeaturePtr(new CollectionPlugin_GroupSubstraction); - } + } else if (theFeatureID == CollectionPlugin_GroupShape::ID()) { + return FeaturePtr(new CollectionPlugin_GroupShape); + } // feature of such kind is not found return FeaturePtr(); diff --git a/src/CollectionPlugin/doc/CollectionPlugin.rst b/src/CollectionPlugin/doc/CollectionPlugin.rst index 2b83ddd8c..f47b202f5 100644 --- a/src/CollectionPlugin/doc/CollectionPlugin.rst +++ b/src/CollectionPlugin/doc/CollectionPlugin.rst @@ -16,3 +16,4 @@ Collection plug-in deals with groups of geometrical entities created by selectio groupAdditionFeature.rst groupIntersectionFeature.rst groupSubstractionFeature.rst + groupShapeFeature.rst diff --git a/src/CollectionPlugin/doc/TUI_groupShapeFeature.rst b/src/CollectionPlugin/doc/TUI_groupShapeFeature.rst new file mode 100644 index 000000000..d6f9ea6f7 --- /dev/null +++ b/src/CollectionPlugin/doc/TUI_groupShapeFeature.rst @@ -0,0 +1,11 @@ + + .. _tui_create_group_shape: + +Create Group Shape +===================== + +.. literalinclude:: examples/group_shape.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/CollectionPlugin/doc/examples/group_shape.py b/src/CollectionPlugin/doc/examples/group_shape.py new file mode 100644 index 000000000..20e4bde3f --- /dev/null +++ b/src/CollectionPlugin/doc/examples/group_shape.py @@ -0,0 +1,14 @@ +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")]) +GroupShape_1 = model.addGroupShape(Part_1_doc, [model.selection("COMPOUND", "Group_1"), + model.selection("COMPOUND", "Group_2")]) +model.end() diff --git a/src/CollectionPlugin/doc/groupShapeFeature.rst b/src/CollectionPlugin/doc/groupShapeFeature.rst new file mode 100644 index 000000000..33a84a3a4 --- /dev/null +++ b/src/CollectionPlugin/doc/groupShapeFeature.rst @@ -0,0 +1,36 @@ +.. |group_shape.icon| image:: images/group_shape.png + +Group Shape +============== + +Group shape produces a new shape from union of all the elements of the selected groups. +To create a Group Shape in the active part: + +#. select in the Main Menu *Features - > Group Shape* item or +#. click |group_shape.icon| **Group Shape** button in the toolbar: + +The following property panel appears. + +.. figure:: images/group_shape_property_panel.png + :align: center + + Create a group shape operation + +Input fields: + +- **Name** defines the name of the group, by default, it is **GroupShape_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.addGroupShape(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 shape. + + +**See Also** a sample TUI Script of :ref:`tui_create_group_shape` operation. diff --git a/src/CollectionPlugin/plugin-Collection.xml b/src/CollectionPlugin/plugin-Collection.xml index ea913123b..c20a2b9b6 100644 --- a/src/CollectionPlugin/plugin-Collection.xml +++ b/src/CollectionPlugin/plugin-Collection.xml @@ -31,6 +31,7 @@ + + + + + +