From fded0dbe10f03890f992c3e45ffe92b4eee0964c Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 16 Jun 2016 16:51:57 +0300 Subject: [PATCH] Add ConnectorAPI --- CMakeLists.txt | 1 + src/ConnectorAPI/CMakeLists.txt | 69 +++++++++++++++++++++ src/ConnectorAPI/ConnectorAPI.h | 20 ++++++ src/ConnectorAPI/ConnectorAPI.i | 22 +++++++ src/ConnectorAPI/ConnectorAPI_Connector.cpp | 18 ++++++ src/ConnectorAPI/ConnectorAPI_Connector.h | 25 ++++++++ src/ConnectorAPI/ConnectorAPI_swig.h | 14 +++++ src/PythonAPI/model/connection/__init__.py | 2 +- 8 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/ConnectorAPI/CMakeLists.txt create mode 100644 src/ConnectorAPI/ConnectorAPI.h create mode 100644 src/ConnectorAPI/ConnectorAPI.i create mode 100644 src/ConnectorAPI/ConnectorAPI_Connector.cpp create mode 100644 src/ConnectorAPI/ConnectorAPI_Connector.h create mode 100644 src/ConnectorAPI/ConnectorAPI_swig.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 30b019882..7ecfbf08c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,7 @@ ADD_SUBDIRECTORY (src/PythonAddons) ADD_SUBDIRECTORY (src/PythonAPI) # High Level C++/Python API ADD_SUBDIRECTORY (src/ModelHighAPI) +ADD_SUBDIRECTORY (src/ConnectorAPI) ADD_SUBDIRECTORY (src/ConstructionAPI) ADD_SUBDIRECTORY (src/ExchangeAPI) ADD_SUBDIRECTORY (src/FeaturesAPI) diff --git a/src/ConnectorAPI/CMakeLists.txt b/src/ConnectorAPI/CMakeLists.txt new file mode 100644 index 000000000..4c68777cd --- /dev/null +++ b/src/ConnectorAPI/CMakeLists.txt @@ -0,0 +1,69 @@ +## Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +INCLUDE(Common) + +SET(PROJECT_HEADERS + ConnectorAPI.h + ConnectorAPI_Connector.h +) + +SET(PROJECT_SOURCES + ConnectorAPI_Connector.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 ConnectorPlugin 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/ConnectorPlugin +) + +#TODO(spo): is ${CAS_DEFINITIONS} necessary? +ADD_DEFINITIONS(-DCONSTRUCTIONAPI_EXPORTS ${CAS_DEFINITIONS}) +ADD_LIBRARY(ConnectorAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(ConnectorAPI ${PROJECT_LIBRARIES}) + +# SWIG wrapper + +INCLUDE(PythonAPI) + +SET_SOURCE_FILES_PROPERTIES(ConnectorAPI.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(ConnectorAPI.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 + ConnectorAPI + ModelHighAPI + ModelAPI + ${PYTHON_LIBRARIES} +) + +SET(SWIG_MODULE_ConnectorAPI_EXTRA_DEPS ${SWIG_MODULE_ConnectorAPI_EXTRA_DEPS} + ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i + doxyhelp.i + ${PROJECT_HEADERS} +) + +SWIG_ADD_MODULE(ConnectorAPI python ConnectorAPI.i ${PROJECT_HEADERS}) +SWIG_LINK_LIBRARIES(ConnectorAPI ${SWIG_LINK_LIBRARIES}) + +IF(WIN32) + SET_TARGET_PROPERTIES(_ConnectorAPI PROPERTIES DEBUG_OUTPUT_NAME _ConnectorAPI_d) +ENDIF(WIN32) + +INSTALL(TARGETS _ConnectorAPI DESTINATION ${SHAPER_INSTALL_SWIG}) +INSTALL(TARGETS ConnectorAPI DESTINATION ${SHAPER_INSTALL_BIN}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ConnectorAPI.py DESTINATION ${SHAPER_INSTALL_SWIG}) diff --git a/src/ConnectorAPI/ConnectorAPI.h b/src/ConnectorAPI/ConnectorAPI.h new file mode 100644 index 000000000..7b2391a54 --- /dev/null +++ b/src/ConnectorAPI/ConnectorAPI.h @@ -0,0 +1,20 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#ifndef CONNECTORAPI_H +#define CONNECTORAPI_H + +#if defined CONNECTORAPI_EXPORTS +#if defined WIN32 +#define CONNECTORAPI_EXPORT __declspec( dllexport ) +#else +#define CONNECTORAPI_EXPORT +#endif +#else +#if defined WIN32 +#define CONNECTORAPI_EXPORT __declspec( dllimport ) +#else +#define CONNECTORAPI_EXPORT +#endif +#endif + +#endif diff --git a/src/ConnectorAPI/ConnectorAPI.i b/src/ConnectorAPI/ConnectorAPI.i new file mode 100644 index 000000000..ba3165c72 --- /dev/null +++ b/src/ConnectorAPI/ConnectorAPI.i @@ -0,0 +1,22 @@ +/* ConnectorAPI.i */ + +%module ConnectorAPI + +%{ + #include "ConnectorAPI_swig.h" +%} + +%include "doxyhelp.i" + +// import other modules +%import "ModelHighAPI.i" + +// to avoid error on this +#define CONNECTORAPI_EXPORT + +// standard definitions +%include "typemaps.i" +%include "std_shared_ptr.i" + +// all supported interfaces +%include "ConnectorAPI_Connector.h" diff --git a/src/ConnectorAPI/ConnectorAPI_Connector.cpp b/src/ConnectorAPI/ConnectorAPI_Connector.cpp new file mode 100644 index 000000000..2a48f702c --- /dev/null +++ b/src/ConnectorAPI/ConnectorAPI_Connector.cpp @@ -0,0 +1,18 @@ +// Name : ConnectorAPI_Connector.cpp +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "ConnectorAPI_Connector.h" +//-------------------------------------------------------------------------------------- +#include +#include +//-------------------------------------------------------------------------------------- +void exportToGEOM(const std::shared_ptr & thePart) +{ + // TODO(spo): check that theConnector is not empty + std::shared_ptr aFeature = thePart->addFeature("ExportToGEOM"); + aFeature->execute(); +} diff --git a/src/ConnectorAPI/ConnectorAPI_Connector.h b/src/ConnectorAPI/ConnectorAPI_Connector.h new file mode 100644 index 000000000..5ddf0bfe7 --- /dev/null +++ b/src/ConnectorAPI/ConnectorAPI_Connector.h @@ -0,0 +1,25 @@ +// Name : ConnectorAPI_Connector.h +// Purpose: +// +// History: +// 16/06/16 - Sergey POKHODENKO - Creation of the file + +#ifndef SRC_CONNECTORAPI_CONNECTORAPI_PART_H_ +#define SRC_CONNECTORAPI_CONNECTORAPI_PART_H_ + +//-------------------------------------------------------------------------------------- +#include "ConnectorAPI.h" +//-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- +class ModelAPI_Document; +//-------------------------------------------------------------------------------------- +/**\ingroup CPPHighAPI + * \brief Export to GEOM + */ +CONNECTORAPI_EXPORT +void exportToGEOM(const std::shared_ptr & thePart); + +//-------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------- +#endif /* SRC_CONNECTORAPI_CONNECTORAPI_PART_H_ */ diff --git a/src/ConnectorAPI/ConnectorAPI_swig.h b/src/ConnectorAPI/ConnectorAPI_swig.h new file mode 100644 index 000000000..a94542d7b --- /dev/null +++ b/src/ConnectorAPI/ConnectorAPI_swig.h @@ -0,0 +1,14 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ConnectorAPI_swig.h +// Created: 16/06/16 +// Author: Sergey POKHODENKO + +#ifndef SRC_CONNECTORAPI_CONNECTORAPI_SWIG_H_ +#define SRC_CONNECTORAPI_CONNECTORAPI_SWIG_H_ + + #include + + #include "ConnectorAPI_Connector.h" + +#endif /* SRC_CONNECTORAPI_CONNECTORAPI_SWIG_H_ */ diff --git a/src/PythonAPI/model/connection/__init__.py b/src/PythonAPI/model/connection/__init__.py index 514b7f9ee..1b5a6587e 100644 --- a/src/PythonAPI/model/connection/__init__.py +++ b/src/PythonAPI/model/connection/__init__.py @@ -1,4 +1,4 @@ """Package for Connection plugin for the Parametric Geometry API of the Modeler. """ -from connection import exportToGEOM \ No newline at end of file +from ConnectorAPI import exportToGEOM \ No newline at end of file -- 2.39.2