]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add PartSetAPI
authorspo <sergey.pokhodenko@opencascade.com>
Thu, 16 Jun 2016 13:10:18 +0000 (16:10 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:12 +0000 (14:41 +0300)
CMakeLists.txt
src/ModelHighAPI/ModelHighAPI_Macro.h
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h
src/PartSetAPI/CMakeLists.txt [new file with mode: 0644]
src/PartSetAPI/PartSetAPI.h [new file with mode: 0644]
src/PartSetAPI/PartSetAPI.i [new file with mode: 0644]
src/PartSetAPI/PartSetAPI_Part.cpp [new file with mode: 0644]
src/PartSetAPI/PartSetAPI_Part.h [new file with mode: 0644]
src/PartSetAPI/PartSetAPI_swig.h [new file with mode: 0644]
src/PythonAPI/model/partset/__init__.py

index d00323c9532020222e620ab174a71af2eec3361b..bbfe7510c8d88a67ead1fc8950910e76ae71f8fc 100644 (file)
@@ -99,6 +99,7 @@ ADD_SUBDIRECTORY (src/ModelHighAPI)
 ADD_SUBDIRECTORY (src/ConstructionAPI)
 ADD_SUBDIRECTORY (src/ExchangeAPI)
 ADD_SUBDIRECTORY (src/FeaturesAPI)
+ADD_SUBDIRECTORY (src/PartSetAPI)
 ADD_SUBDIRECTORY (src/SketchAPI)
 
 IF(${HAVE_SALOME})
index a38bebe7b0da1564bf29656b5a8ec28fa549e2e8..4e15701addcdc8b2d10008694c0742246ad99742 100644 (file)
     return true; \
   }
 
+//--------------------------------------------------------------------------------------
+#define INTERFACE_0(KIND) \
+  public: \
+    INTERFACE_COMMON(KIND) \
+  protected: \
+    START_INIT() \
+    END_INIT() \
+  public:
 
 //--------------------------------------------------------------------------------------
 #define INTERFACE_1(KIND, \
index 2c300e15ccf65463bb12f384bdb5f4e66bdadd80..ff191e5cadf5f19797f4040c01ff265f81fcc354 100644 (file)
@@ -102,6 +102,13 @@ void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
     it->appendToList(theAttribute);
 }
 
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::shared_ptr<ModelAPI_Object> & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute)
+{
+  theAttribute->setValue(theValue);
+}
+
 //--------------------------------------------------------------------------------------
 void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute)
index f53e37a1b79f168d0f1d599b429fedcb7b604d53..dc3378df2ee02cae4cd1508956b1b6b7c9b1ea0b 100644 (file)
@@ -82,6 +82,10 @@ MODELHIGHAPI_EXPORT
 void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
                    const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute);
 
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::shared_ptr<ModelAPI_Object> & theValue,
+                   const std::shared_ptr<ModelAPI_AttributeReference> & theAttribute);
+
 MODELHIGHAPI_EXPORT
 void fillAttribute(const std::list<std::shared_ptr<ModelAPI_Object> > & theValue,
                    const std::shared_ptr<ModelAPI_AttributeRefList> & theAttribute);
diff --git a/src/PartSetAPI/CMakeLists.txt b/src/PartSetAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c9cb063
--- /dev/null
@@ -0,0 +1,69 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+  PartSetAPI.h
+  PartSetAPI_Part.h
+)
+
+SET(PROJECT_SOURCES
+  PartSetAPI_Part.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 PartSetPlugin headers to remove dependency on GeomAPI headers
+  ${PROJECT_SOURCE_DIR}/src/GeomAPI
+  # TODO(spo): it is for *_swig.h files. Can we eliminate it?
+  ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+)
+
+#TODO(spo): is ${CAS_DEFINITIONS} necessary?
+ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(PartSetAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(PartSetAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(PartSetAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(PartSetAPI.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
+  PartSetAPI
+  ModelHighAPI
+  ModelAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_PartSetAPI_EXTRA_DEPS ${SWIG_MODULE_PartSetAPI_EXTRA_DEPS}
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+  doxyhelp.i
+  ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(PartSetAPI python PartSetAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(PartSetAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_PartSetAPI PROPERTIES DEBUG_OUTPUT_NAME _PartSetAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _PartSetAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS PartSetAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/PartSetAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
diff --git a/src/PartSetAPI/PartSetAPI.h b/src/PartSetAPI/PartSetAPI.h
new file mode 100644 (file)
index 0000000..8473acb
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef PARTSETAPI_H
+#define PARTSETAPI_H
+
+#if defined PARTSETAPI_EXPORTS
+#if defined WIN32
+#define PARTSETAPI_EXPORT __declspec( dllexport )
+#else
+#define PARTSETAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define PARTSETAPI_EXPORT __declspec( dllimport )
+#else
+#define PARTSETAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/PartSetAPI/PartSetAPI.i b/src/PartSetAPI/PartSetAPI.i
new file mode 100644 (file)
index 0000000..748fdf0
--- /dev/null
@@ -0,0 +1,25 @@
+/* PartSetAPI.i */
+
+%module PartSetAPI
+
+%{
+  #include "PartSetAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define PARTSETAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(PartSetAPI_Part)
+
+// all supported interfaces
+%include "PartSetAPI_Part.h"
diff --git a/src/PartSetAPI/PartSetAPI_Part.cpp b/src/PartSetAPI/PartSetAPI_Part.cpp
new file mode 100644 (file)
index 0000000..e55cc92
--- /dev/null
@@ -0,0 +1,54 @@
+// Name   : PartSetAPI_Part.cpp
+// Purpose: 
+//
+// History:
+// 16/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "PartSetAPI_Part.h"
+//--------------------------------------------------------------------------------------
+#include <ModelAPI_ResultPart.h>
+//--------------------------------------------------------------------------------------
+#include <PartSetPlugin_Duplicate.h>
+#include <PartSetPlugin_Remove.h>
+//--------------------------------------------------------------------------------------
+PartSetAPI_Part::PartSetAPI_Part(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+PartSetAPI_Part::~PartSetAPI_Part()
+{
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_Document> PartSetAPI_Part::document() const
+{
+  return std::dynamic_pointer_cast<ModelAPI_ResultPart>(defaultResult())->partDoc();
+}
+
+//--------------------------------------------------------------------------------------
+PartPtr addPart(const std::shared_ptr<ModelAPI_Document> & thePart)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetAPI_Part::ID());
+  aFeature->execute();
+  return PartPtr(new PartSetAPI_Part(aFeature));
+}
+
+PartPtr duplicatePart(const std::shared_ptr<ModelAPI_Document> & thePart)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Duplicate::ID());
+  aFeature->execute();
+  return PartPtr(new PartSetAPI_Part(aFeature));
+}
+
+void removePart(const std::shared_ptr<ModelAPI_Document> & thePart)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Remove::ID());
+  aFeature->execute();
+}
diff --git a/src/PartSetAPI/PartSetAPI_Part.h b/src/PartSetAPI/PartSetAPI_Part.h
new file mode 100644 (file)
index 0000000..b65fce9
--- /dev/null
@@ -0,0 +1,64 @@
+// Name   : PartSetAPI_Part.h
+// Purpose: 
+//
+// History:
+// 16/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_PARTSETAPI_PARTSETAPI_PART_H_
+#define SRC_PARTSETAPI_PARTSETAPI_PART_H_
+
+//--------------------------------------------------------------------------------------
+#include "PartSetAPI.h"
+
+#include <PartSetPlugin_Part.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelAPI_Document;
+//--------------------------------------------------------------------------------------
+/**\class PartSetAPI_Part
+ * \ingroup CPPHighAPI
+ * \brief Interface for Part feature
+ */
+class PartSetAPI_Part : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  PARTSETAPI_EXPORT
+  explicit PartSetAPI_Part(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Destructor
+  PARTSETAPI_EXPORT
+  virtual ~PartSetAPI_Part();
+
+  INTERFACE_0(PartSetPlugin_Part::ID())
+
+  /// Return document
+  PARTSETAPI_EXPORT
+  std::shared_ptr<ModelAPI_Document> document() const;
+};
+
+//! Pointer on Part object
+typedef std::shared_ptr<PartSetAPI_Part> PartPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Part feature
+ */
+PARTSETAPI_EXPORT
+PartPtr addPart(const std::shared_ptr<ModelAPI_Document> & thePartSet);
+
+/**\ingroup CPPHighAPI
+ * \brief Duplicate Part feature
+ */
+PARTSETAPI_EXPORT
+PartPtr duplicatePart(const std::shared_ptr<ModelAPI_Document> & thePart);
+
+/**\ingroup CPPHighAPI
+ * \brief Remove Part feature
+ */
+PARTSETAPI_EXPORT
+void removePart(const std::shared_ptr<ModelAPI_Document> & thePart);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_PARTSETAPI_PARTSETAPI_PART_H_ */
diff --git a/src/PartSetAPI/PartSetAPI_swig.h b/src/PartSetAPI/PartSetAPI_swig.h
new file mode 100644 (file)
index 0000000..adec751
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    PartSetAPI_swig.h
+// Created: 16/06/16
+// Author:  Sergey POKHODENKO
+
+#ifndef SRC_PARTSETAPI_PARTSETAPI_SWIG_H_
+#define SRC_PARTSETAPI_PARTSETAPI_SWIG_H_
+
+  #include <ModelHighAPI_swig.h>
+
+  #include "PartSetAPI_Part.h"
+
+#endif /* SRC_PARTSETAPI_PARTSETAPI_SWIG_H_ */
index 33eed0d4b5a11ead1137e865cee4240a552ad739..f66380156d976b0f2dba6e165be9769f53b067ef 100644 (file)
@@ -1,4 +1,4 @@
 """Package for PartSet plugin for the Parametric Geometry API of the Modeler.
 """
 
-from part import addPart, duplicatePart, removePart
\ No newline at end of file
+from PartSetAPI import addPart, duplicatePart, removePart
\ No newline at end of file