From: dbv Date: Wed, 17 Aug 2016 07:41:07 +0000 (+0300) Subject: Issue #1648: Dump Python in the High Level Parameterized Geometry API X-Git-Tag: V_2.5.0~137^2~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28b402322360471243fcc6a8eace2afc44b888c8;p=modules%2Fshaper.git Issue #1648: Dump Python in the High Level Parameterized Geometry API CPP High API for FeaturesPlugin_Union; Dump for FeaturesAPI_Union. --- diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index 1db8f2dd6..70ea1166d 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -18,6 +18,7 @@ SET(PROJECT_HEADERS FeaturesAPI_RevolutionBoolean.h FeaturesAPI_Rotation.h FeaturesAPI_Translation.h + FeaturesAPI_Union.h ) SET(PROJECT_SOURCES @@ -35,6 +36,7 @@ SET(PROJECT_SOURCES FeaturesAPI_RevolutionBoolean.cpp FeaturesAPI_Rotation.cpp FeaturesAPI_Translation.cpp + FeaturesAPI_Union.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index d2c9f968a..cc7cbdd54 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -37,6 +37,7 @@ %shared_ptr(FeaturesAPI_RevolutionFuse) %shared_ptr(FeaturesAPI_Rotation) %shared_ptr(FeaturesAPI_Translation) +%shared_ptr(FeaturesAPI_Union) // all supported interfaces %include "FeaturesAPI_Boolean.h" @@ -53,3 +54,4 @@ %include "FeaturesAPI_RevolutionBoolean.h" %include "FeaturesAPI_Rotation.h" %include "FeaturesAPI_Translation.h" +%include "FeaturesAPI_Union.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Union.cpp b/src/FeaturesAPI/FeaturesAPI_Union.cpp new file mode 100644 index 000000000..a3580a303 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Union.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Union.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_Union.h" + +#include +#include + +//================================================================================================== +FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +FeaturesAPI_Union::~FeaturesAPI_Union() +{ + +} + +//================================================================================================== +void FeaturesAPI_Union::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID()); + + theDumper << aBase << " = model.addUnion(" << aDocName << ", " << anAttrObjects << ")" << std::endl; +} + +//================================================================================================== +UnionPtr addUnion(const std::shared_ptr& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Union::ID()); + return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_Union.h b/src/FeaturesAPI/FeaturesAPI_Union.h new file mode 100644 index 000000000..e07a9b168 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Union.h @@ -0,0 +1,60 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Union.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_Union_H_ +#define FeaturesAPI_Union_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Dumper; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_Union +/// \ingroup CPPHighAPI +/// \brief Interface for Union feature. +class FeaturesAPI_Union: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Union(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Union(const std::shared_ptr& theFeature, + const std::list& theBaseObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_Union(); + + INTERFACE_1(FeaturesPlugin_Union::ID(), + baseObjects, FeaturesPlugin_Union::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */) + + /// Modify base attribute of the feature. + FEATURESAPI_EXPORT + void setBase(const std::list& theBaseObjects); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Union object. +typedef std::shared_ptr UnionPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Union feature. +FEATURESAPI_EXPORT +UnionPtr addUnion(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // FeaturesAPI_Union_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index f8da2bcfa..8fff1a42b 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -24,5 +24,6 @@ #include "FeaturesAPI_RevolutionBoolean.h" #include "FeaturesAPI_Rotation.h" #include "FeaturesAPI_Translation.h" + #include "FeaturesAPI_Union.h" #endif // FeaturesAPI_swig_H_ diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index e7ff9b1c5..f0b317407 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -6,5 +6,5 @@ from FeaturesAPI import addExtrusion, addExtrusionCut, addExtrusionFuse from FeaturesAPI import addRevolution, addRevolutionCut, addRevolutionFuse from FeaturesAPI import addPipe from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addFill -from FeaturesAPI import addIntersection, addPartition, addRemoveSubShapes +from FeaturesAPI import addIntersection, addPartition, addUnion, addRemoveSubShapes from FeaturesAPI import addGroup, addRecover