From 0eb9388d9b4fc0f4c398a63a82c5e6264ed6b48e Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 17 Jun 2016 10:28:32 +0300 Subject: [PATCH] Added CPP High API for BuildPlugin_SubShapes --- src/BuildAPI/BuildAPI.i | 2 + src/BuildAPI/BuildAPI_SubShapes.cpp | 60 ++++++++++++++++++++++++++++ src/BuildAPI/BuildAPI_SubShapes.h | 62 +++++++++++++++++++++++++++++ src/BuildAPI/BuildAPI_swig.h | 1 + src/BuildAPI/CMakeLists.txt | 2 + 5 files changed, 127 insertions(+) create mode 100644 src/BuildAPI/BuildAPI_SubShapes.cpp create mode 100644 src/BuildAPI/BuildAPI_SubShapes.h diff --git a/src/BuildAPI/BuildAPI.i b/src/BuildAPI/BuildAPI.i index ff24e0571..af873f979 100644 --- a/src/BuildAPI/BuildAPI.i +++ b/src/BuildAPI/BuildAPI.i @@ -22,6 +22,7 @@ %shared_ptr(BuildAPI_Edge) %shared_ptr(BuildAPI_Face) %shared_ptr(BuildAPI_Shell) +%shared_ptr(BuildAPI_SubShapes) %shared_ptr(BuildAPI_Vertex) %shared_ptr(BuildAPI_Wire) @@ -29,5 +30,6 @@ %include "BuildAPI_Edge.h" %include "BuildAPI_Face.h" %include "BuildAPI_Shell.h" +%include "BuildAPI_SubShapes.h" %include "BuildAPI_Vertex.h" %include "BuildAPI_Wire.h" diff --git a/src/BuildAPI/BuildAPI_SubShapes.cpp b/src/BuildAPI/BuildAPI_SubShapes.cpp new file mode 100644 index 000000000..b6e2a729b --- /dev/null +++ b/src/BuildAPI/BuildAPI_SubShapes.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: BuildAPI_SubShapes.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "BuildAPI_SubShapes.h" + +#include + +//================================================================================================== +BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theBaseShape, + const std::list& theSubShapes) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseShape, mybaseShape); + setSubShapes(theSubShapes); + } +} + +//================================================================================================== +BuildAPI_SubShapes::~BuildAPI_SubShapes() +{ + +} + +//================================================================================================== +void BuildAPI_SubShapes::setBaseShape(const ModelHighAPI_Selection& theBaseShape) +{ + fillAttribute(theBaseShape, mybaseShape); + + execute(); +} + +//================================================================================================== +void BuildAPI_SubShapes::setSubShapes(const std::list& theSubShapes) +{ + fillAttribute(theSubShapes, mysubShapes); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +SubShapesPtr addSubShapes(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theBaseShape, + const std::list& theSubShapes) +{ + std::shared_ptr aFeature = thePart->addFeature(BuildAPI_SubShapes::ID()); + return SubShapesPtr(new BuildAPI_SubShapes(aFeature, theBaseShape, theSubShapes)); +} diff --git a/src/BuildAPI/BuildAPI_SubShapes.h b/src/BuildAPI/BuildAPI_SubShapes.h new file mode 100644 index 000000000..b8108f5bf --- /dev/null +++ b/src/BuildAPI/BuildAPI_SubShapes.h @@ -0,0 +1,62 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: BuildAPI_SubShapes.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef BuildAPI_SubShapes_H_ +#define BuildAPI_SubShapes_H_ + +#include "BuildAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class BuildAPI_SubShapes +/// \ingroup CPPHighAPI +/// \brief Interface for SubShapes feature. +class BuildAPI_SubShapes: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + BUILDAPI_EXPORT + explicit BuildAPI_SubShapes(const std::shared_ptr& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_SubShapes(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theBaseShape, + const std::list& theSubShapes); + + /// Destructor. + BUILDAPI_EXPORT + virtual ~BuildAPI_SubShapes(); + + INTERFACE_2(BuildPlugin_SubShapes::ID(), + baseShape, BuildPlugin_SubShapes::BASE_SHAPE_ID(), ModelAPI_AttributeSelection, /** Base shape */, + subShapes, BuildPlugin_SubShapes::SUBSHAPES_ID(), ModelAPI_AttributeSelectionList, /** Sub-shapes */) + + /// Modify base attribute of the feature. + BUILDAPI_EXPORT + void setBaseShape(const ModelHighAPI_Selection& theBaseShape); + + /// Modify sub-shapes attribute of the feature. + BUILDAPI_EXPORT + void setSubShapes(const std::list& theSubShapes); +}; + +/// Pointer on SubShapes object. +typedef std::shared_ptr SubShapesPtr; + +/// \ingroup CPPHighAPI +/// \brief Create SubShapes feature. +BUILDAPI_EXPORT +SubShapesPtr addSubShapes(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theBaseShape, + const std::list& theSubShapes); + +#endif // BuildAPI_SubShapes_H_ diff --git a/src/BuildAPI/BuildAPI_swig.h b/src/BuildAPI/BuildAPI_swig.h index 634ade0b9..332db7b2a 100644 --- a/src/BuildAPI/BuildAPI_swig.h +++ b/src/BuildAPI/BuildAPI_swig.h @@ -12,6 +12,7 @@ #include "BuildAPI_Edge.h" #include "BuildAPI_Face.h" #include "BuildAPI_Shell.h" + #include "BuildAPI_SubShapes.h" #include "BuildAPI_Vertex.h" #include "BuildAPI_Wire.h" diff --git a/src/BuildAPI/CMakeLists.txt b/src/BuildAPI/CMakeLists.txt index 695b8e03a..0d3073bd6 100644 --- a/src/BuildAPI/CMakeLists.txt +++ b/src/BuildAPI/CMakeLists.txt @@ -7,6 +7,7 @@ SET(PROJECT_HEADERS BuildAPI_Edge.h BuildAPI_Face.h BuildAPI_Shell.h + BuildAPI_SubShapes.h BuildAPI_Vertex.h BuildAPI_Wire.h ) @@ -15,6 +16,7 @@ SET(PROJECT_SOURCES BuildAPI_Edge.cpp BuildAPI_Face.cpp BuildAPI_Shell.cpp + BuildAPI_SubShapes.cpp BuildAPI_Vertex.cpp BuildAPI_Wire.cpp ) -- 2.39.2