Python dump and unit tests for Group Addition operation.
SET(PROJECT_HEADERS
CollectionAPI.h
CollectionAPI_Group.h
+ CollectionAPI_GroupAddition.h
CollectionAPI_Field.h
)
SET(PROJECT_SOURCES
CollectionAPI_Group.cpp
+ CollectionAPI_GroupAddition.cpp
CollectionAPI_Field.cpp
)
#include "CollectionAPI.h"
#include "CollectionAPI_Group.h"
+ #include "CollectionAPI_GroupAddition.h"
#include "CollectionAPI_Field.h"
#endif // CollectionAPI_swig_H_
// shared pointers
%shared_ptr(CollectionAPI_Group)
+%shared_ptr(CollectionAPI_GroupAddition)
%shared_ptr(CollectionAPI_Field)
// all supported interfaces
%include "CollectionAPI_Group.h"
+%include "CollectionAPI_GroupAddition.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 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_Group_H_
TestGroupMove19.py
TestGroupMove20.py
TestGroupShareTopology.py
+ TestGroupAddition.py
+ TestGroupAddition_Error.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
+#
+
+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() != "")
// 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 <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();
}
"""
from CollectionAPI import addGroup, addField
+from CollectionAPI import addGroupAddition