From e9f653a8e91fc25d8369fa462c74b8a44a3ec858 Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 16 Jun 2016 16:35:57 +0300 Subject: [PATCH] Added CPP High API for FeaturesPlugin_Partition --- src/FeaturesAPI/CMakeLists.txt | 2 + src/FeaturesAPI/FeaturesAPI.i | 2 + src/FeaturesAPI/FeaturesAPI_Partition.cpp | 49 ++++++++++++++++++++ src/FeaturesAPI/FeaturesAPI_Partition.h | 55 +++++++++++++++++++++++ src/FeaturesAPI/FeaturesAPI_swig.h | 1 + 5 files changed, 109 insertions(+) create mode 100644 src/FeaturesAPI/FeaturesAPI_Partition.cpp create mode 100644 src/FeaturesAPI/FeaturesAPI_Partition.h diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index e01482c49..e8c007d94 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -8,6 +8,7 @@ SET(PROJECT_HEADERS FeaturesAPI_Extrusion.h FeaturesAPI_ExtrusionBoolean.h FeaturesAPI_Group.h + FeaturesAPI_Partition.h FeaturesAPI_Pipe.h FeaturesAPI_Placement.h FeaturesAPI_Revolution.h @@ -21,6 +22,7 @@ SET(PROJECT_SOURCES FeaturesAPI_Extrusion.cpp FeaturesAPI_ExtrusionBoolean.cpp FeaturesAPI_Group.cpp + FeaturesAPI_Partition.cpp FeaturesAPI_Pipe.cpp FeaturesAPI_Placement.cpp FeaturesAPI_Rotation.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index 0bf48a170..79bb8c73e 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -25,6 +25,7 @@ %shared_ptr(FeaturesAPI_ExtrusionCut) %shared_ptr(FeaturesAPI_ExtrusionFuse) %shared_ptr(FeaturesAPI_Group) +%shared_ptr(FeaturesAPI_Partition) %shared_ptr(FeaturesAPI_Pipe) %shared_ptr(FeaturesAPI_Placement) %shared_ptr(FeaturesAPI_Revolution) @@ -39,6 +40,7 @@ %include "FeaturesAPI_Extrusion.h" %include "FeaturesAPI_ExtrusionBoolean.h" %include "FeaturesAPI_Group.h" +%include "FeaturesAPI_Partition.h" %include "FeaturesAPI_Pipe.h" %include "FeaturesAPI_Placement.h" %include "FeaturesAPI_Revolution.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Partition.cpp b/src/FeaturesAPI/FeaturesAPI_Partition.cpp new file mode 100644 index 000000000..b0e3589cd --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Partition.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Partition.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_Partition.h" + +#include + +//================================================================================================== +FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr& theFeature, + const std::list& theBaseObjects) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + setBase(theBaseObjects); + } +} + +//================================================================================================== +FeaturesAPI_Partition::~FeaturesAPI_Partition() +{ + +} + +//================================================================================================== +void FeaturesAPI_Partition::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +PartitionPtr addPartition(const std::shared_ptr& thePart, + const std::list& theBaseObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Partition::ID()); + return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_Partition.h b/src/FeaturesAPI/FeaturesAPI_Partition.h new file mode 100644 index 000000000..c88047899 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_Partition.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Partition.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_Partition_H_ +#define FeaturesAPI_Partition_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_Partition +/// \ingroup CPPHighAPI +/// \brief Interface for Partition feature. +class FeaturesAPI_Partition: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Partition(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_Partition(const std::shared_ptr& theFeature, + const std::list& theBaseObjects); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_Partition(); + + INTERFACE_1(FeaturesPlugin_Partition::ID(), + baseObjects, FeaturesPlugin_Partition::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */) + + /// Modify base attribute of the feature. + FEATURESAPI_EXPORT + void setBase(const std::list& theBaseObjects); +}; + +/// Pointer on Partition object. +typedef std::shared_ptr PartitionPtr; + +/// \ingroup CPPHighAPI +/// \brief Create Partition feature. +FEATURESAPI_EXPORT +PartitionPtr addPartition(const std::shared_ptr& thePart, + const std::list& theBaseObjects); + +#endif // FeaturesAPI_Partition_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index 6d4e02b46..4eef6fd21 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -14,6 +14,7 @@ #include "FeaturesAPI_Extrusion.h" #include "FeaturesAPI_ExtrusionBoolean.h" #include "FeaturesAPI_Group.h" + #include "FeaturesAPI_Partition.h" #include "FeaturesAPI_Pipe.h" #include "FeaturesAPI_Placement.h" #include "FeaturesAPI_Revolution.h" -- 2.39.2