Implementation of Group Addition operation from scratch.
CollectionPlugin.h
CollectionPlugin_Plugin.h
CollectionPlugin_Group.h
+ CollectionPlugin_GroupAddition.h
CollectionPlugin_Field.h
CollectionPlugin_WidgetCreator.h
CollectionPlugin_WidgetField.h
SET(PROJECT_SOURCES
CollectionPlugin_Plugin.cpp
CollectionPlugin_Group.cpp
+ CollectionPlugin_GroupAddition.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
--- /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>
+
+CollectionPlugin_GroupAddition::CollectionPlugin_GroupAddition()
+{
+}
+
+void CollectionPlugin_GroupAddition::initAttributes()
+{
+ data()->addAttribute(CollectionPlugin_Group::LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
+}
+
+void CollectionPlugin_GroupAddition::execute()
+{
+ if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
+ ResultPtr aGroup = document()->createGroup(data());
+ 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_Group::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
#include <CollectionPlugin_Plugin.h>
#include <CollectionPlugin_Group.h>
+#include <CollectionPlugin_GroupAddition.h>
#include <CollectionPlugin_Field.h>
#include <CollectionPlugin_Validators.h>
#include <ModelAPI_Session.h>
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);
}
// feature of such kind is not found
--- /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="GeomValidators_BodyShapes"/>-->
+ </multi_selector>
+</source>
\ No newline at end of file
--- /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 objects"
+ type_choice="Vertices Edges Faces Solids"
+ use_choice="true"
+ clear_in_neutral_point="false"
+ filter_points="false"
+ same_topology="true">
+ <validator id="GeomValidators_BodyShapes"/>
+ </multi_selector>
+</source>
\ No newline at end of file
--- /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 objects"
+ type_choice="Vertices Edges Faces Solids"
+ use_choice="true"
+ clear_in_neutral_point="false"
+ filter_points="false"
+ same_topology="true">
+ <validator id="GeomValidators_BodyShapes"/>
+ </multi_selector>
+</source>
\ No newline at end of file
</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"
+ apply_continue="true"
+ helpfile="groupAdditionFeature.html">
+ <source path="group_addition_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()) {
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;