Salome HOME
Added CPP High API for BuildPlugin_Vertex
authordbv <dbv@opencascade.com>
Thu, 16 Jun 2016 15:03:28 +0000 (18:03 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:13 +0000 (14:41 +0300)
CMakeLists.txt
src/BuildAPI/BuildAPI.h [new file with mode: 0644]
src/BuildAPI/BuildAPI.i [new file with mode: 0644]
src/BuildAPI/BuildAPI_Vertex.cpp [new file with mode: 0644]
src/BuildAPI/BuildAPI_Vertex.h [new file with mode: 0644]
src/BuildAPI/BuildAPI_swig.h [new file with mode: 0644]
src/BuildAPI/CMakeLists.txt [new file with mode: 0644]

index 7ecfbf08c64ba955d26578c4d7f94fe0a6abd38e..1047795a7de43a940768220ac3380184e29e22f4 100644 (file)
@@ -96,6 +96,7 @@ ADD_SUBDIRECTORY (src/PythonAddons)
 ADD_SUBDIRECTORY (src/PythonAPI)
 # High Level C++/Python API
 ADD_SUBDIRECTORY (src/ModelHighAPI)
+ADD_SUBDIRECTORY (src/BuildAPI)
 ADD_SUBDIRECTORY (src/ConnectorAPI)
 ADD_SUBDIRECTORY (src/ConstructionAPI)
 ADD_SUBDIRECTORY (src/ExchangeAPI)
diff --git a/src/BuildAPI/BuildAPI.h b/src/BuildAPI/BuildAPI.h
new file mode 100644 (file)
index 0000000..36cfee1
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef BUILDAPI_H
+#define BUILDAPI_H
+
+#if defined BUILDAPI_EXPORTS
+#if defined WIN32
+#define BUILDAPI_EXPORT __declspec( dllexport )
+#else
+#define BUILDAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define BUILDAPI_EXPORT __declspec( dllimport )
+#else
+#define BUILDAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/BuildAPI/BuildAPI.i b/src/BuildAPI/BuildAPI.i
new file mode 100644 (file)
index 0000000..c1bb7e4
--- /dev/null
@@ -0,0 +1,25 @@
+/* FeaturesAPI.i */
+
+%module BuildAPI
+
+%{
+  #include "BuildAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define BUILDAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(BuildAPI_Vertex)
+
+// all supported interfaces
+%include "BuildAPI_Vertex.h"
diff --git a/src/BuildAPI/BuildAPI_Vertex.cpp b/src/BuildAPI/BuildAPI_Vertex.cpp
new file mode 100644 (file)
index 0000000..a3b71ae
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildAPI_Vertex.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "BuildAPI_Vertex.h"
+
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+BuildAPI_Vertex::BuildAPI_Vertex(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+BuildAPI_Vertex::BuildAPI_Vertex(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                 const std::list<ModelHighAPI_Selection>& theBaseObjects)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setBase(theBaseObjects);
+  }
+}
+
+//==================================================================================================
+BuildAPI_Vertex::~BuildAPI_Vertex()
+{
+
+}
+
+//==================================================================================================
+void BuildAPI_Vertex::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  fillAttribute(theBaseObjects, mybaseObjects);
+
+  execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+VertexPtr addVertex(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Vertex::ID());
+  return VertexPtr(new BuildAPI_Vertex(aFeature, theBaseObjects));
+}
diff --git a/src/BuildAPI/BuildAPI_Vertex.h b/src/BuildAPI/BuildAPI_Vertex.h
new file mode 100644 (file)
index 0000000..a01ea4c
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        BuildAPI_Vertex.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef BuildAPI_Vertex_H_
+#define BuildAPI_Vertex_H_
+
+#include "BuildAPI.h"
+
+#include <BuildPlugin_Vertex.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Selection;
+
+/// \class BuildAPI_Vertex
+/// \ingroup CPPHighAPI
+/// \brief Interface for Vertex feature.
+class BuildAPI_Vertex: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  BUILDAPI_EXPORT
+  explicit BuildAPI_Vertex(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  BUILDAPI_EXPORT
+  explicit BuildAPI_Vertex(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                           const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Destructor.
+  BUILDAPI_EXPORT
+  virtual ~BuildAPI_Vertex();
+
+  INTERFACE_1(BuildPlugin_Vertex::ID(),
+              baseObjects, BuildPlugin_Vertex::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */)
+
+  /// Modify base attribute of the feature.
+  BUILDAPI_EXPORT
+  void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+};
+
+/// Pointer on Vertex object.
+typedef std::shared_ptr<BuildAPI_Vertex> VertexPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Vertex feature.
+BUILDAPI_EXPORT
+VertexPtr addVertex(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+#endif // BuildAPI_Vertex_H_
diff --git a/src/BuildAPI/BuildAPI_swig.h b/src/BuildAPI/BuildAPI_swig.h
new file mode 100644 (file)
index 0000000..68c4f4e
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    FeaturesAPI_swig.h
+// Created: 07 June 2016
+// Author:  Dmitry Bobylev
+
+#ifndef FeaturesAPI_swig_H_
+#define FeaturesAPI_swig_H_
+
+  #include <ModelHighAPI_swig.h>
+
+  #include "BuildAPI_Vertex.h"
+
+#endif // FeaturesAPI_swig_H_
diff --git a/src/BuildAPI/CMakeLists.txt b/src/BuildAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f84136f
--- /dev/null
@@ -0,0 +1,76 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+  BuildAPI.h
+  BuildAPI_Vertex.h
+)
+
+SET(PROJECT_SOURCES
+  BuildAPI_Vertex.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/BuildPlugin
+)
+
+#TODO(spo): is ${CAS_DEFINITIONS} necessary?
+ADD_DEFINITIONS(-DBUILDAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(BuildAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(BuildAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(BuildAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(BuildAPI.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
+  BuildAPI
+  ModelHighAPI
+  ModelAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_BuildAPI_EXTRA_DEPS ${SWIG_MODULE_BuildAPI_EXTRA_DEPS}
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+  doxyhelp.i
+  ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(BuildAPI python BuildAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(BuildAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_BuildAPI PROPERTIES DEBUG_OUTPUT_NAME _BuildAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _BuildAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS BuildAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/BuildAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
+
+# Tests
+INCLUDE(UnitTest)
+
+ADD_UNIT_TESTS(
+)
+
+# ADD_SUBDIRECTORY (Test)