From: dbv Date: Thu, 16 Jun 2016 15:22:11 +0000 (+0300) Subject: Added CPP High API for BuildPlugin_Wire X-Git-Tag: V_2.4.0~91^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=43b33b994262aeccecadf1373cc3a1c23c0c9732;p=modules%2Fshaper.git Added CPP High API for BuildPlugin_Wire --- diff --git a/src/BuildAPI/BuildAPI.i b/src/BuildAPI/BuildAPI.i index 7745dc9e0..56bd04bd2 100644 --- a/src/BuildAPI/BuildAPI.i +++ b/src/BuildAPI/BuildAPI.i @@ -21,7 +21,9 @@ // shared pointers %shared_ptr(BuildAPI_Edge) %shared_ptr(BuildAPI_Vertex) +%shared_ptr(BuildAPI_Wire) // all supported interfaces %include "BuildAPI_Edge.h" %include "BuildAPI_Vertex.h" +%include "BuildAPI_Wire.h" diff --git a/src/BuildAPI/BuildAPI_Wire.cpp b/src/BuildAPI/BuildAPI_Wire.cpp new file mode 100644 index 000000000..66631c74f --- /dev/null +++ b/src/BuildAPI/BuildAPI_Wire.cpp @@ -0,0 +1,55 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: BuildAPI_Wire.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "BuildAPI_Wire.h" + +#include + +//================================================================================================== +BuildAPI_Wire::BuildAPI_Wire(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +BuildAPI_Wire::BuildAPI_Wire(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +BuildAPI_Wire::~BuildAPI_Wire() +{ + +} + +//================================================================================================== +void BuildAPI_Wire::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +//================================================================================================== +void BuildAPI_Wire::addContour() +{ + feature()->customAction(BuildPlugin_Wire::ADD_CONTOUR_ACTION_ID()); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +WirePtr addWire(const std::shared_ptr& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(BuildAPI_Wire::ID()); + return WirePtr(new BuildAPI_Wire(aFeature, theBaseObjects)); +} diff --git a/src/BuildAPI/BuildAPI_Wire.h b/src/BuildAPI/BuildAPI_Wire.h new file mode 100644 index 000000000..d1d24fa71 --- /dev/null +++ b/src/BuildAPI/BuildAPI_Wire.h @@ -0,0 +1,59 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: BuildAPI_Wire.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef BuildAPI_Wire_H_ +#define BuildAPI_Wire_H_ + +#include "BuildAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class BuildAPI_Wire +/// \ingroup CPPHighAPI +/// \brief Interface for Wire feature. +class BuildAPI_Wire: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + BUILDAPI_EXPORT + explicit BuildAPI_Wire(const std::shared_ptr& theFeature); + + /// Constructor with values. + BUILDAPI_EXPORT + explicit BuildAPI_Wire(const std::shared_ptr& theFeature, + const std::list& theBaseObjects); + + /// Destructor. + BUILDAPI_EXPORT + virtual ~BuildAPI_Wire(); + + INTERFACE_1(BuildPlugin_Wire::ID(), + baseObjects, BuildPlugin_Wire::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */) + + /// Modify base attribute of the feature. + BUILDAPI_EXPORT + void setBase(const std::list& theBaseObjects); + + /// Adds closed contour. + BUILDAPI_EXPORT + void addContour(); +}; + +/// Pointer on Wire object. +typedef std::shared_ptr WirePtr; + +/// \ingroup CPPHighAPI +/// \brief Create Wire feature. +BUILDAPI_EXPORT +WirePtr addWire(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // BuildAPI_Wire_H_ diff --git a/src/BuildAPI/BuildAPI_swig.h b/src/BuildAPI/BuildAPI_swig.h index dd947e863..f6d982af2 100644 --- a/src/BuildAPI/BuildAPI_swig.h +++ b/src/BuildAPI/BuildAPI_swig.h @@ -11,5 +11,6 @@ #include "BuildAPI_Edge.h" #include "BuildAPI_Vertex.h" + #include "BuildAPI_Wire.h" #endif // FeaturesAPI_swig_H_ diff --git a/src/BuildAPI/CMakeLists.txt b/src/BuildAPI/CMakeLists.txt index 51d197dde..3cf929265 100644 --- a/src/BuildAPI/CMakeLists.txt +++ b/src/BuildAPI/CMakeLists.txt @@ -6,11 +6,13 @@ SET(PROJECT_HEADERS BuildAPI.h BuildAPI_Edge.h BuildAPI_Vertex.h + BuildAPI_Wire.h ) SET(PROJECT_SOURCES BuildAPI_Edge.cpp BuildAPI_Vertex.cpp + BuildAPI_Wire.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp index 6acb80b23..4b7231a72 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.cpp +++ b/src/BuildPlugin/BuildPlugin_Wire.cpp @@ -85,7 +85,7 @@ void BuildPlugin_Wire::execute() //================================================================================================= bool BuildPlugin_Wire::customAction(const std::string& theActionId) { - if(theActionId == "add_contour") { + if(theActionId == ADD_CONTOUR_ACTION_ID()) { return addContour(); } else { std::string aMsg = "Error: Feature \"%1\" does not support action \"%2\"."; diff --git a/src/BuildPlugin/BuildPlugin_Wire.h b/src/BuildPlugin/BuildPlugin_Wire.h index 39128be6b..acf500669 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.h +++ b/src/BuildPlugin/BuildPlugin_Wire.h @@ -34,6 +34,13 @@ public: return MY_BASE_OBJECTS_ID; } + /// Attribute name of base objects. + inline static const std::string& ADD_CONTOUR_ACTION_ID() + { + static const std::string MY_ADD_CONTOUR_ACTION_ID("add_contour"); + return MY_ADD_CONTOUR_ACTION_ID; + } + /// \return the kind of a feature. BUILDPLUGIN_EXPORT virtual const std::string& getKind() {