ADD_SUBDIRECTORY (src/ParametersAPI)
ADD_SUBDIRECTORY (src/PartSetAPI)
ADD_SUBDIRECTORY (src/PrimitivesAPI)
+ADD_SUBDIRECTORY (src/OperaAPI)
ADD_SUBDIRECTORY (src/SketchAPI)
ADD_SUBDIRECTORY (src/GDMLAPI)
ADD_SUBDIRECTORY (src/ConnectorAPI)
SET(PROJECT_HEADERS
OperaAPI.h
- OperaAPI_addVolume.h
+ OperaAPI_Volume.h
)
SET(PROJECT_SOURCES
- OperaAPI_addVolume.cpp
+ OperaAPI_Volume.cpp
)
SET(PROJECT_LIBRARIES
#endif
#endif
-#endif //PRIMITIVESAPI_H
+#endif //OPERAAPI_H
--- /dev/null
+// Copyright (C) 2014-2021 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 "OperaAPI_Volume.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+OperaAPI_Volume::OperaAPI_Volume(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+OperaAPI_Volume::OperaAPI_Volume(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectList)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(OperaPlugin_Volume::MEDIUM(), medium());
+ setObjectList(theObjectList);
+ }
+}
+
+//==================================================================================================
+OperaAPI_Volume::~OperaAPI_Volume() {}
+
+//==================================================================================================
+void OperaAPI_Volume::setMedium(const ModelHighAPI_Double& theMedium)
+{
+ fillAttribute(OperaPlugin_Volume::MEDIUM(), medium());
+
+ execute();
+}
+
+//==================================================================================================
+void OperaAPI_Volume::setObjectList(const std::list<ModelHighAPI_Selection>& theObjectList)
+{
+ fillAttribute(theObjectList, myvolumeList);
+
+ execute();
+}
+
+//==================================================================================================
+void OperaAPI_Volume::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeStringPtr anAttrMedium = aBase->string(OperaPlugin_Volume::MEDIUM());
+ theDumper << aBase << " = model.Volume(" << aDocName << ", " << anAttrMedium << ", ";
+
+ AttributeSelectionListPtr anAttrList = aBase->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID());
+ if (anAttrList->isWholeResultAllowed() && !anAttrList->selectionType().empty())
+ theDumper<<"\""<<anAttrList->selectionType()<<"\", ";
+ theDumper << anAttrList;
+ if (anAttrList->isGeometricalSelection())
+ theDumper <<", True";
+ theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+VolumePtr Volume(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(OperaAPI_Volume::ID());
+ aFeature->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID())->setGeometricalSelection(true);
+ return VolumePtr(new OperaAPI_Volume(aFeature, theMedium, theObjectList));
+}
--- /dev/null
+// Copyright (C) 2014-2021 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 OPERAAPI_VOLUME_H_
+#define OPERAAPI_VOLUME_H_
+
+#include "OperaAPI.h"
+#include <OperaPlugin_Volume.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class OperaAPI_Volume
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Box feature.
+class OperaAPI_Volume: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ OPERAAPI_EXPORT
+ explicit OperaAPI_Volume(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ OPERAAPI_EXPORT
+ OperaAPI_Volume(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectList);
+
+ /// Destructor.
+ OPERAAPI_EXPORT
+ virtual ~OperaAPI_Volume();
+
+ INTERFACE_2(OperaPlugin_Volume::ID(),
+ medium, OperaPlugin_Volume::MEDIUM(),
+ ModelAPI_AttributeString, /** Volume medium */,
+ volumeList, OperaPlugin_Volume::VOLUME_LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Group list*/)
+
+ /// Set medium
+ OPERAAPI_EXPORT
+ void setMedium(const ModelHighAPI_Double& theMedium);
+
+ /// Set main objects list.
+ OPERAAPI_EXPORT
+ void setObjectList(const std::list<ModelHighAPI_Selection>& theObjectList);
+
+ /// Dump wrapped feature
+ OPERAAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer Volume feature
+typedef std::shared_ptr<OperaAPI_Volume> VolumePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Volume feature.
+OPERAAPI_EXPORT
+VolumePtr Volume(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectList);
+
+#endif // OperaAPI_Volume_H_
+++ /dev/null
-// Copyright (C) 2014-2021 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 "OperaAPI_addVolume.h"
-
-#include <ModelHighAPI_Dumper.h>
-#include <ModelHighAPI_Tools.h>
-
-//==================================================================================================
-OperaAPI_addVolume::OperaAPI_addVolume(const std::shared_ptr<ModelAPI_Feature>& theFeature)
-: ModelHighAPI_Interface(theFeature)
-{
- initialize();
-}
-
-//==================================================================================================
-OperaAPI_addVolume::OperaAPI_addVolume(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const ModelHighAPI_Double& theMedium,
- const std::list<ModelHighAPI_Selection>& theObjectList)
-: ModelHighAPI_Interface(theFeature)
-{
- if(initialize()) {
- fillAttribute(OperaPlugin_Volume::MEDIUM(), medium());
- setObjectList(theObjectList);
- }
-}
-
-//==================================================================================================
-OperaAPI_addVolume::~OperaAPI_addVolume() {}
-
-//==================================================================================================
-void OperaAPI_addVolume::setMedium(const ModelHighAPI_Double& theMedium)
-{
- fillAttribute(OperaPlugin_Volume::MEDIUM(), medium());
-
- execute();
-}
-
-//==================================================================================================
-void OperaAPI_addVolume::setObjectList(const std::list<ModelHighAPI_Selection>& theObjectList)
-{
- fillAttribute(theObjectList, myvolumeList);
-
- execute();
-}
-
-//==================================================================================================
-void OperaAPI_addVolume::dump(ModelHighAPI_Dumper& theDumper) const
-{
- FeaturePtr aBase = feature();
- const std::string& aDocName = theDumper.name(aBase->document());
-
- AttributeStringPtr anAttrMedium = aBase->string(OperaPlugin_Volume::MEDIUM());
- theDumper << aBase << " = model.addVolume(" << aDocName << ", " << anAttrMedium << ", ";
-
- AttributeSelectionListPtr anAttrList = aBase->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID());
- if (anAttrList->isWholeResultAllowed() && !anAttrList->selectionType().empty())
- theDumper<<"\""<<anAttrList->selectionType()<<"\", ";
- theDumper << anAttrList;
- if (anAttrList->isGeometricalSelection())
- theDumper <<", True";
- theDumper << ")" << std::endl;
-}
-
-//==================================================================================================
-VolumePtr addVolume(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Double& theMedium,
- const std::list<ModelHighAPI_Selection>& theObjectList)
-{
- std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(OperaAPI_addVolume::ID());
- aFeature->selectionList(OperaPlugin_Volume::VOLUME_LIST_ID())->setGeometricalSelection(true);
- return VolumePtr(new OperaAPI_addVolume(aFeature, theMedium, theObjectList));
-}
+++ /dev/null
-// Copyright (C) 2014-2021 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 OPERAAPI_ADDVOLUME_H_
-#define OPERAAPI_ADDVOLUME_H_
-
-#include "OperaAPI.h"
-#include <OperaPlugin_Volume.h>
-
-#include <ModelHighAPI_Interface.h>
-#include <ModelHighAPI_Macro.h>
-
-class ModelHighAPI_Double;
-class ModelHighAPI_Selection;
-
-/// \class OperaAPI_addVolume
-/// \ingroup CPPHighAPI
-/// \brief Interface for primitive Box feature.
-class OperaAPI_addVolume: public ModelHighAPI_Interface
-{
-public:
- /// Constructor without values.
- OPERAAPI_EXPORT
- explicit OperaAPI_addVolume(const std::shared_ptr<ModelAPI_Feature>& theFeature);
-
- /// Constructor with values.
- OPERAAPI_EXPORT
- OperaAPI_addVolume(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const ModelHighAPI_Double& theMedium,
- const std::list<ModelHighAPI_Selection>& theObjectList);
-
- /// Destructor.
- OPERAAPI_EXPORT
- virtual ~OperaAPI_addVolume();
-
- INTERFACE_2(OperaPlugin_Volume::ID(),
- medium, OperaPlugin_Volume::MEDIUM(),
- ModelAPI_AttributeString, /** Volume medium */,
- volumeList, OperaPlugin_Volume::VOLUME_LIST_ID(),
- ModelAPI_AttributeSelectionList, /** Group list*/)
-
- /// Set medium
- OPERAAPI_EXPORT
- void setMedium(const ModelHighAPI_Double& theMedium);
-
- /// Set main objects list.
- OPERAAPI_EXPORT
- void setObjectList(const std::list<ModelHighAPI_Selection>& theObjectList);
-
- /// Dump wrapped feature
- OPERAAPI_EXPORT
- virtual void dump(ModelHighAPI_Dumper& theDumper) const;
-};
-
-/// Pointer addVolume feature
-typedef std::shared_ptr<OperaAPI_addVolume> VolumePtr;
-
-/// \ingroup CPPHighAPI
-/// \brief Create addVolume feature.
-OPERAAPI_EXPORT
-VolumePtr addVolume(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Double& theMedium,
- const std::list<ModelHighAPI_Selection>& theObjectList);
-
-#endif // OperaAPI_addVolume_H_
SET(XML_RESOURCES
plugin-Opera.xml
- addvolume_widget.xml
+ volume_widget.xml
)
SET(TEXT_RESOURCES
{
// Get Medium
data()->addAttribute(MEDIUM(), ModelAPI_AttributeString::typeId());
-
+
// Get Objects
data()->addAttribute(VOLUME_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
}
aResult = aSel->context()->shape();
}
- std::set<std::wstring> anExistingNames;
- std::wstring aBaseName = aSel->context()->name();
+ // Handle naming : Volume_<name_of_feature_used>
std::wstring aName;
+ std::set<std::wstring> anExistingNames;
+ std::wstring aBaseName = aSel->context() ? aSel->context()->data()->name() :
+ aSel->contextFeature()->firstResult()->data()->name();
int anInd = 0;
do {
anInd++;
/// Box kind
inline static const std::string& ID()
{
- static const std::string MY_VOLUME_ID("addVolume");
+ static const std::string MY_VOLUME_ID("Volume");
return MY_VOLUME_ID;
}
inline static const std::string& MEDIUM()
+++ /dev/null
-# Copyright (C) 2014-2021 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
-#
-
-"""
- TestAddVolume.py
- Test case of OperaPlugin_addVolume
-"""
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-from salome.shaper import model
-
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-
-#=========================================================================
-# Create a Box, a Torus and a Cylinder
-#=========================================================================
-Box_1 = model.addBox(Part_1_doc, 10, 20, 10)
-Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 3)
-Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
-
-#=========================================================================
-# Create one Volume
-#=========================================================================
-
-Volume_1 = model.addVolume(Part_1_doc, "Test_medium", [model.selection("SOLID", "Box_1")])
-
-#=========================================================================
-# Check results
-#=========================================================================
-
-from GeomAPI import GeomAPI_Shape
-
-# TODO : Check this
-# TODO : Do I need a testNbVolume ??
-model.testNbResults(Volume_1, 1)
-model.testNbSubResults(Volume_1, [0])
-model.testNbSubShapes(Volume_1, GeomAPI_Shape.SOLID, [1])
-model.testNbSubShapes(Volume_1, GeomAPI_Shape.FACE, [6])
-model.testHaveNamingFaces(Volume_1, model, Part_1_doc)
-
-#=========================================================================
-# Create two volumes at once
-#=========================================================================
-
-Volume_2 = model.addVolume(Part_1_doc, "Test_medium_2", [model.selection("SOLID", "Torus_1"),
- model.selection("SOLID", "Cylinder_1")])
-
-#=========================================================================
-# Check results
-#=========================================================================
-
-# TODO : Check this
-
-model.testNbResults(Volume_2, 2)
-model.testNbSubResults(Volume_2, [0])
-model.testNbSubShapes(Volume_2, GeomAPI_Shape.SOLID, [2])
-
-#=========================================================================
-# End of test
-#=========================================================================
-
-from salome.shaper import model
-assert(model.checkPythonDump())
--- /dev/null
+# Copyright (C) 2014-2021 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
+#
+
+"""
+ TestVolume.py
+ Test case of OperaPlugin_Volume
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+#=========================================================================
+# Create a Box, a Torus and a Cylinder
+#=========================================================================
+Box_1 = model.addBox(Part_1_doc, 10, 20, 10)
+Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 3)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+
+#=========================================================================
+# Create one Volume
+#=========================================================================
+
+Volume_1 = model.Volume(Part_1_doc, "Test_medium", [model.selection("SOLID", "Box_1")])
+
+#=========================================================================
+# Check results
+#=========================================================================
+
+from GeomAPI import GeomAPI_Shape
+
+# TODO : Check this
+# TODO : Do I need a testNbVolume ??
+model.testNbResults(Volume_1, 1)
+model.testNbSubResults(Volume_1, [0])
+model.testNbSubShapes(Volume_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Volume_1, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(Volume_1, model, Part_1_doc)
+
+#=========================================================================
+# Create two volumes at once
+#=========================================================================
+
+Volume_2 = model.Volume(Part_1_doc, "Test_medium_2", [model.selection("SOLID", "Torus_1"),
+ model.selection("SOLID", "Cylinder_1")])
+
+#=========================================================================
+# Check results
+#=========================================================================
+
+# TODO : Check this
+
+model.testNbResults(Volume_2, 2)
+model.testNbSubResults(Volume_2, [0])
+model.testNbSubShapes(Volume_2, GeomAPI_Shape.SOLID, [2])
+
+#=========================================================================
+# End of test
+#=========================================================================
+
+from salome.shaper import model
+assert(model.checkPythonDump())
+++ /dev/null
-<source>
- <stringvalue id="medium"
- label="Medium"
- tooltip="Please input the volumes medium">
- </stringvalue>
- <multi_selector id="volume_list"
- label="Select solids"
- tooltip="Select solid objects"
- shape_types="solids"
- concealment="true">
- <validator id="GeomValidators_ShapeType" parameters="solid"/>
- </multi_selector>
-</source>
<workbench id="Opera" document="Part">
<group id="Opera">
<feature
- id="addVolume"
- title="addVolume"
+ id="Volume"
+ title="Volume"
tooltip="Create a volume"
- icon="icons/Opera/addVolume.png"
+ icon="icons/Opera/Volume.png"
auto_preview="true"
- helpfile="addvolumeFeature.html">
- <source path="addvolume_widget.xml"/>
+ helpfile="volumeFeature.html">
+ <source path="volume_widget.xml"/>
</feature>
</group>
</workbench>
#
SET(TEST_NAMES
- TestAddVolume.py
+ TestVolume.py
)
--- /dev/null
+<source>
+ <stringvalue id="medium"
+ label="Medium"
+ tooltip="Please input the volumes medium">
+ </stringvalue>
+ <multi_selector id="volume_list"
+ label="Select solids"
+ tooltip="Select solid objects"
+ shape_types="solids"
+ concealment="true">
+ <validator id="GeomValidators_ShapeType" parameters="solid"/>
+ </multi_selector>
+</source>
import PrimitivesAPI
PrimitivesAPI.PrimitivesAPI_Box(self.part.addFeature("Box"))
+ import OperaAPI
+ OperaAPI.OperaAPI_Volume(self.part.addFeature("Volume"))
+
import ParametersAPI
ParametersAPI.ParametersAPI_Parameter(self.part.addFeature("Parameter"))
"""Package for Opera plugin for SHAPER Opera.
"""
-from OperaAPI import addVolume
+from OperaAPI import Volume