Salome HOME
Add ExchangeAPI, fillAttribute in ModelHighAPI_Tools, ModelHighAPI_Selection and...
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 7 Jun 2016 08:54:08 +0000 (11:54 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:03 +0000 (14:41 +0300)
17 files changed:
CMakeLists.txt
src/ExchangeAPI/CMakeLists.txt [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI.h [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI.i [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI_Export.cpp [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI_Export.h [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI_Import.cpp [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI_Import.h [new file with mode: 0644]
src/ExchangeAPI/ExchangeAPI_swig.h [new file with mode: 0644]
src/ExchangeAPI/Test/TestExchange.py [new file with mode: 0644]
src/ModelHighAPI/CMakeLists.txt
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_Selection.cpp
src/ModelHighAPI/ModelHighAPI_Selection.h
src/ModelHighAPI/ModelHighAPI_Tools.cpp [new file with mode: 0644]
src/ModelHighAPI/ModelHighAPI_Tools.h [new file with mode: 0644]
src/ModelHighAPI/ModelHighAPI_swig.h

index 7d29b74ad15ac897f2222446491ebac24b8e38ba..854053df0333441adcef8ecdd4134ef96e94c9a3 100644 (file)
@@ -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 (file)
index 0000000..12279e3
--- /dev/null
@@ -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 (file)
index 0000000..a2e9ab8
--- /dev/null
@@ -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 (file)
index 0000000..5d0f87d
--- /dev/null
@@ -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 (file)
index 0000000..ace1fe5
--- /dev/null
@@ -0,0 +1,67 @@
+// Name   : ExchangeAPI_Export.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ExchangeAPI_Export.h"
+
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+ExchangeAPI_Export::ExchangeAPI_Export(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+ExchangeAPI_Export::ExchangeAPI_Export(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::string & theFilePath,
+    const std::string & theFileFormat,
+    const std::list<ModelHighAPI_Selection> & 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<ModelHighAPI_Selection> & theSelectionList)
+{
+  fillAttribute(theSelectionList, myselectionList);
+}
+
+//--------------------------------------------------------------------------------------
+ExportPtr exportToFile(
+    const std::shared_ptr<ModelAPI_Document> & thePart,
+    const std::string & theFilePath,
+    const std::string & theFileFormat,
+    const std::list<ModelHighAPI_Selection> & theSelectionList)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> 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 (file)
index 0000000..02429cc
--- /dev/null
@@ -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 <list>
+#include <string>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+#include <ExchangePlugin_ExportFeature.h>
+//--------------------------------------------------------------------------------------
+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<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  EXCHANGEAPI_EXPORT
+  ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                     const std::string & theFilePath,
+                     const std::string & theFileFormat,
+                     const std::list<ModelHighAPI_Selection> & 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<ModelHighAPI_Selection> & theSelectionList);
+};
+
+//! Pointer on Export object
+typedef std::shared_ptr<ExchangeAPI_Export> ExportPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Export feature
+ */
+EXCHANGEAPI_EXPORT
+ExportPtr exportToFile(const std::shared_ptr<ModelAPI_Document> & thePart,
+                       const std::string & theFilePath,
+                       const std::string & theFileFormat,
+                       const std::list<ModelHighAPI_Selection> & 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 (file)
index 0000000..6cc2c16
--- /dev/null
@@ -0,0 +1,53 @@
+// Name   : ExchangeAPI_Import.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ExchangeAPI_Import.h"
+
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
+
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+ExchangeAPI_Import::ExchangeAPI_Import(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+ExchangeAPI_Import::ExchangeAPI_Import(
+    const std::shared_ptr<ModelAPI_Feature> & 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<ModelAPI_Document> & thePart,
+    const std::string & theFilePath)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> 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 (file)
index 0000000..0d9900d
--- /dev/null
@@ -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 <string>
+
+#include <ExchangePlugin_ImportFeature.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+/**\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<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  EXCHANGEAPI_EXPORT
+  ExchangeAPI_Import(const std::shared_ptr<ModelAPI_Feature> & 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<ExchangeAPI_Import> ImportPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Import feature
+ */
+EXCHANGEAPI_EXPORT
+ImportPtr addImport(const std::shared_ptr<ModelAPI_Document> & 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 (file)
index 0000000..80219bb
--- /dev/null
@@ -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 <ModelHighAPI_swig.h>
+  #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 (file)
index 0000000..5f1576c
--- /dev/null
@@ -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()
index d197f65186245cb6bdf951a227c1cd87b14a18d2..b513ee600dc3a01cbe626e4d6a08486d85469b3e 100644 (file)
@@ -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
index 003e58a9767b94e0357f5bce6f62184e46295a36..63199a34b4957b1afa32ee4c89dbea6f6b1d186d 100644 (file)
@@ -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<ModelHighAPI_Selection>;
index 1c2cca5bfdc887257dcecda85949cd7c6b3cd807..e997aa4e01db5cd53d2304e9e7f9c4de986de32a 100644 (file)
@@ -8,6 +8,7 @@
 #include "ModelHighAPI_Selection.h"
 
 #include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeSelectionList.h>
 //--------------------------------------------------------------------------------------
 
 //--------------------------------------------------------------------------------------
@@ -32,7 +33,7 @@ struct fill_visitor : boost::static_visitor<void>
 {
   mutable std::shared_ptr<ModelAPI_AttributeSelection> myAttribute;
 
-  fill_visitor(std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
+  fill_visitor(const std::shared_ptr<ModelAPI_AttributeSelection> & 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>
 };
 
 void ModelHighAPI_Selection::fillAttribute(
-    std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
+    const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
 {
   boost::apply_visitor(fill_visitor(theAttribute), myValue);
 }
+
+//--------------------------------------------------------------------------------------
+struct append_visitor : boost::static_visitor<void>
+{
+  mutable std::shared_ptr<ModelAPI_AttributeSelectionList> myAttribute;
+
+  append_visitor(const std::shared_ptr<ModelAPI_AttributeSelectionList> & 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<ModelAPI_AttributeSelectionList> & theAttribute) const
+{
+  boost::apply_visitor(append_visitor(theAttribute), myValue);
+}
index a3970046576f8523a85adbacd2124d7800458062..36706aacbc612956fff2a30723a0310a2344d6e6 100644 (file)
@@ -8,6 +8,8 @@
 #define SRC_MODELHIGHAPI_MODELHIGHAPI_SELECTION_H_
 
 //--------------------------------------------------------------------------------------
+#include "ModelHighAPI.h"
+
 #include <memory>
 #include <string>
 #include <utility>
@@ -16,6 +18,7 @@
 //--------------------------------------------------------------------------------------
 class GeomAPI_Shape;
 class ModelAPI_AttributeSelection;
+class ModelAPI_AttributeSelectionList;
 class ModelAPI_Result;
 //--------------------------------------------------------------------------------------
 typedef std::pair<std::shared_ptr<ModelAPI_Result>, std::shared_ptr<GeomAPI_Shape> > ResultSubShapePair;
@@ -29,16 +32,24 @@ class ModelHighAPI_Selection
 {
 public:
   /// Constructor for result and sub-shape
+  MODELHIGHAPI_EXPORT
   ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext = std::shared_ptr<ModelAPI_Result>(),
                          const std::shared_ptr<GeomAPI_Shape>& theSubShape = std::shared_ptr<GeomAPI_Shape>());
   /// 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<ModelAPI_AttributeSelection> & theAttribute) const;
+  MODELHIGHAPI_EXPORT
+  virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const;
+
+  /// Append to list attribute
+  MODELHIGHAPI_EXPORT
+  virtual void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
 
 private:
   boost::variant<ResultSubShapePair, TypeSubShapeNamePair> myValue;
diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp
new file mode 100644 (file)
index 0000000..fed0d7b
--- /dev/null
@@ -0,0 +1,29 @@
+// Name   : ModelHighAPI_Tools.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI_Tools.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeString.h>
+
+#include "ModelHighAPI_Selection.h"
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeSelectionList> & 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<ModelAPI_AttributeString> & theAttribute)
+{
+  theAttribute->setValue(theValue);
+}
+//--------------------------------------------------------------------------------------
diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.h b/src/ModelHighAPI/ModelHighAPI_Tools.h
new file mode 100644 (file)
index 0000000..fc4dafd
--- /dev/null
@@ -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 <list>
+#include <memory>
+#include <string>
+//--------------------------------------------------------------------------------------
+class ModelAPI_AttributeSelectionList;
+class ModelAPI_AttributeString;
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::list<ModelHighAPI_Selection> & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute);
+
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::string & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */ 
index 35d06b7622aa5284ea3ef40d9e0e5f54c6eb638e..7fa918cd0bc6852943a627f0c8c3d46a54317187 100644 (file)
@@ -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_ */