From: vsv Date: Mon, 7 Jul 2014 14:30:13 +0000 (+0400) Subject: Features plug-in created with Extrusion operation. X-Git-Tag: V_0.4.4~204^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c109c614957e7b090a0556b37d2cde412f7d75a;p=modules%2Fshaper.git Features plug-in created with Extrusion operation. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f70d821c..7a276cea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ ADD_SUBDIRECTORY (src/GeomData) ADD_SUBDIRECTORY (src/GeomDataAPI) ADD_SUBDIRECTORY (src/PartSetPlugin) ADD_SUBDIRECTORY (src/ConstructionPlugin) +ADD_SUBDIRECTORY (src/FeaturesPlugin) ADD_SUBDIRECTORY (src/SketchPlugin) ADD_SUBDIRECTORY (src/SketchSolver) ADD_SUBDIRECTORY (src/ModuleBase) diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml index e54794df6..a4d1dbdae 100644 --- a/src/Config/plugins.xml +++ b/src/Config/plugins.xml @@ -2,6 +2,7 @@ + diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index dc32be987..1c81b62aa 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -4,13 +4,11 @@ SET(PROJECT_HEADERS ConstructionPlugin.h ConstructionPlugin_Plugin.h ConstructionPlugin_Point.h - ConstructionPlugin_Extrusion.h ) SET(PROJECT_SOURCES ConstructionPlugin_Plugin.cpp ConstructionPlugin_Point.cpp - ConstructionPlugin_Extrusion.cpp ) ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) @@ -26,7 +24,6 @@ INCLUDE_DIRECTORIES( SET(XML_RESOURCES plugin-Construction.xml point_widget.xml - extrusion_widget.xml ) INSTALL(TARGETS ConstructionPlugin DESTINATION plugins) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp deleted file mode 100644 index 0af9cad3b..000000000 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// File: ConstructionPlugin_Extrusion.cpp -// Created: 30 May 2014 -// Author: Vitaly SMETANNIKOV - -#include "ConstructionPlugin_Extrusion.h" -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; - -ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion() -{ -} - -void ConstructionPlugin_Extrusion::initAttributes() -{ - data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type()); - data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type()); - data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type()); -} - -void ConstructionPlugin_Extrusion::execute() -{ - boost::shared_ptr aFaceRef = - boost::dynamic_pointer_cast(data()->attribute(EXTRUSION_FACE)); - if (!aFaceRef) - return; - FeaturePtr aFaceFeature = aFaceRef->value(); - if (!aFaceFeature) - return; - boost::shared_ptr aFace = aFaceFeature->data()->shape(); - if (!aFace) - return; - - double aSize = data()->real(EXTRUSION_SIZE)->value(); - if (data()->boolean(EXTRUSION_REVERSE)->value()) - aSize = -aSize; - data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize)); -} diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h deleted file mode 100644 index 5933929b8..000000000 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h +++ /dev/null @@ -1,45 +0,0 @@ -// File: ConstructionPlugin_Extrusion.h -// Created: 30 May 2014 -// Author: Vitaly SMETANNIKOV - -#ifndef ConstructionPlugin_Extrusion_HeaderFile -#define ConstructionPlugin_Extrusion_HeaderFile - -#include "ConstructionPlugin.h" -#include - -/// Extrusion kind -const std::string CONSTRUCTION_EXTRUSION_KIND("Extrusion"); - -/// attribute name of referenced face -const std::string EXTRUSION_FACE = "extrusion_face"; - -/// attribute name of extrusion size -const std::string EXTRUSION_SIZE = "extrusion_size"; - -/// attribute name of reverce direction -const std::string EXTRUSION_REVERSE = "extrusion_reverse"; - - -class ConstructionPlugin_Extrusion: public ModelAPI_Feature -{ -public: - /// Returns the kind of a feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() - { static std::string MY_KIND = CONSTRUCTION_EXTRUSION_KIND; return MY_KIND; } - - /// Returns to which group in the document must be added feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() - { static std::string MY_GROUP = "Construction"; return MY_GROUP; } - - /// Creates a new part document if needed - CONSTRUCTIONPLUGIN_EXPORT virtual void execute(); - - /// Request for initialization of data model of the feature: adding all attributes - CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes(); - - /// Use plugin manager for features creation - ConstructionPlugin_Extrusion(); -}; - -#endif diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index d420b2110..6b0d729a4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -1,6 +1,5 @@ #include "ConstructionPlugin_Plugin.h" #include "ConstructionPlugin_Point.h" -#include "ConstructionPlugin_Extrusion.h" #include #include @@ -20,8 +19,6 @@ FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID) { if (theFeatureID == CONSTRUCTION_POINT_KIND) { return FeaturePtr(new ConstructionPlugin_Point); - } else if (theFeatureID == CONSTRUCTION_EXTRUSION_KIND) { - return FeaturePtr(new ConstructionPlugin_Extrusion); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/ConstructionPlugin/extrusion_widget.xml b/src/ConstructionPlugin/extrusion_widget.xml deleted file mode 100644 index c0069ca67..000000000 --- a/src/ConstructionPlugin/extrusion_widget.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/src/ConstructionPlugin/plugin-Construction.xml b/src/ConstructionPlugin/plugin-Construction.xml index 4736d36cf..b3fdc4608 100644 --- a/src/ConstructionPlugin/plugin-Construction.xml +++ b/src/ConstructionPlugin/plugin-Construction.xml @@ -6,9 +6,6 @@ - - - diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt new file mode 100644 index 000000000..29e08785f --- /dev/null +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -0,0 +1,30 @@ +INCLUDE(Common) + +SET(PROJECT_HEADERS + FeaturesPlugin.h + FeaturesPlugin_Plugin.h + FeaturesPlugin_Extrusion.h +) + +SET(PROJECT_SOURCES + FeaturesPlugin_Plugin.cpp + FeaturesPlugin_Extrusion.cpp +) + +ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS}) +ADD_LIBRARY(FeaturesPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI) + +INCLUDE_DIRECTORIES( + ../ModelAPI + ../GeomAPI + ../GeomAlgoAPI +) + +SET(XML_RESOURCES + plugin-Features.xml + extrusion_widget.xml +) + +INSTALL(TARGETS FeaturesPlugin DESTINATION plugins) +INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins) diff --git a/src/FeaturesPlugin/FeaturesPlugin.h b/src/FeaturesPlugin/FeaturesPlugin.h new file mode 100644 index 000000000..2e931e293 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin.h @@ -0,0 +1,18 @@ +#ifndef FEATURESPLUGIN_H +#define FEATURESPLUGIN_H + +#if defined FEATURESPLUGIN_EXPORTS +#if defined WIN32 +#define FEATURESPLUGIN_EXPORT __declspec( dllexport ) +#else +#define FEATURESPLUGIN_EXPORT +#endif +#else +#if defined WIN32 +#define FEATURESPLUGIN_EXPORT __declspec( dllimport ) +#else +#define FEATURESPLUGIN_EXPORT +#endif +#endif + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp new file mode 100644 index 000000000..328dde5f0 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -0,0 +1,45 @@ +// File: FeaturesPlugin_Extrusion.cpp +// Created: 30 May 2014 +// Author: Vitaly SMETANNIKOV + +#include "FeaturesPlugin_Extrusion.h" +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() +{ +} + +void FeaturesPlugin_Extrusion::initAttributes() +{ + data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type()); + data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type()); + data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type()); +} + +void FeaturesPlugin_Extrusion::execute() +{ + boost::shared_ptr aFaceRef = + boost::dynamic_pointer_cast(data()->attribute(EXTRUSION_FACE)); + if (!aFaceRef) + return; + FeaturePtr aFaceFeature = aFaceRef->value(); + if (!aFaceFeature) + return; + boost::shared_ptr aFace = aFaceFeature->data()->shape(); + if (!aFace) + return; + + double aSize = data()->real(EXTRUSION_SIZE)->value(); + if (data()->boolean(EXTRUSION_REVERSE)->value()) + aSize = -aSize; + data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize)); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h new file mode 100644 index 000000000..95c8f98ae --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -0,0 +1,45 @@ +// File: FeaturesPlugin_Extrusion.h +// Created: 30 May 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef FeaturesPlugin_Extrusion_HeaderFile +#define FeaturesPlugin_Extrusion_HeaderFile + +#include "FeaturesPlugin.h" +#include + +/// Extrusion kind +const std::string FEATURES_EXTRUSION_KIND("Extrusion"); + +/// attribute name of referenced face +const std::string EXTRUSION_FACE = "extrusion_face"; + +/// attribute name of extrusion size +const std::string EXTRUSION_SIZE = "extrusion_size"; + +/// attribute name of reverse direction +const std::string EXTRUSION_REVERSE = "extrusion_reverse"; + + +class FeaturesPlugin_Extrusion: public ModelAPI_Feature +{ +public: + /// Returns the kind of a feature + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { static std::string MY_KIND = FEATURES_EXTRUSION_KIND; return MY_KIND; } + + /// Returns to which group in the document must be added feature + FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() + { static std::string MY_GROUP = "Construction"; return MY_GROUP; } + + /// Creates a new part document if needed + FEATURESPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + FEATURESPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + FeaturesPlugin_Extrusion(); +}; + +#endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp new file mode 100644 index 000000000..1c9273d5f --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -0,0 +1,25 @@ +#include "FeaturesPlugin_Plugin.h" +#include "FeaturesPlugin_Extrusion.h" + +#include +#include + +using namespace std; + +// the only created instance of this plugin +static FeaturesPlugin_Plugin* MY_INSTANCE = new FeaturesPlugin_Plugin(); + +FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() +{ + // register this plugin + ModelAPI_PluginManager::get()->registerPlugin(this); +} + +FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID) +{ + if (theFeatureID == FEATURES_EXTRUSION_KIND) { + return FeaturePtr(new FeaturesPlugin_Extrusion); + } + // feature of such kind is not found + return FeaturePtr(); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.h b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h new file mode 100644 index 000000000..3ec8c1239 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h @@ -0,0 +1,24 @@ +// File: FeaturesPlugin_Plugin.hxx +// Created: 07 July 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef FeaturesPlugin_Plugin_HeaderFile +#define FeaturesPlugin_Plugin_HeaderFile + + +#include "FeaturesPlugin.h" +#include +#include + +class FEATURESPLUGIN_EXPORT FeaturesPlugin_Plugin: public ModelAPI_Plugin +{ +public: + /// Creates the feature object of this plugin by the feature string ID + virtual FeaturePtr createFeature(std::string theFeatureID); + +public: + /// Is needed for python wrapping by swig + FeaturesPlugin_Plugin(); +}; + +#endif diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml new file mode 100644 index 000000000..c0069ca67 --- /dev/null +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml new file mode 100644 index 000000000..783d373fa --- /dev/null +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -0,0 +1,9 @@ + + + + + + + + +