From 194397661fa740703e6a23eee4501759d1f020c6 Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 16 Jun 2016 17:37:34 +0300 Subject: [PATCH] Added CPP High API for FeaturesPlugin_RemoveSubShapes --- src/FeaturesAPI/CMakeLists.txt | 4 +- src/FeaturesAPI/FeaturesAPI.i | 2 + .../FeaturesAPI_RemoveSubShapes.cpp | 59 ++++++++++++++++++ src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.h | 60 +++++++++++++++++++ src/FeaturesAPI/FeaturesAPI_swig.h | 1 + 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.cpp create mode 100644 src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.h diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index acd90db77..ac6f97e99 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS FeaturesAPI_Partition.h FeaturesAPI_Pipe.h FeaturesAPI_Placement.h + FeaturesAPI_RemoveSubShapes.h FeaturesAPI_Revolution.h FeaturesAPI_RevolutionBoolean.h FeaturesAPI_Rotation.h @@ -27,9 +28,10 @@ SET(PROJECT_SOURCES FeaturesAPI_Partition.cpp FeaturesAPI_Pipe.cpp FeaturesAPI_Placement.cpp - FeaturesAPI_Rotation.cpp + FeaturesAPI_RemoveSubShapes.cpp FeaturesAPI_Revolution.cpp FeaturesAPI_RevolutionBoolean.cpp + FeaturesAPI_Rotation.cpp FeaturesAPI_Translation.cpp ) diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index e4dd0c754..748634b66 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -29,6 +29,7 @@ %shared_ptr(FeaturesAPI_Partition) %shared_ptr(FeaturesAPI_Pipe) %shared_ptr(FeaturesAPI_Placement) +%shared_ptr(FeaturesAPI_RemoveSubShapes) %shared_ptr(FeaturesAPI_Revolution) %shared_ptr(FeaturesAPI_RevolutionBoolean) %shared_ptr(FeaturesAPI_RevolutionCut) @@ -45,6 +46,7 @@ %include "FeaturesAPI_Partition.h" %include "FeaturesAPI_Pipe.h" %include "FeaturesAPI_Placement.h" +%include "FeaturesAPI_RemoveSubShapes.h" %include "FeaturesAPI_Revolution.h" %include "FeaturesAPI_RevolutionBoolean.h" %include "FeaturesAPI_Rotation.h" diff --git a/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.cpp b/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.cpp new file mode 100644 index 000000000..79c3c6f0b --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.cpp @@ -0,0 +1,59 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_RemoveSubShapes.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_RemoveSubShapes.h" + +#include + +//================================================================================================== +FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theBase) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBase); + + execute(); + } +} + +//================================================================================================== +FeaturesAPI_RemoveSubShapes::~FeaturesAPI_RemoveSubShapes() +{ + +} + +//================================================================================================== +void FeaturesAPI_RemoveSubShapes::setBase(const ModelHighAPI_Selection& theBase) +{ + fillAttribute(theBase, mybase); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_RemoveSubShapes::setSubShapesToKeep(const std::list& theSubShapes) +{ + fillAttribute(theSubShapes, mysubshapes); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +RemoveSubShapesPtr addRemoveSubShapes(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theBase) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_RemoveSubShapes::ID()); + return RemoveSubShapesPtr(new FeaturesAPI_RemoveSubShapes(aFeature, theBase)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.h b/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.h new file mode 100644 index 000000000..d4de1dcc2 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_RemoveSubShapes.h @@ -0,0 +1,60 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_RemoveSubShapes.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_RemoveSubShapes_H_ +#define FeaturesAPI_RemoveSubShapes_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_RemoveSubShapes +/// \ingroup CPPHighAPI +/// \brief Interface for RemoveSubShapes feature. +class FeaturesAPI_RemoveSubShapes: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_RemoveSubShapes(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_RemoveSubShapes(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theBase); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_RemoveSubShapes(); + + INTERFACE_2(FeaturesPlugin_RemoveSubShapes::ID(), + base, FeaturesPlugin_RemoveSubShapes::BASE_SHAPE_ID(), ModelAPI_AttributeSelection, /** Base */, + subshapes, FeaturesPlugin_RemoveSubShapes::SUBSHAPES_ID(), ModelAPI_AttributeSelectionList, /** Subshapes */) + + /// Modify objects attribute of the feature. + FEATURESAPI_EXPORT + void setBase(const ModelHighAPI_Selection& theBase); + + /// Modify tools attribute of the feature. + FEATURESAPI_EXPORT + void setSubShapesToKeep(const std::list& theSubShapes); +}; + +/// Pointer on RemoveSubShapes object. +typedef std::shared_ptr RemoveSubShapesPtr; + +/// \ingroup CPPHighAPI +/// \brief Create RemoveSubShapes feature. +FEATURESAPI_EXPORT +RemoveSubShapesPtr addRemoveSubShapes(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theBase); + +#endif // FeaturesAPI_RemoveSubShapes_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index b88b1f922..0710405ad 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -18,6 +18,7 @@ #include "FeaturesAPI_Partition.h" #include "FeaturesAPI_Pipe.h" #include "FeaturesAPI_Placement.h" + #include "FeaturesAPI_RemoveSubShapes.h" #include "FeaturesAPI_Revolution.h" #include "FeaturesAPI_RevolutionBoolean.h" #include "FeaturesAPI_Rotation.h" -- 2.39.2