From: dbv Date: Thu, 16 Jun 2016 15:03:28 +0000 (+0300) Subject: Added CPP High API for BuildPlugin_Vertex X-Git-Tag: V_2.4.0~91^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e1d9d3de5d8d94cc9f2ec5d6aa48e5f84ea00b34;p=modules%2Fshaper.git Added CPP High API for BuildPlugin_Vertex --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ecfbf08c..1047795a7 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/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 index 000000000..36cfee18d --- /dev/null +++ b/src/BuildAPI/BuildAPI.h @@ -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 index 000000000..c1bb7e44c --- /dev/null +++ b/src/BuildAPI/BuildAPI.i @@ -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 index 000000000..a3b71ae5f --- /dev/null +++ b/src/BuildAPI/BuildAPI_Vertex.cpp @@ -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 + +//================================================================================================== +BuildAPI_Vertex::BuildAPI_Vertex(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_Vertex::BuildAPI_Vertex(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +BuildAPI_Vertex::~BuildAPI_Vertex() +{ + +} + +//================================================================================================== +void BuildAPI_Vertex::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +VertexPtr addVertex(const std::shared_ptr& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr 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 index 000000000..a01ea4c14 --- /dev/null +++ b/src/BuildAPI/BuildAPI_Vertex.h @@ -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 + +#include +#include + +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& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_Vertex(const std::shared_ptr& theFeature, + const std::list& 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& theBaseObjects); +}; + +/// Pointer on Vertex object. +typedef std::shared_ptr VertexPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Vertex feature. +BUILDAPI_EXPORT +VertexPtr addVertex(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // BuildAPI_Vertex_H_ diff --git a/src/BuildAPI/BuildAPI_swig.h b/src/BuildAPI/BuildAPI_swig.h new file mode 100644 index 000000000..68c4f4e90 --- /dev/null +++ b/src/BuildAPI/BuildAPI_swig.h @@ -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 + + #include "BuildAPI_Vertex.h" + +#endif // FeaturesAPI_swig_H_ diff --git a/src/BuildAPI/CMakeLists.txt b/src/BuildAPI/CMakeLists.txt new file mode 100644 index 000000000..f84136f59 --- /dev/null +++ b/src/BuildAPI/CMakeLists.txt @@ -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)