From: dbv Date: Wed, 8 Jun 2016 15:01:42 +0000 (+0300) Subject: CPP API for FeaturesPlugin_Group X-Git-Tag: V_2.4.0~91^2~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41a0b4ccfdd7ab5ede8dbdb2b2445ab6cfbc2662;p=modules%2Fshaper.git CPP API for FeaturesPlugin_Group --- diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index 4daaa9f5f..1bf3b9f6c 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -5,6 +5,7 @@ INCLUDE(Common) SET(PROJECT_HEADERS FeaturesAPI.h FeaturesAPI_Boolean.h + FeaturesAPI_Group.h FeaturesAPI_Placement.h FeaturesAPI_Rotation.h FeaturesAPI_Translation.h @@ -12,6 +13,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES FeaturesAPI_Boolean.cpp + FeaturesAPI_Group.cpp FeaturesAPI_Placement.cpp FeaturesAPI_Rotation.cpp FeaturesAPI_Translation.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index 226d74492..52c73c730 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -20,12 +20,14 @@ // shared pointers %shared_ptr(FeaturesAPI_Boolean) +%shared_ptr(FeaturesAPI_Group) %shared_ptr(FeaturesAPI_Placement) %shared_ptr(FeaturesAPI_Rotation) %shared_ptr(FeaturesAPI_Translation) // all supported interfaces %include "FeaturesAPI_Boolean.h" +%include "FeaturesAPI_Group.h" %include "FeaturesAPI_Placement.h" %include "FeaturesAPI_Rotation.h" %include "FeaturesAPI_Translation.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp index 83e65fe47..6f68890cf 100644 --- a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp @@ -11,14 +11,14 @@ #include //================================================================================================== -FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr & theFeature) +FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } //================================================================================================== -FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr & theFeature, +FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr& theFeature, const ModelHighAPI_Integer& theBoolType, const std::list& theMainObjects, const std::list& theToolObjects) @@ -63,7 +63,7 @@ void FeaturesAPI_Boolean::setToolObjects(const std::list // TODO(spo): make add* as static functions of the class //================================================================================================== -BooleanPtr addCut(const std::shared_ptr & thePart, +BooleanPtr addCut(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects) { @@ -75,7 +75,7 @@ BooleanPtr addCut(const std::shared_ptr & thePart, } //================================================================================================== -BooleanPtr addFuse(const std::shared_ptr & thePart, +BooleanPtr addFuse(const std::shared_ptr& thePart, const std::list& theObjects) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID()); @@ -87,7 +87,7 @@ BooleanPtr addFuse(const std::shared_ptr & thePart, } //================================================================================================== -BooleanPtr addFuse(const std::shared_ptr & thePart, +BooleanPtr addFuse(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects) { @@ -99,7 +99,7 @@ BooleanPtr addFuse(const std::shared_ptr & thePart, } //================================================================================================== -BooleanPtr addCommon(const std::shared_ptr & thePart, +BooleanPtr addCommon(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects) { diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.h b/src/FeaturesAPI/FeaturesAPI_Boolean.h index bcbd40f25..6e8833a35 100644 --- a/src/FeaturesAPI/FeaturesAPI_Boolean.h +++ b/src/FeaturesAPI/FeaturesAPI_Boolean.h @@ -20,16 +20,16 @@ class ModelHighAPI_Selection; /// \class FeaturesAPI_Boolean /// \ingroup CPPHighAPI /// \brief Interface for Boolean feature. -class FeaturesAPI_Boolean : public ModelHighAPI_Interface +class FeaturesAPI_Boolean: public ModelHighAPI_Interface { public: /// Constructor without values. FEATURESAPI_EXPORT - explicit FeaturesAPI_Boolean(const std::shared_ptr & theFeature); + explicit FeaturesAPI_Boolean(const std::shared_ptr& theFeature); /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Boolean(const std::shared_ptr & theFeature, + FeaturesAPI_Boolean(const std::shared_ptr& theFeature, const ModelHighAPI_Integer& theBoolType, const std::list& theMainObjects, const std::list& theToolObjects); @@ -62,27 +62,27 @@ typedef std::shared_ptr BooleanPtr; /// \ingroup CPPHighAPI /// \brief Create Boolean Cut feature. FEATURESAPI_EXPORT -BooleanPtr addCut(const std::shared_ptr & thePart, +BooleanPtr addCut(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects); /// \ingroup CPPHighAPI /// \brief Create Boolean Fuse feature. FEATURESAPI_EXPORT -BooleanPtr addFuse(const std::shared_ptr & thePart, +BooleanPtr addFuse(const std::shared_ptr& thePart, const std::list& theObjects); /// \ingroup CPPHighAPI /// \brief Create Boolean Fuse feature. FEATURESAPI_EXPORT -BooleanPtr addFuse(const std::shared_ptr & thePart, +BooleanPtr addFuse(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects); /// \ingroup CPPHighAPI /// \brief Create Boolean Common feature. FEATURESAPI_EXPORT -BooleanPtr addCommon(const std::shared_ptr & thePart, +BooleanPtr addCommon(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects); diff --git a/src/FeaturesAPI/FeaturesAPI_Group.cpp b/src/FeaturesAPI/FeaturesAPI_Group.cpp new file mode 100644 index 000000000..f942c0925 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Group.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Group.cpp +// Created: 07 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_Group.h" + +#include +#include +#include + +//================================================================================================== +FeaturesAPI_Group::FeaturesAPI_Group(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_Group::FeaturesAPI_Group(const std::shared_ptr& theFeature, + const std::list& theGroupList) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setGroupList(theGroupList); + } +} + +//================================================================================================== +FeaturesAPI_Group::~FeaturesAPI_Group() +{ + +} + +//================================================================================================== +void FeaturesAPI_Group::setGroupList(const std::list& theGroupList) +{ + fillAttribute(theGroupList, mygroupList); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +GroupPtr addGroup(const std::shared_ptr& thePart, + const std::list& theGroupList) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Group::ID()); + return GroupPtr(new FeaturesAPI_Group(aFeature, theGroupList)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_Group.h b/src/FeaturesAPI/FeaturesAPI_Group.h new file mode 100644 index 000000000..08c2e5bda --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Group.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Group.h +// Created: 07 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_Group_H_ +#define FeaturesAPI_Group_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_Group +/// \ingroup CPPHighAPI +/// \brief Interface for Group feature. +class FeaturesAPI_Group: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Group(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_Group(const std::shared_ptr& theFeature, + const std::list& theGroupList); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_Group(); + + INTERFACE_1(FeaturesPlugin_Group::ID(), + groupList, FeaturesPlugin_Group::LIST_ID()(), ModelAPI_AttributeSelectionList, /** Group list*/) + + /// Set main objects. + FEATURESAPI_EXPORT + void setGroupList(const std::list& theGroupList); +}; + +/// Pointer on Group object. +typedef std::shared_ptr GroupPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Group feature. +FEATURESAPI_EXPORT +GroupPtr addGroup(const std::shared_ptr& thePart, + const std::list& theGroupList); + +#endif // FeaturesAPI_Group_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_Placement.cpp b/src/FeaturesAPI/FeaturesAPI_Placement.cpp index 4d0870615..e071487f1 100644 --- a/src/FeaturesAPI/FeaturesAPI_Placement.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Placement.cpp @@ -9,14 +9,14 @@ #include //================================================================================================== -FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr & theFeature) +FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } //================================================================================================== -FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr & theFeature, +FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr& theFeature, const std::list& theObjects, const ModelHighAPI_Selection& theStartShape, const ModelHighAPI_Selection& theEndShape, @@ -81,7 +81,7 @@ void FeaturesAPI_Placement::setCentering(const bool theCentering) // TODO(spo): make add* as static functions of the class //================================================================================================== -PlacementPtr addPlacement(const std::shared_ptr & thePart, +PlacementPtr addPlacement(const std::shared_ptr& thePart, const std::list& theObjects, const ModelHighAPI_Selection& theStartShape, const ModelHighAPI_Selection& theEndShape, diff --git a/src/FeaturesAPI/FeaturesAPI_Placement.h b/src/FeaturesAPI/FeaturesAPI_Placement.h index 691fd509b..14378f068 100644 --- a/src/FeaturesAPI/FeaturesAPI_Placement.h +++ b/src/FeaturesAPI/FeaturesAPI_Placement.h @@ -19,16 +19,16 @@ class ModelHighAPI_Selection; /// \class FeaturesAPI_Placement /// \ingroup CPPHighAPI /// \brief Interface for Placement feature. -class FeaturesAPI_Placement : public ModelHighAPI_Interface +class FeaturesAPI_Placement: public ModelHighAPI_Interface { public: /// Constructor without values. FEATURESAPI_EXPORT - explicit FeaturesAPI_Placement(const std::shared_ptr & theFeature); + explicit FeaturesAPI_Placement(const std::shared_ptr& theFeature); /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Placement(const std::shared_ptr & theFeature, + FeaturesAPI_Placement(const std::shared_ptr& theFeature, const std::list& theObjects, const ModelHighAPI_Selection& theStartShape, const ModelHighAPI_Selection& theEndShape, @@ -73,7 +73,7 @@ typedef std::shared_ptr PlacementPtr; /// \ingroup CPPHighAPI /// \brief Create Placement feature. FEATURESAPI_EXPORT -PlacementPtr addPlacement(const std::shared_ptr & thePart, +PlacementPtr addPlacement(const std::shared_ptr& thePart, const std::list& theObjects, const ModelHighAPI_Selection& theStartShape, const ModelHighAPI_Selection& theEndShape, diff --git a/src/FeaturesAPI/FeaturesAPI_Rotation.cpp b/src/FeaturesAPI/FeaturesAPI_Rotation.cpp index a043f5928..fdc8996de 100644 --- a/src/FeaturesAPI/FeaturesAPI_Rotation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Rotation.cpp @@ -9,14 +9,14 @@ #include //================================================================================================== -FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr & theFeature) +FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } //================================================================================================== -FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr & theFeature, +FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr& theFeature, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theAngle) @@ -61,7 +61,7 @@ void FeaturesAPI_Rotation::setAngle(const ModelHighAPI_Double& theAngle) // TODO(spo): make add* as static functions of the class //================================================================================================== -RotationPtr addRotation(const std::shared_ptr & thePart, +RotationPtr addRotation(const std::shared_ptr& thePart, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance) diff --git a/src/FeaturesAPI/FeaturesAPI_Rotation.h b/src/FeaturesAPI/FeaturesAPI_Rotation.h index 0267cc94c..c8e74ace8 100644 --- a/src/FeaturesAPI/FeaturesAPI_Rotation.h +++ b/src/FeaturesAPI/FeaturesAPI_Rotation.h @@ -20,16 +20,16 @@ class ModelHighAPI_Selection; /// \class FeaturesAPI_Rotation /// \ingroup CPPHighAPI /// \brief Interface for Rotation feature. -class FeaturesAPI_Rotation : public ModelHighAPI_Interface +class FeaturesAPI_Rotation: public ModelHighAPI_Interface { public: /// Constructor without values. FEATURESAPI_EXPORT - explicit FeaturesAPI_Rotation(const std::shared_ptr & theFeature); + explicit FeaturesAPI_Rotation(const std::shared_ptr& theFeature); /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Rotation(const std::shared_ptr & theFeature, + FeaturesAPI_Rotation(const std::shared_ptr& theFeature, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theAngle); @@ -62,7 +62,7 @@ typedef std::shared_ptr RotationPtr; /// \ingroup CPPHighAPI /// \brief Create Rotation feature. FEATURESAPI_EXPORT -RotationPtr addRotation(const std::shared_ptr & thePart, +RotationPtr addRotation(const std::shared_ptr& thePart, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance); diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index 5c3fa0632..e4c61d954 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -9,14 +9,14 @@ #include //================================================================================================== -FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr & theFeature) +FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } //================================================================================================== -FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr & theFeature, +FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr& theFeature, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance) @@ -61,7 +61,7 @@ void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance // TODO(spo): make add* as static functions of the class //================================================================================================== -TranslationPtr addTranslation(const std::shared_ptr & thePart, +TranslationPtr addTranslation(const std::shared_ptr& thePart, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance) diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.h b/src/FeaturesAPI/FeaturesAPI_Translation.h index fef95b503..0304f2819 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.h +++ b/src/FeaturesAPI/FeaturesAPI_Translation.h @@ -20,16 +20,16 @@ class ModelHighAPI_Selection; /// \class FeaturesAPI_Translation /// \ingroup CPPHighAPI /// \brief Interface for Translation feature. -class FeaturesAPI_Translation : public ModelHighAPI_Interface +class FeaturesAPI_Translation: public ModelHighAPI_Interface { public: /// Constructor without values. FEATURESAPI_EXPORT - explicit FeaturesAPI_Translation(const std::shared_ptr & theFeature); + explicit FeaturesAPI_Translation(const std::shared_ptr& theFeature); /// Constructor with values. FEATURESAPI_EXPORT - FeaturesAPI_Translation(const std::shared_ptr & theFeature, + FeaturesAPI_Translation(const std::shared_ptr& theFeature, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance); @@ -62,7 +62,7 @@ typedef std::shared_ptr TranslationPtr; /// \ingroup CPPHighAPI /// \brief Create Translation feature. FEATURESAPI_EXPORT -TranslationPtr addTranslation(const std::shared_ptr & thePart, +TranslationPtr addTranslation(const std::shared_ptr& thePart, const std::list& theMainObjects, const ModelHighAPI_Selection& theAxisObject, const ModelHighAPI_Double& theDistance); diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index 61571735a..b9836a45e 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -10,6 +10,7 @@ #include #include "FeaturesAPI.h" + #include "FeaturesAPI_Group.h" #include "FeaturesAPI_Boolean.h" #include "FeaturesAPI_Placement.h" #include "FeaturesAPI_Rotation.h" diff --git a/src/PythonAPI/Test/TestFeatures.py b/src/PythonAPI/Test/TestFeatures.py index a5e98ba65..07df469c9 100644 --- a/src/PythonAPI/Test/TestFeatures.py +++ b/src/PythonAPI/Test/TestFeatures.py @@ -72,7 +72,7 @@ class FeaturesTestCase(FeaturesFixture): FeaturesAPI.FeaturesAPI_Placement(self.part.addFeature("Placement")) FeaturesAPI.FeaturesAPI_Rotation(self.part.addFeature("Rotation")) FeaturesAPI.FeaturesAPI_Translation(self.part.addFeature("Translation")) - model.features.group.Group(self.part.addFeature("Group")) + FeaturesAPI.FeaturesAPI_Group(self.part.addFeature("Group")) model.parameter.Parameter(self.part.addFeature("Parameter"))