From c040abb8ae7ecff3c1b7d0dd97a9bf88972df93c Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 7 Jun 2016 11:54:08 +0300 Subject: [PATCH] Add ExchangeAPI, fillAttribute in ModelHighAPI_Tools, ModelHighAPI_Selection and functions to fill SelectionList attribute --- CMakeLists.txt | 1 + src/ExchangeAPI/CMakeLists.txt | 79 +++++++++++++++++++++ src/ExchangeAPI/ExchangeAPI.h | 20 ++++++ src/ExchangeAPI/ExchangeAPI.i | 28 ++++++++ src/ExchangeAPI/ExchangeAPI_Export.cpp | 67 +++++++++++++++++ src/ExchangeAPI/ExchangeAPI_Export.h | 77 ++++++++++++++++++++ src/ExchangeAPI/ExchangeAPI_Import.cpp | 53 ++++++++++++++ src/ExchangeAPI/ExchangeAPI_Import.h | 58 +++++++++++++++ src/ExchangeAPI/ExchangeAPI_swig.h | 16 +++++ src/ExchangeAPI/Test/TestExchange.py | 26 +++++++ src/ModelHighAPI/CMakeLists.txt | 2 + src/ModelHighAPI/ModelHighAPI.i | 6 ++ src/ModelHighAPI/ModelHighAPI_Selection.cpp | 26 ++++++- src/ModelHighAPI/ModelHighAPI_Selection.h | 13 +++- src/ModelHighAPI/ModelHighAPI_Tools.cpp | 29 ++++++++ src/ModelHighAPI/ModelHighAPI_Tools.h | 32 +++++++++ src/ModelHighAPI/ModelHighAPI_swig.h | 2 + 17 files changed, 532 insertions(+), 3 deletions(-) create mode 100644 src/ExchangeAPI/CMakeLists.txt create mode 100644 src/ExchangeAPI/ExchangeAPI.h create mode 100644 src/ExchangeAPI/ExchangeAPI.i create mode 100644 src/ExchangeAPI/ExchangeAPI_Export.cpp create mode 100644 src/ExchangeAPI/ExchangeAPI_Export.h create mode 100644 src/ExchangeAPI/ExchangeAPI_Import.cpp create mode 100644 src/ExchangeAPI/ExchangeAPI_Import.h create mode 100644 src/ExchangeAPI/ExchangeAPI_swig.h create mode 100644 src/ExchangeAPI/Test/TestExchange.py create mode 100644 src/ModelHighAPI/ModelHighAPI_Tools.cpp create mode 100644 src/ModelHighAPI/ModelHighAPI_Tools.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d29b74ad..854053df0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ ADD_SUBDIRECTORY (src/PythonAPI) # High Level C++/Python API ADD_SUBDIRECTORY (src/ModelHighAPI) ADD_SUBDIRECTORY (src/ConstructionAPI) +ADD_SUBDIRECTORY (src/ExchangeAPI) IF(${HAVE_SALOME}) ADD_SUBDIRECTORY (src/SHAPERGUI) diff --git a/src/ExchangeAPI/CMakeLists.txt b/src/ExchangeAPI/CMakeLists.txt new file mode 100644 index 000000000..12279e3c6 --- /dev/null +++ b/src/ExchangeAPI/CMakeLists.txt @@ -0,0 +1,79 @@ +## Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +INCLUDE(Common) + +SET(PROJECT_HEADERS + ExchangeAPI.h + ExchangeAPI_Export.h + ExchangeAPI_Import.h +) + +SET(PROJECT_SOURCES + ExchangeAPI_Export.cpp + ExchangeAPI_Import.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( + # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers + ${PROJECT_SOURCE_DIR}/src/GeomAPI + ${PROJECT_SOURCE_DIR}/src/ExchangePlugin +) + +#TODO(spo): is ${CAS_DEFINITIONS} necessary? +ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS}) +ADD_LIBRARY(ExchangeAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(ExchangeAPI ${PROJECT_LIBRARIES}) + +# SWIG wrapper + +INCLUDE(PythonAPI) + +SET_SOURCE_FILES_PROPERTIES(ExchangeAPI.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(ExchangeAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow") + +#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)? +SET(SWIG_LINK_LIBRARIES + ExchangeAPI + ModelHighAPI + ModelAPI + ${PYTHON_LIBRARIES} +) + +SET(SWIG_MODULE_ExchangeAPI_EXTRA_DEPS ${SWIG_MODULE_ExchangeAPI_EXTRA_DEPS} + ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i + doxyhelp.i + ${PROJECT_HEADERS} +) + +SWIG_ADD_MODULE(ExchangeAPI python ExchangeAPI.i ${PROJECT_HEADERS}) +SWIG_LINK_LIBRARIES(ExchangeAPI ${SWIG_LINK_LIBRARIES}) + +IF(WIN32) + SET_TARGET_PROPERTIES(_ExchangeAPI PROPERTIES DEBUG_OUTPUT_NAME _ExchangeAPI_d) +ENDIF(WIN32) + +INSTALL(TARGETS _ExchangeAPI DESTINATION ${SHAPER_INSTALL_SWIG}) +INSTALL(TARGETS ExchangeAPI DESTINATION ${SHAPER_INSTALL_BIN}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ExchangeAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) + +# Tests + +INCLUDE(UnitTest) + +ADD_UNIT_TESTS( + TestExchange.py +) + +# ADD_SUBDIRECTORY (Test) diff --git a/src/ExchangeAPI/ExchangeAPI.h b/src/ExchangeAPI/ExchangeAPI.h new file mode 100644 index 000000000..a2e9ab8ad --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI.h @@ -0,0 +1,20 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#ifndef EXCHANGEAPI_H +#define EXCHANGEAPI_H + +#if defined EXCHANGEAPI_EXPORTS +#if defined WIN32 +#define EXCHANGEAPI_EXPORT __declspec( dllexport ) +#else +#define EXCHANGEAPI_EXPORT +#endif +#else +#if defined WIN32 +#define EXCHANGEAPI_EXPORT __declspec( dllimport ) +#else +#define EXCHANGEAPI_EXPORT +#endif +#endif + +#endif diff --git a/src/ExchangeAPI/ExchangeAPI.i b/src/ExchangeAPI/ExchangeAPI.i new file mode 100644 index 000000000..5d0f87d90 --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI.i @@ -0,0 +1,28 @@ +/* ExchangeAPI.i */ + +%module ExchangeAPI + +%{ + #include "ExchangeAPI_swig.h" +%} + +%include "doxyhelp.i" + +// import other modules +%import "ModelHighAPI.i" + +// to avoid error on this +#define EXCHANGEAPI_EXPORT + +// standard definitions +%include "typemaps.i" +%include "std_list.i" +%include "std_shared_ptr.i" + +// shared pointers +%shared_ptr(ExchangeAPI_Export) +%shared_ptr(ExchangeAPI_Import) + +// all supported interfaces +%include "ExchangeAPI_Export.h" +%include "ExchangeAPI_Import.h" diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp new file mode 100644 index 000000000..ace1fe58d --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI_Export.cpp @@ -0,0 +1,67 @@ +// Name : ExchangeAPI_Export.cpp +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "ExchangeAPI_Export.h" + +#include +#include +//-------------------------------------------------------------------------------------- +ExchangeAPI_Export::ExchangeAPI_Export( + const std::shared_ptr & theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +ExchangeAPI_Export::ExchangeAPI_Export( + const std::shared_ptr & theFeature, + const std::string & theFilePath, + const std::string & theFileFormat, + const std::list & theSelectionList) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + setFilePath(theFilePath); + setFileFormat(theFileFormat); + setSelectionList(theSelectionList); + execute(); + } +} + +ExchangeAPI_Export::~ExchangeAPI_Export() +{ + +} + +//-------------------------------------------------------------------------------------- +void ExchangeAPI_Export::setFilePath(const std::string & theFilePath) +{ + fillAttribute(theFilePath, myfilePath); +} + +void ExchangeAPI_Export::setFileFormat(const std::string & theFileFormat) +{ + fillAttribute(theFileFormat, myfileFormat); +} + +void ExchangeAPI_Export::setSelectionList( + const std::list & theSelectionList) +{ + fillAttribute(theSelectionList, myselectionList); +} + +//-------------------------------------------------------------------------------------- +ExportPtr exportToFile( + const std::shared_ptr & thePart, + const std::string & theFilePath, + const std::string & theFileFormat, + const std::list & theSelectionList) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ExchangeAPI_Export::ID()); + return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theFileFormat, theSelectionList)); +} diff --git a/src/ExchangeAPI/ExchangeAPI_Export.h b/src/ExchangeAPI/ExchangeAPI_Export.h new file mode 100644 index 000000000..02429cc81 --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI_Export.h @@ -0,0 +1,77 @@ +// Name : ExchangeAPI_Export.h +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_EXCHANGEAPI_EXCHANGEAPI_EXPORT_H_ +#define SRC_EXCHANGEAPI_EXCHANGEAPI_EXPORT_H_ + +//-------------------------------------------------------------------------------------- +#include "ExchangeAPI.h" + +#include +#include + +#include +#include + +#include +//-------------------------------------------------------------------------------------- +class ModelHighAPI_Selection; +//-------------------------------------------------------------------------------------- +/**\class ExchangeAPI_Export + * \ingroup CPPHighAPI + * \brief Interface for Export feature + */ +class ExchangeAPI_Export : public ModelHighAPI_Interface +{ +public: + /// Constructor without values + EXCHANGEAPI_EXPORT + explicit ExchangeAPI_Export(const std::shared_ptr & theFeature); + /// Constructor with values + EXCHANGEAPI_EXPORT + ExchangeAPI_Export(const std::shared_ptr & theFeature, + const std::string & theFilePath, + const std::string & theFileFormat, + const std::list & theSelectionList); + /// Destructor + EXCHANGEAPI_EXPORT + virtual ~ExchangeAPI_Export(); + + INTERFACE_3(ExchangePlugin_ExportFeature::ID(), + filePath, ExchangePlugin_ExportFeature::FILE_PATH_ID(), String, /** File path */, + fileFormat, ExchangePlugin_ExportFeature::FILE_FORMAT_ID(), String, /** File format */, + selectionList, ExchangePlugin_ExportFeature::SELECTION_LIST_ID(), SelectionList, /** Selection list */ + ) + + /// Set file path (without execute) + EXCHANGEAPI_EXPORT + void setFilePath(const std::string & theFilePath); + + /// Set file format (without execute) + EXCHANGEAPI_EXPORT + void setFileFormat(const std::string & theFileFormat); + + + /// Set selection list (without execute) + EXCHANGEAPI_EXPORT + void setSelectionList(const std::list & theSelectionList); +}; + +//! Pointer on Export object +typedef std::shared_ptr ExportPtr; + +/**\ingroup CPPHighAPI + * \brief Create Export feature + */ +EXCHANGEAPI_EXPORT +ExportPtr exportToFile(const std::shared_ptr & thePart, + const std::string & theFilePath, + const std::string & theFileFormat, + const std::list & theSelectionList); + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_EXCHANGEAPI_EXCHANGEAPI_EXPORT_H_ */ diff --git a/src/ExchangeAPI/ExchangeAPI_Import.cpp b/src/ExchangeAPI/ExchangeAPI_Import.cpp new file mode 100644 index 000000000..6cc2c169f --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI_Import.cpp @@ -0,0 +1,53 @@ +// Name : ExchangeAPI_Import.cpp +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "ExchangeAPI_Import.h" + +#include +#include + +#include +//-------------------------------------------------------------------------------------- +ExchangeAPI_Import::ExchangeAPI_Import( + const std::shared_ptr & theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +ExchangeAPI_Import::ExchangeAPI_Import( + const std::shared_ptr & theFeature, + const std::string & theFilePath) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + setFilePath(theFilePath); +} + +ExchangeAPI_Import::~ExchangeAPI_Import() +{ + +} + +//-------------------------------------------------------------------------------------- +void ExchangeAPI_Import::setFilePath(const std::string & theFilePath) +{ + fillAttribute(theFilePath, myfilePath); + + execute(); +} + +//-------------------------------------------------------------------------------------- +// TODO(spo): make add* as static functions of the class +ImportPtr addImport( + const std::shared_ptr & thePart, + const std::string & theFilePath) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ExchangeAPI_Import::ID()); + return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath)); +} diff --git a/src/ExchangeAPI/ExchangeAPI_Import.h b/src/ExchangeAPI/ExchangeAPI_Import.h new file mode 100644 index 000000000..0d9900d6e --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI_Import.h @@ -0,0 +1,58 @@ +// Name : ExchangeAPI_Import.h +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_ +#define SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_ + +//-------------------------------------------------------------------------------------- +#include "ExchangeAPI.h" + +#include + +#include + +#include +#include +//-------------------------------------------------------------------------------------- +/**\class ExchangeAPI_Import + * \ingroup CPPHighAPI + * \brief Interface for Import feature + */ +class ExchangeAPI_Import : public ModelHighAPI_Interface +{ +public: + /// Constructor without values + EXCHANGEAPI_EXPORT + explicit ExchangeAPI_Import(const std::shared_ptr & theFeature); + /// Constructor with values + EXCHANGEAPI_EXPORT + ExchangeAPI_Import(const std::shared_ptr & theFeature, + const std::string & theFilePath); + /// Destructor + EXCHANGEAPI_EXPORT + virtual ~ExchangeAPI_Import(); + + INTERFACE_1(ExchangePlugin_ImportFeature::ID(), + filePath, ExchangePlugin_ImportFeature::FILE_PATH_ID(), String, /** File path */) + + /// Set point values + EXCHANGEAPI_EXPORT + void setFilePath(const std::string & theFilePath); +}; + +//! Importer on Import object +typedef std::shared_ptr ImportPtr; + +/**\ingroup CPPHighAPI + * \brief Create Import feature + */ +EXCHANGEAPI_EXPORT +ImportPtr addImport(const std::shared_ptr & thePart, + const std::string & theFilePath); + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_EXCHANGEAPI_EXCHANGEAPI_IMPORT_H_ */ diff --git a/src/ExchangeAPI/ExchangeAPI_swig.h b/src/ExchangeAPI/ExchangeAPI_swig.h new file mode 100644 index 000000000..80219bb7c --- /dev/null +++ b/src/ExchangeAPI/ExchangeAPI_swig.h @@ -0,0 +1,16 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ExchangeAPI_swig.h +// Created: 07/06/16 +// Author: Sergey POKHODENKO + +#ifndef SRC_EXCHANGEAPI_EXCHANGEAPI_SWIG_H_ +#define SRC_EXCHANGEAPI_EXCHANGEAPI_SWIG_H_ + + #include + #include "ExchangeAPI.h" + + #include "ExchangeAPI_Export.h" + #include "ExchangeAPI_Import.h" + +#endif /* SRC_EXCHANGEAPI_EXCHANGEAPI_SWIG_H_ */ diff --git a/src/ExchangeAPI/Test/TestExchange.py b/src/ExchangeAPI/Test/TestExchange.py new file mode 100644 index 000000000..5f1576c77 --- /dev/null +++ b/src/ExchangeAPI/Test/TestExchange.py @@ -0,0 +1,26 @@ +import unittest + +import ModelAPI +import ExchangeAPI + +class PointTestCase(unittest.TestCase): + + def setUp(self): + self.session = ModelAPI.ModelAPI_Session.get() + self.doc = self.session.moduleDocument() + + def tearDown(self): + self.session.closeAll() + + def test_addImport(self): + self.session.startOperation() + self.feature = ExchangeAPI.addImport(self.doc, "file_path") + self.session.finishOperation() + + def test_addExport(self): + self.session.startOperation() + self.feature = ExchangeAPI.exportToFile(self.doc, "file_path", "file_format", []) + self.session.finishOperation() + +if __name__ == "__main__": + unittest.main() diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index d197f6518..b513ee600 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -8,12 +8,14 @@ SET(PROJECT_HEADERS ModelHighAPI_Interface.h ModelHighAPI_Macro.h ModelHighAPI_Selection.h + ModelHighAPI_Tools.h ) SET(PROJECT_SOURCES ModelHighAPI_Double.cpp ModelHighAPI_Interface.cpp ModelHighAPI_Selection.cpp + ModelHighAPI_Tools.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 003e58a97..63199a34b 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -12,6 +12,7 @@ // standard definitions %include "typemaps.i" +%include "std_list.i" %include "std_string.i" %include "std_shared_ptr.i" @@ -41,3 +42,8 @@ %include "ModelHighAPI_Double.h" %include "ModelHighAPI_Interface.h" %include "ModelHighAPI_Macro.h" +%include "ModelHighAPI_Selection.h" +%include "ModelHighAPI_Tools.h" + +// std::list -> [] +%template(SelectionList) std::list; diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index 1c2cca5bf..e997aa4e0 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -8,6 +8,7 @@ #include "ModelHighAPI_Selection.h" #include +#include //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- @@ -32,7 +33,7 @@ struct fill_visitor : boost::static_visitor { mutable std::shared_ptr myAttribute; - fill_visitor(std::shared_ptr & theAttribute) + fill_visitor(const std::shared_ptr & theAttribute) : myAttribute(theAttribute) {} void operator()(const ResultSubShapePair & thePair) const { myAttribute->setValue(thePair.first, thePair.second); } @@ -40,7 +41,28 @@ struct fill_visitor : boost::static_visitor }; void ModelHighAPI_Selection::fillAttribute( - std::shared_ptr & theAttribute) const + const std::shared_ptr & theAttribute) const { boost::apply_visitor(fill_visitor(theAttribute), myValue); } + +//-------------------------------------------------------------------------------------- +struct append_visitor : boost::static_visitor +{ + mutable std::shared_ptr myAttribute; + + append_visitor(const std::shared_ptr & theAttribute) + : myAttribute(theAttribute) {} + + void operator()(const ResultSubShapePair & thePair) const { myAttribute->append(thePair.first, thePair.second); } + void operator()(const TypeSubShapeNamePair & thePair) const { + // Note: the reverse order (first - type, second - sub-shape name) + myAttribute->append(thePair.second, thePair.first); + } +}; + +void ModelHighAPI_Selection::appendToList( + const std::shared_ptr & theAttribute) const +{ + boost::apply_visitor(append_visitor(theAttribute), myValue); +} diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.h b/src/ModelHighAPI/ModelHighAPI_Selection.h index a39700465..36706aacb 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.h +++ b/src/ModelHighAPI/ModelHighAPI_Selection.h @@ -8,6 +8,8 @@ #define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_ //-------------------------------------------------------------------------------------- +#include "ModelHighAPI.h" + #include #include #include @@ -16,6 +18,7 @@ //-------------------------------------------------------------------------------------- class GeomAPI_Shape; class ModelAPI_AttributeSelection; +class ModelAPI_AttributeSelectionList; class ModelAPI_Result; //-------------------------------------------------------------------------------------- typedef std::pair, std::shared_ptr > ResultSubShapePair; @@ -29,16 +32,24 @@ class ModelHighAPI_Selection { public: /// Constructor for result and sub-shape + MODELHIGHAPI_EXPORT ModelHighAPI_Selection(const std::shared_ptr& theContext = std::shared_ptr(), const std::shared_ptr& theSubShape = std::shared_ptr()); /// Constructor for sub-shape by the textual Name + MODELHIGHAPI_EXPORT ModelHighAPI_Selection(const std::string& theType, const std::string& theSubShapeName); /// Destructor + MODELHIGHAPI_EXPORT virtual ~ModelHighAPI_Selection(); /// Fill attribute values - virtual void fillAttribute(std::shared_ptr & theAttribute) const; + MODELHIGHAPI_EXPORT + virtual void fillAttribute(const std::shared_ptr & theAttribute) const; + + /// Append to list attribute + MODELHIGHAPI_EXPORT + virtual void appendToList(const std::shared_ptr & theAttribute) const; private: boost::variant myValue; diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp new file mode 100644 index 000000000..fed0d7b89 --- /dev/null +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -0,0 +1,29 @@ +// Name : ModelHighAPI_Tools.cpp +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "ModelHighAPI_Tools.h" + +#include +#include + +#include "ModelHighAPI_Selection.h" +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->clear(); + for (auto it = theValue.begin(); it != theValue.end(); ++it) + it->appendToList(theAttribute); +} + +//-------------------------------------------------------------------------------------- +void fillAttribute(const std::string & theValue, + const std::shared_ptr & theAttribute) +{ + theAttribute->setValue(theValue); +} +//-------------------------------------------------------------------------------------- diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.h b/src/ModelHighAPI/ModelHighAPI_Tools.h new file mode 100644 index 000000000..fc4dafda2 --- /dev/null +++ b/src/ModelHighAPI/ModelHighAPI_Tools.h @@ -0,0 +1,32 @@ +// Name : ModelHighAPI_Tools.h +// Purpose: +// +// History: +// 07/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ +#define SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ + +//-------------------------------------------------------------------------------------- +#include "ModelHighAPI.h" + +#include +#include +#include +//-------------------------------------------------------------------------------------- +class ModelAPI_AttributeSelectionList; +class ModelAPI_AttributeString; +//-------------------------------------------------------------------------------------- +class ModelHighAPI_Selection; +//-------------------------------------------------------------------------------------- +MODELHIGHAPI_EXPORT +void fillAttribute(const std::list & theValue, + const std::shared_ptr & theAttribute); + +MODELHIGHAPI_EXPORT +void fillAttribute(const std::string & theValue, + const std::shared_ptr & theAttribute); + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */ diff --git a/src/ModelHighAPI/ModelHighAPI_swig.h b/src/ModelHighAPI/ModelHighAPI_swig.h index 35d06b762..7fa918cd0 100644 --- a/src/ModelHighAPI/ModelHighAPI_swig.h +++ b/src/ModelHighAPI/ModelHighAPI_swig.h @@ -13,5 +13,7 @@ #include "ModelHighAPI_Double.h" #include "ModelHighAPI_Interface.h" #include "ModelHighAPI_Macro.h" + #include "ModelHighAPI_Selection.h" + #include "ModelHighAPI_Tools.h" #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SWIG_H_ */ -- 2.39.2