ADD_SUBDIRECTORY (src/ConstructionPlugin)
ADD_SUBDIRECTORY (src/BuildPlugin)
ADD_SUBDIRECTORY (src/PrimitivesPlugin)
+ADD_SUBDIRECTORY (src/OperaPlugin)
ADD_SUBDIRECTORY (src/GDMLPlugin)
ADD_SUBDIRECTORY (src/FeaturesPlugin)
ADD_SUBDIRECTORY (src/CollectionPlugin)
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)
ModelGeomAlgo
Locale
test_API
+ OperaPlugin
)
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="BuildPlugin" configuration="plugin-Build.xml"/>
<plugin library="PrimitivesPlugin" configuration="plugin-Primitives.xml"/>
+ <plugin library="OperaPlugin" configuration="plugin-Opera.xml"/>
<!--<plugin library="GDMLPlugin" configuration="plugin-GDML.xml"/>-->
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="CollectionPlugin" configuration="plugin-Collection.xml"/>
--- /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(Common)
+
+SET(PROJECT_HEADERS
+ OperaAPI.h
+ OperaAPI_Volume.h
+)
+
+SET(PROJECT_SOURCES
+ OperaAPI_Volume.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ ModelAPI
+ ModelHighAPI
+)
+
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+)
+
+# Plugin headers dependency
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/src/GeomAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+ ${PROJECT_SOURCE_DIR}/src/OperaPlugin
+)
+
+ADD_DEFINITIONS(-DOperaAPI_EXPORTS ${OpenCASCADE_DEFINITIONS})
+ADD_LIBRARY(OperaAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(OperaAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(OperaAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(OperaAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+SET(SWIG_LINK_LIBRARIES
+ OperaAPI
+ ModelHighAPI
+ ModelAPI
+ ${PYTHON_LIBRARIES}
+)
+SET(CMAKE_SWIG_FLAGS -threads -w325,321,302,362,322,383,403)
+
+SET(SWIG_MODULE_OperaAPI_EXTRA_DEPS ${SWIG_MODULE_OperaAPI_EXTRA_DEPS}
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+ doxyhelp.i
+ ${PROJECT_HEADERS}
+)
+
+IF(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
+ SWIG_ADD_LIBRARY(OperaAPI LANGUAGE python SOURCES OperaAPI.i ${PROJECT_HEADERS})
+ELSE()
+ SWIG_ADD_MODULE(OperaAPI python OperaAPI.i ${PROJECT_HEADERS})
+ENDIF()
+SWIG_LINK_LIBRARIES(OperaAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_OperaAPI PROPERTIES DEBUG_OUTPUT_NAME _OperaAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _OperaAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS OperaAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/OperaAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
--- /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_H
+#define OPERAAPI_H
+
+#if defined OPERAAPI_EXPORTS
+#if defined WIN32
+#define OPERAAPI_EXPORT __declspec( dllexport )
+#else
+#define OPERAAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define OPERAAPI_EXPORT __declspec( dllimport )
+#else
+#define OPERAAPI_EXPORT
+#endif
+#endif
+
+#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
+//
+
+/* OperaAPI.i */
+
+%module OperaAPI
+
+%{
+ #include "OperaAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define OPERAAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(OperaAPI_Volume)
+
+// all supported interfaces
+%include "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_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 std::string& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectsList)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ fillAttribute(theMedium, medium());
+ setObjectsList(theObjectsList);
+ }
+}
+
+//==================================================================================================
+OperaAPI_Volume::~OperaAPI_Volume()
+{
+}
+
+//==================================================================================================
+void OperaAPI_Volume::setMedium(const std::string& theMedium)
+{
+ fillAttribute(theMedium, medium());
+ execute();
+}
+
+//==================================================================================================
+void OperaAPI_Volume::setObjectsList(const std::list<ModelHighAPI_Selection>& theObjectsList)
+{
+ fillAttribute(theObjectsList, objectsList());
+ 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_ID());
+ theDumper << aBase << " = model.addVolume(" << aDocName << ", " << anAttrMedium << ", ";
+
+ AttributeSelectionListPtr anAttrList =
+ aBase->selectionList(OperaPlugin_Volume::OBJECTS_LIST_ID());
+ theDumper << anAttrList << ")" << std::endl;
+}
+
+//==================================================================================================
+VolumePtr addVolume(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::string& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectsList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(OperaAPI_Volume::ID());
+ return VolumePtr(new OperaAPI_Volume(aFeature, theMedium, theObjectsList));
+}
--- /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_Selection;
+
+/// \class OperaAPI_Volume
+/// \ingroup CPPHighAPI
+/// \brief Interface for Volume 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
+ explicit OperaAPI_Volume(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectList);
+
+ /// Destructor.
+ OPERAAPI_EXPORT
+ virtual ~OperaAPI_Volume();
+
+ INTERFACE_2(OperaPlugin_Volume::ID(),
+ medium, OperaPlugin_Volume::MEDIUM_ID(),
+ ModelAPI_AttributeString, /** Medium */,
+ objectsList, OperaPlugin_Volume::OBJECTS_LIST_ID(),
+ ModelAPI_AttributeSelectionList, /** Objects list*/)
+
+ /// Set medium
+ OPERAAPI_EXPORT
+ void setMedium(const std::string& theMedium);
+
+ /// Set main objects list.
+ OPERAAPI_EXPORT
+ void setObjectsList(const std::list<ModelHighAPI_Selection>& theObjectsList);
+
+ /// 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 addVolume(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const std::string& theMedium,
+ const std::list<ModelHighAPI_Selection>& theObjectsList);
+
+#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
+//
+
+#ifndef OPERAAPI_SWIG_H_
+#define OPERAAPI_SWIG_H_
+
+ #include <ModelHighAPI_swig.h>
+
+ #include "OperaAPI.h"
+ #include "OperaAPI_Volume.h"
+
+#endif // OPERAAPI_SWIG_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
+#
+
+SET(PROJECT_HEADERS
+ OperaPlugin.h
+ OperaPlugin_Plugin.h
+ OperaPlugin_Volume.h
+)
+
+SET(PROJECT_SOURCES
+ OperaPlugin_Plugin.cpp
+ OperaPlugin_Volume.cpp
+
+)
+
+SET(XML_RESOURCES
+ plugin-Opera.xml
+ volume_widget.xml
+)
+
+SET(TEXT_RESOURCES
+ OperaPlugin_msg_fr.ts
+)
+
+SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES})
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
+INCLUDE_DIRECTORIES(
+ ../ModelAPI
+ ../GeomAPI
+ ../GeomAlgoAPI
+ ../Events
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ ModelAPI
+ GeomAPI
+ GeomAlgoAPI
+)
+
+ADD_DEFINITIONS(-DOPERAPLUGIN_EXPORTS)
+ADD_LIBRARY(OperaPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
+TARGET_LINK_LIBRARIES(OperaPlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS OperaPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
+INSTALL(FILES ${XML_RESOURCES} ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Opera)
+
+include(tests.set)
+
+ADD_UNIT_TESTS(${TEST_NAMES})
+
+if(${HAVE_SALOME})
+ enable_testing()
+ set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/OperaPlugin")
+
+ install(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
+ install(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+ set(TMP_TESTS_NAMES)
+ foreach(tfile ${TEST_NAMES})
+ list(APPEND TMP_TESTS_NAMES "Test/${tfile}")
+ endforeach(tfile ${TEST_NAMES})
+
+ install(FILES ${TMP_TESTS_NAMES} DESTINATION ${TEST_INSTALL_DIRECTORY})
+endif(${HAVE_SALOME})
+
+
--- /dev/null
+# Copyright (C) 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(tests.set)
+
+#SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py")
+#SET(TIMEOUT 300)
+
+foreach(tfile ${TEST_NAMES})
+ set(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ add_test(${TEST_NAME} python ${tfile})
+ set_tests_properties(${TEST_NAME} PROPERTIES LABELS "${SALOME_TEST_LABEL_ADV}")
+endforeach()
--- /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 OPERAPLUGIN_H
+#define OPERAPLUGIN_H
+
+#if defined OPERAPLUGIN_EXPORTS
+#if defined WIN32
+#define OPERAPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define OPERAPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define OPERAPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define OPERAPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
--- /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 <OperaPlugin_Plugin.h>
+#include <OperaPlugin_Volume.h>
+
+#include <ModelAPI_Session.h>
+
+#include <string>
+
+// the only created instance of this plugin
+static OperaPlugin_Plugin* MY_PRIMITIVES_INSTANCE = new OperaPlugin_Plugin();
+
+OperaPlugin_Plugin::OperaPlugin_Plugin()
+{
+ // register this plugin
+ ModelAPI_Session::get()->registerPlugin(this);
+}
+
+FeaturePtr OperaPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+ if (theFeatureID == OperaPlugin_Volume::ID()) {
+ return FeaturePtr(new OperaPlugin_Volume);
+ } else {
+ return FeaturePtr();
+ }
+}
--- /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 OperaPlugin_Plugin_H_
+#define OperaPlugin_Plugin_H_
+
+#include "OperaPlugin.h"
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class OperaPlugin_Plugin
+ * \ingroup Plugins
+ * \brief The main class managing Opera Features as plugins.
+ */
+class OPERAPLUGIN_EXPORT OperaPlugin_Plugin : public ModelAPI_Plugin
+{
+ public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ /// Default constructor
+ OperaPlugin_Plugin();
+
+};
+
+#endif
--- /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 <OperaPlugin_Volume.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Tools.h>
+
+#include <sstream>
+#include <memory>
+
+//=================================================================================================
+OperaPlugin_Volume::OperaPlugin_Volume() // Nothing to do during instantiation
+{
+}
+
+//=================================================================================================
+static GeomShapePtr shapeOfSelection(AttributeSelectionPtr theSel) {
+ GeomShapePtr aResult;
+ FeaturePtr aSelFeature = theSel->contextFeature();
+ if (aSelFeature.get()) {
+ if (aSelFeature->results().empty()) // if selected feature has no results, make nothing
+ return aResult;
+ if (aSelFeature->results().size() == 1) { // for one sub-result don't make compound
+ aResult = aSelFeature->firstResult()->shape();
+ }
+ }
+ if (!aResult.get())
+ aResult = theSel->value();
+ if (!aResult.get()) {
+ if (theSel->context().get())
+ aResult = theSel->context()->shape();
+ }
+ return aResult;
+}
+
+//=================================================================================================
+void OperaPlugin_Volume::initAttributes()
+{
+ // Get Medium
+ data()->addAttribute(MEDIUM_ID(), ModelAPI_AttributeString::typeId());
+
+ // Get Objects
+ data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+}
+
+//=================================================================================================
+void OperaPlugin_Volume::execute()
+{
+ std::string aCopiesMedium = string(MEDIUM_ID())->value();
+ if (aCopiesMedium.empty())
+ {
+ setError("Error: Medium cannot be empty.");
+ return;
+ }
+
+ int aResultIndex = 0;
+
+ AttributeSelectionListPtr aList = selectionList(OBJECTS_LIST_ID());
+ std::wstring aBaseName;
+ for (int aSelIndex = 0; aSelIndex < aList->size(); aSelIndex++) {
+ AttributeSelectionPtr aSel = aList->value(aSelIndex);
+ GeomShapePtr aResult;
+ FeaturePtr aSelFeature = aSel->contextFeature();
+ if (aSelFeature.get()) {
+ if (aSelFeature->results().empty()) // if selected feature has no results, make nothing
+ continue;
+ if (aSelFeature->results().size() == 1) { // for one sub-result don't make compound
+ aResult = aSelFeature->firstResult()->shape();
+ }
+ }
+ if (!aResult.get())
+ aResult = aSel->value();
+ if (!aResult.get()) {
+ if (aSel->context().get())
+ aResult = aSel->context()->shape();
+ }
+
+ // 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();
+ do {
+ std::wostringstream aNameStr;
+ aNameStr << "Volume_" << aBaseName;
+ aName = aNameStr.str();
+ } while (anExistingNames.count(aName));
+ anExistingNames.insert(aName);
+
+ ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+ aResultBody->data()->setName(aName);
+ aResultBody->store(aResult);
+ setResult(aResultBody, aResultIndex++);
+ }
+ // Remove the rest results if there were produced in the previous pass.
+ removeResults(aResultIndex);
+}
--- /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 OperaPlugin_Volume_H_
+#define OperaPlugin_Volume_H_
+
+#include <OperaPlugin.h>
+#include <ModelAPI_Feature.h>
+
+class GeomAPI_Shape;
+class ModelAPI_ResultBody;
+
+/**\class OperaPlugin_Volume
+ * \ingroup Plugins
+ * \brief Feature for creation of a Volume using solids.
+ *
+ * Volume creates Volume object - This volume takes selected solids shape
+ * and transform the result to a volume with a medium for OPERA.
+ */
+class OperaPlugin_Volume : public ModelAPI_Feature
+{
+ public:
+ /// Volume kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_VOLUME_ID("Volume");
+ return MY_VOLUME_ID;
+ }
+ inline static const std::string& MEDIUM_ID()
+ {
+ static const std::string MY_MEDIUM_ID("medium");
+ return MY_MEDIUM_ID;
+ }
+ /// attribute name of selected entities list
+ inline static const std::string& OBJECTS_LIST_ID()
+ {
+ static const std::string MY_OBJECTS_LIST_ID("objects_list");
+ return MY_OBJECTS_LIST_ID;
+ }
+
+ // Creates a new part document if needed
+ OPERAPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ OPERAPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Returns the kind of a feature
+ OPERAPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = OperaPlugin_Volume::ID();
+ return MY_KIND;
+ }
+
+ /// Use plugin manager for features creation
+ OperaPlugin_Volume();
+};
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+
+ <context>
+ <name>workshop</name>
+ <message>
+ <source>Volume</source>
+ <translation>Volume</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>Volume</name>
+ <message>
+ <source>Volume</source>
+ <translation>Volume</translation>
+ </message>
+ <message>
+ <source>Create a volume</source>
+ <translation>Créer un volume</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>Volume:medium</name>
+ <message>
+ <source>Medium</source>
+ <translation>Milieu</translation>
+ </message>
+ <message>
+ <source>Please input the volumes medium</source>
+ <translation>Veuillez indiquer le milieu des volumes</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>Volume:objects_list</name>
+ <message>
+ <source>Objects</source>
+ <translation>Objets</translation>
+ </message>
+ <message>
+ <source>Select solid objects</source>
+ <translation>Sélectionnez les solides</translation>
+ </message>
+ </context>
+
+ <context>
+ <name>Volume:objects_list</name>
+ <message>
+ <source>Attribute "%1" is not initialized.</source>
+ <translation>Sélectionnez les solides.</translation>
+ </message>
+ </context>
+
+</TS>
--- /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 two box (one for error case)
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_2 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create a cylinder
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10)
+
+### Create a sphere
+Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
+
+### Create a volume from the box
+Volume_1 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Box_1_1")])
+
+### Create a volume from the cylinder and the sphere
+Volume_2 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Sphere_1_1")])
+Volume_2.setMedium("Eau")
+
+#Checks
+from GeomAPI import GeomAPI_Shape
+
+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)
+
+model.testNbResults(Volume_2, 2)
+model.testNbSubResults(Volume_2, [0, 0])
+model.testNbSubShapes(Volume_2, GeomAPI_Shape.SOLID, [1, 1])
+model.testNbSubShapes(Volume_2, GeomAPI_Shape.FACE, [3, 1])
+
+### Create a volume with no medium
+Volume_3 = model.addVolume(Part_1_doc, "", [model.selection("SOLID", "Box_2_1")])
+model.testNbResults(Volume_3, 0)
+assert(Volume_3.feature().error() == "Error: Medium cannot be empty.")
+
+### Create a volume with no shapes
+Volume_4 = model.addVolume(Part_1_doc, "Error", [])
+model.testNbResults(Volume_4, 0)
+assert(Volume_4.feature().error() == "Attribute \"objects_list\" is not initialized.")
+
+### Create a volume with bad shapes
+Volume_5 = model.addVolume(Part_1_doc, "Bad Shape", [model.selection("VERTEX", "PartSet/Origin")])
+model.testNbResults(Volume_5, 0)
+assert(Volume_5.feature().error() == "It does not contain element with acceptable shape type. The type should be one of the next: solid")
+
+#=========================================================================
+# End of test
+#=========================================================================
--- /dev/null
+
+.. _operaPlugin:
+
+Opera plug-in
+==================
+
+The Opera plug-in provides a set of common operations to ROOT geometry. It implements the following features:
+
+.. toctree::
+ :titlesonly:
+ :maxdepth: 1
+
+ volumeFeature.rst
--- /dev/null
+
+ .. _tui_create_volume:
+
+Create Volume
+=============
+
+.. literalinclude:: examples/volume.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/volume.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)
+Volume_1 = model.addVolume(Part_1_doc, "Air", [model.selection("SOLID", "Box_1_1")])
+
+model.do()
+model.end()
--- /dev/null
+.. |Volume_button.icon| image:: images/Volume_button.png
+
+Volume
+------
+
+Volume feature creates a basic object used in bulding the ROOT geometrical hierarchy.
+
+To create a Volume in the active part:
+
+#. select in the Main Menu *Opera - > Volume* item or
+#. click |Volume_button.icon| **Volume** button in the toolbar:
+
+Volume is created by a value and a list of solids
+
+.. figure:: images/Volume.png
+ :align: center
+
+Input fields:
+
+- **Medium** defines the name of the medium;
+- **Objects** defines the list of solid objects
+
+**TUI Command**:
+
+.. py:function::
+ model.addVolume(Part_doc, medium, model.selection[("SOLID", ...), ...])
+
+ :param part: The current part object.
+ :param string: A medium name.
+ :param list: A list of solids.
+ :return: Result object.
+
+Result
+""""""
+
+One solid for each selected solid in the volume list with according medium
+
+.. figure:: images/Volume1.png
+ :align: center
+
+ Volume created
+
+**See Also** a sample TUI Script of :ref:`tui_create_volume` operation.
--- /dev/null
+<plugin>
+ <workbench id="Opera" document="Part">
+ <group id="Opera">
+ <feature id="Volume"
+ title="Volume"
+ tooltip="Create a volume"
+ icon="icons/Opera/Volume.png"
+ auto_preview="true"
+ helpfile="volumeFeature.html">
+ <source path="volume_widget.xml"/>
+ </feature>
+ </group>
+ </workbench>
+</plugin>
--- /dev/null
+# Copyright (C) 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
+#
+
+SET(TEST_NAMES
+ TestVolume.py
+)
--- /dev/null
+<source>
+ <stringvalue id="medium"
+ label="Medium"
+ tooltip="Please input the volumes medium">
+ </stringvalue>
+ <multi_selector id="objects_list"
+ label="Objects"
+ 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"))
from .parameter import *
from .partset import *
from .primitives import *
+from .opera import *
from .gdml import *
from .tests import *
--- /dev/null
+# Copyright (C) 2016-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
+#
+"""Package for Opera plugin for SHAPER Opera.
+"""
+
+from OperaAPI import addVolume
<parameter name="PartSet" value="%SHAPER_ROOT_DIR%/share/salome/resources/shaper"/>
<parameter name="XGUI" value="%SHAPER_ROOT_DIR%/share/salome/resources/shaper"/>
</section>
+ <section name="Sketch">
+ <parameter name="operation_cursor" value="1"/>
+ </section>
<section name="Viewer" >
<!-- Viewer preferences -->
<parameter name="face-selection" value="true" />