From e2e1b927dc9767f699d6d245de62cf43efa5580a Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 16 Jun 2016 14:11:21 +0300 Subject: [PATCH] Added CPP High API for FeaturesPlugin_ExtrusionCut, FeaturesPlugin_ExtrusionFuse --- src/FeaturesAPI/CMakeLists.txt | 2 + src/FeaturesAPI/FeaturesAPI.i | 4 + src/FeaturesAPI/FeaturesAPI_Extrusion.h | 4 +- .../FeaturesAPI_ExtrusionBoolean.cpp | 492 ++++++++++++++++++ .../FeaturesAPI_ExtrusionBoolean.h | 334 ++++++++++++ src/FeaturesAPI/FeaturesAPI_Revolution.h | 4 +- src/FeaturesAPI/FeaturesAPI_swig.h | 1 + src/ModelHighAPI/ModelHighAPI_Interface.h | 1 + src/ModelHighAPI/ModelHighAPI_Macro.h | 47 +- src/PythonAPI/Test/TestFeatures.py | 4 +- src/PythonAPI/model/features/__init__.py | 10 +- 11 files changed, 889 insertions(+), 14 deletions(-) create mode 100644 src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp create mode 100644 src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.h diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index ec14e58de..519f4e755 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -6,6 +6,7 @@ SET(PROJECT_HEADERS FeaturesAPI.h FeaturesAPI_Boolean.h FeaturesAPI_Extrusion.h + FeaturesAPI_ExtrusionBoolean.h FeaturesAPI_Group.h FeaturesAPI_Placement.h FeaturesAPI_Revolution.h @@ -16,6 +17,7 @@ SET(PROJECT_HEADERS SET(PROJECT_SOURCES FeaturesAPI_Boolean.cpp FeaturesAPI_Extrusion.cpp + FeaturesAPI_ExtrusionBoolean.cpp FeaturesAPI_Group.cpp FeaturesAPI_Placement.cpp FeaturesAPI_Rotation.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index 6fc57716f..55094b61d 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -21,6 +21,9 @@ // shared pointers %shared_ptr(FeaturesAPI_Boolean) %shared_ptr(FeaturesAPI_Extrusion) +%shared_ptr(FeaturesAPI_ExtrusionBoolean) +%shared_ptr(FeaturesAPI_ExtrusionCut) +%shared_ptr(FeaturesAPI_ExtrusionFuse) %shared_ptr(FeaturesAPI_Group) %shared_ptr(FeaturesAPI_Placement) %shared_ptr(FeaturesAPI_Revolution) @@ -30,6 +33,7 @@ // all supported interfaces %include "FeaturesAPI_Boolean.h" %include "FeaturesAPI_Extrusion.h" +%include "FeaturesAPI_ExtrusionBoolean.h" %include "FeaturesAPI_Group.h" %include "FeaturesAPI_Placement.h" %include "FeaturesAPI_Revolution.h" diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.h b/src/FeaturesAPI/FeaturesAPI_Extrusion.h index 3f271e7d5..2c569802f 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.h +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.h @@ -78,7 +78,7 @@ public: virtual ~FeaturesAPI_Extrusion(); INTERFACE_10(FeaturesPlugin_Extrusion::ID(), - baseObjects, FeaturesPlugin_CompositeSketch::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, + baseObjects, FeaturesPlugin_Extrusion::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, creationMethod, FeaturesPlugin_Extrusion::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, toSize, FeaturesPlugin_Extrusion::TO_SIZE_ID(), ModelAPI_AttributeDouble, /** To size */, fromSize, FeaturesPlugin_Extrusion::FROM_SIZE_ID(), ModelAPI_AttributeDouble, /** From size */, @@ -87,7 +87,7 @@ public: fromObject, FeaturesPlugin_Extrusion::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */, fromOffset, FeaturesPlugin_Extrusion::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */, direction, FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID(), ModelAPI_AttributeSelection, /** Direction */, - sketchLauncher, FeaturesPlugin_CompositeSketch::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */) + sketchLauncher, FeaturesPlugin_Extrusion::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */) /// Modify base attribute of the feature. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp new file mode 100644 index 000000000..b645e7393 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp @@ -0,0 +1,492 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_Extrusion.cpp +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#include "FeaturesAPI_ExtrusionBoolean.h" + +#include +#include + +//================================================================================================== +FeaturesAPI_ExtrusionBoolean::FeaturesAPI_ExtrusionBoolean(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ +} + +//================================================================================================== +FeaturesAPI_ExtrusionBoolean::~FeaturesAPI_ExtrusionBoolean() +{ +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setBase(const std::list& theBaseObjects) +{ + fillAttribute(theBaseObjects, mybaseObjects); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setDirection(const ModelHighAPI_Selection& theDirection) +{ + fillAttribute(theDirection, mydirection); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setSizes(const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize) +{ + fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod); + fillAttribute(theToSize, mytoSize); + fillAttribute(theFromSize, myfromSize); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setSize(const ModelHighAPI_Double& theSize) +{ + fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod); + fillAttribute(theSize, mytoSize); + fillAttribute(ModelHighAPI_Double(), myfromSize); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset) +{ + fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod); + fillAttribute(theToObject, mytoObject); + fillAttribute(theToOffset, mytoOffset); + fillAttribute(theFromObject, myfromObject); + fillAttribute(theFromOffset, myfromOffset); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_ExtrusionBoolean::setBooleanObjects(const std::list& theBooleanObjects) +{ + fillAttribute(theBooleanObjects, mybooleanObjects); + + execute(); +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theSize, mytoSize); + fillAttribute(ModelHighAPI_Double(), myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theSize, mytoSize); + fillAttribute(ModelHighAPI_Double(), myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theToSize, mytoSize); + fillAttribute(theFromSize, myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theToSize, mytoSize); + fillAttribute(theFromSize, myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theToObject, mytoObject); + fillAttribute(theToOffset, mytoOffset); + fillAttribute(theFromObject, myfromObject); + fillAttribute(theFromOffset, myfromOffset); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theToObject, mytoObject); + fillAttribute(theToOffset, mytoOffset); + fillAttribute(theFromObject, myfromObject); + fillAttribute(theFromOffset, myfromOffset); + setBooleanObjects(theBooleanObjects); + } +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theDirection, theSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theToSize, theFromSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, + theBaseObjects, + theDirection, + theToSize, + theFromSize, + theBooleanObjects)); +} + +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, + theBaseObjects, + theToObject, + theToOffset, + theFromObject, + theFromOffset, + theBooleanObjects)); +} + +//================================================================================================== +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID()); + return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, + theBaseObjects, + theDirection, + theToObject, + theToOffset, + theFromObject, + theFromOffset, + theBooleanObjects)); +} + + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + initialize(); +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theSize, mytoSize); + fillAttribute(ModelHighAPI_Double(), myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theSize, mytoSize); + fillAttribute(ModelHighAPI_Double(), myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theToSize, mytoSize); + fillAttribute(theFromSize, myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theToSize, mytoSize); + fillAttribute(theFromSize, myfromSize); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theToObject, mytoObject); + fillAttribute(theToOffset, mytoOffset); + fillAttribute(theFromObject, myfromObject); + fillAttribute(theFromOffset, myfromOffset); + setBooleanObjects(theBooleanObjects); + } +} + +//================================================================================================== +FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +: FeaturesAPI_ExtrusionBoolean(theFeature) +{ + if(initialize()) { + fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theDirection, mydirection); + fillAttribute(theToObject, mytoObject); + fillAttribute(theToOffset, mytoOffset); + fillAttribute(theFromObject, myfromObject); + fillAttribute(theFromOffset, myfromOffset); + setBooleanObjects(theBooleanObjects); + } +} + +// TODO(spo): make add* as static functions of the class +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theDirection, theSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theToSize, theFromSize, theBooleanObjects)); +} + +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, + theBaseObjects, + theDirection, + theToSize, + theFromSize, + theBooleanObjects)); +} + +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, + theBaseObjects, + theToObject, + theToOffset, + theFromObject, + theFromOffset, + theBooleanObjects)); +} + +//================================================================================================== +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID()); + return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, + theBaseObjects, + theDirection, + theToObject, + theToOffset, + theFromObject, + theFromOffset, + theBooleanObjects)); +} diff --git a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.h b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.h new file mode 100644 index 000000000..390a955cb --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.h @@ -0,0 +1,334 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_ExtrusionBoolean.h +// Created: 09 June 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesAPI_ExtrusionBoolean_H_ +#define FeaturesAPI_ExtrusionBoolean_H_ + +#include "FeaturesAPI.h" + +#include +#include +#include + +#include +#include + +class ModelHighAPI_Double; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_ExtrusionBoolean +/// \ingroup CPPHighAPI +/// \brief Interface for ExtrusionBoolean feature. +class FeaturesAPI_ExtrusionBoolean: public ModelHighAPI_Interface +{ +public: + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_ExtrusionBoolean(); + + INTERFACE_11("", + sketchLauncher, FeaturesPlugin_Extrusion::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */, + baseObjects, FeaturesPlugin_Extrusion::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, + direction, FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID(), ModelAPI_AttributeSelection, /** Direction */, + creationMethod, FeaturesPlugin_Extrusion::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, + toSize, FeaturesPlugin_Extrusion::TO_SIZE_ID(), ModelAPI_AttributeDouble, /** To size */, + fromSize, FeaturesPlugin_Extrusion::FROM_SIZE_ID(), ModelAPI_AttributeDouble, /** From size */, + toObject, FeaturesPlugin_Extrusion::TO_OBJECT_ID(), ModelAPI_AttributeSelection, /** To object */, + toOffset, FeaturesPlugin_Extrusion::TO_OFFSET_ID(), ModelAPI_AttributeDouble, /** To offset */, + fromObject, FeaturesPlugin_Extrusion::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */, + fromOffset, FeaturesPlugin_Extrusion::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */, + booleanObjects, FeaturesPlugin_CompositeBoolean::OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Boolean objects */) + + /// Modify base attribute of the feature. + FEATURESAPI_EXPORT + void setBase(const std::list& theBaseObjects); + + /// Modify direction_object attribute of the feature. + FEATURESAPI_EXPORT + void setDirection(const ModelHighAPI_Selection& theDirection); + + /// Modify CreationMethod, to_size, from_size attributes of the feature. + FEATURESAPI_EXPORT + void setSizes(const ModelHighAPI_Double& theToSize, const ModelHighAPI_Double& theFromSize); + + /// Modify creation_method, to_size, from_size attributes of the feature. + FEATURESAPI_EXPORT + void setSize(const ModelHighAPI_Double& theSize); + + /// Modify creation_method, to_object, to_offset, from_object, from_offset attributes of the feature. + FEATURESAPI_EXPORT + void setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset); + + /// Modiyfy main_objects attribute of the feature. + FEATURESAPI_EXPORT + void setBooleanObjects(const std::list& theBooleanObjects); + +protected: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionBoolean(const std::shared_ptr& theFeature); +}; + +class FeaturesAPI_ExtrusionCut: public FeaturesAPI_ExtrusionBoolean +{ +public: + FEATURESAPI_EXPORT + virtual std::string getID() { + return FeaturesPlugin_ExtrusionCut::ID(); + } + + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionCut(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); +}; + +/// Pointer on ExtrusionCut object. +typedef std::shared_ptr ExtrusionCutPtr; + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionCut feature. +FEATURESAPI_EXPORT +ExtrusionCutPtr addExtrusionCut(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + +class FeaturesAPI_ExtrusionFuse: public FeaturesAPI_ExtrusionBoolean +{ +public: + FEATURESAPI_EXPORT + virtual std::string getID() { + return FeaturesPlugin_ExtrusionFuse::ID(); + } + + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + + /// Constructor with values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_ExtrusionFuse(const std::shared_ptr& theFeature, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); +}; + +/// Pointer on ExtrusionFuse object. +typedef std::shared_ptr ExtrusionFusePtr; + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Double& theToSize, + const ModelHighAPI_Double& theFromSize, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + +/// \ingroup CPPHighAPI +/// \brief Create ExtrusionFuse feature. +FEATURESAPI_EXPORT +ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr& thePart, + const std::list& theBaseObjects, + const ModelHighAPI_Selection& theDirection, + const ModelHighAPI_Selection& theToObject, + const ModelHighAPI_Double& theToOffset, + const ModelHighAPI_Selection& theFromObject, + const ModelHighAPI_Double& theFromOffset, + const std::list& theBooleanObjects); + +#endif // FeaturesAPI_ExtrusionBoolean_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.h b/src/FeaturesAPI/FeaturesAPI_Revolution.h index a7c0a096c..a8e4bc6dd 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.h +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.h @@ -57,7 +57,7 @@ public: virtual ~FeaturesAPI_Revolution(); INTERFACE_10(FeaturesPlugin_Revolution::ID(), - baseObjects, FeaturesPlugin_CompositeSketch::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, + baseObjects, FeaturesPlugin_Revolution::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */, axis, FeaturesPlugin_Revolution::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection, /** Axis */, creationMethod, FeaturesPlugin_Revolution::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, toAngle, FeaturesPlugin_Revolution::TO_ANGLE_ID(), ModelAPI_AttributeDouble, /** To angle */, @@ -66,7 +66,7 @@ public: toOffset, FeaturesPlugin_Revolution::TO_OFFSET_ID(), ModelAPI_AttributeDouble, /** To offset */, fromObject, FeaturesPlugin_Revolution::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */, fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */, - sketchLauncher, FeaturesPlugin_CompositeSketch::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */) + sketchLauncher, FeaturesPlugin_Revolution::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */) /// Modify base attribute of the feature. FEATURESAPI_EXPORT diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index 8caf40e97..b226b5504 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -12,6 +12,7 @@ #include "FeaturesAPI.h" #include "FeaturesAPI_Boolean.h" #include "FeaturesAPI_Extrusion.h" + #include "FeaturesAPI_ExtrusionBoolean.h" #include "FeaturesAPI_Group.h" #include "FeaturesAPI_Placement.h" #include "FeaturesAPI_Revolution.h" diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.h b/src/ModelHighAPI/ModelHighAPI_Interface.h index 97084a50b..f8644968c 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.h +++ b/src/ModelHighAPI/ModelHighAPI_Interface.h @@ -13,6 +13,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------- class ModelAPI_Feature; class ModelAPI_Result; diff --git a/src/ModelHighAPI/ModelHighAPI_Macro.h b/src/ModelHighAPI/ModelHighAPI_Macro.h index 86e1bec88..a38bebe7b 100644 --- a/src/ModelHighAPI/ModelHighAPI_Macro.h +++ b/src/ModelHighAPI/ModelHighAPI_Macro.h @@ -47,7 +47,8 @@ //-------------------------------------------------------------------------------------- #define INTERFACE_COMMON(KIND) \ - static std::string ID() { return KIND; } + static std::string ID() { return KIND; }\ + virtual std::string getID() { return ID(); } //-------------------------------------------------------------------------------------- #define START_INIT() \ @@ -56,7 +57,7 @@ throwException(ID() + " exception: The feature is NULL."); \ return false; \ } \ - if (getKind() != ID()) { \ + if (getKind() != getID()) { \ throwException(ID() + " exception: Wrong feature kind."); \ return false; \ } @@ -322,5 +323,47 @@ END_INIT() \ public: +//-------------------------------------------------------------------------------------- +#define INTERFACE_11(KIND, \ + N_0, AN_0, T_0, C_0, \ + N_1, AN_1, T_1, C_1, \ + N_2, AN_2, T_2, C_2, \ + N_3, AN_3, T_3, C_3, \ + N_4, AN_4, T_4, C_4, \ + N_5, AN_5, T_5, C_5, \ + N_6, AN_6, T_6, C_6, \ + N_7, AN_7, T_7, C_7, \ + N_8, AN_8, T_8, C_8, \ + N_9, AN_9, T_9, C_9, \ + N_10, AN_10, T_10, C_10) \ + public: \ + INTERFACE_COMMON(KIND) \ + DEFINE_ATTRIBUTE(N_0, T_0, C_0) \ + DEFINE_ATTRIBUTE(N_1, T_1, C_1) \ + DEFINE_ATTRIBUTE(N_2, T_2, C_2) \ + DEFINE_ATTRIBUTE(N_3, T_3, C_3) \ + DEFINE_ATTRIBUTE(N_4, T_4, C_4) \ + DEFINE_ATTRIBUTE(N_5, T_5, C_5) \ + DEFINE_ATTRIBUTE(N_6, T_6, C_6) \ + DEFINE_ATTRIBUTE(N_7, T_7, C_7) \ + DEFINE_ATTRIBUTE(N_8, T_8, C_8) \ + DEFINE_ATTRIBUTE(N_9, T_9, C_9) \ + DEFINE_ATTRIBUTE(N_10, T_10, C_10) \ + protected: \ + START_INIT() \ + SET_ATTRIBUTE(N_0, T_0, AN_0) \ + SET_ATTRIBUTE(N_1, T_1, AN_1) \ + SET_ATTRIBUTE(N_2, T_2, AN_2) \ + SET_ATTRIBUTE(N_3, T_3, AN_3) \ + SET_ATTRIBUTE(N_4, T_4, AN_4) \ + SET_ATTRIBUTE(N_5, T_5, AN_5) \ + SET_ATTRIBUTE(N_6, T_6, AN_6) \ + SET_ATTRIBUTE(N_7, T_7, AN_7) \ + SET_ATTRIBUTE(N_8, T_8, AN_8) \ + SET_ATTRIBUTE(N_9, T_9, AN_9) \ + SET_ATTRIBUTE(N_10, T_10, AN_10) \ + END_INIT() \ + public: + //-------------------------------------------------------------------------------------- #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_MACRO_H_ */ diff --git a/src/PythonAPI/Test/TestFeatures.py b/src/PythonAPI/Test/TestFeatures.py index c744fe82b..111af601b 100644 --- a/src/PythonAPI/Test/TestFeatures.py +++ b/src/PythonAPI/Test/TestFeatures.py @@ -64,8 +64,8 @@ class FeaturesTestCase(FeaturesFixture): import FeaturesAPI FeaturesAPI.FeaturesAPI_Boolean(self.part.addFeature("Boolean")) FeaturesAPI.FeaturesAPI_Extrusion(self.part.addFeature("Extrusion")) - # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionCut")) - # model.features.extrusion_boolean.ExtrusionBoolean(self.part.addFeature("ExtrusionFuse")) + FeaturesAPI.FeaturesAPI_ExtrusionCut(self.part.addFeature("ExtrusionCut")) + FeaturesAPI.FeaturesAPI_ExtrusionFuse(self.part.addFeature("ExtrusionFuse")) FeaturesAPI.FeaturesAPI_Revolution(self.part.addFeature("Revolution")) # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionCut")) # model.features.revolution_boolean.RevolutionBoolean(self.part.addFeature("RevolutionFuse")) diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index ca00dd5bb..cba59bf27 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -1,16 +1,14 @@ """Package for Features plugin for the Parametric Geometry API of the Modeler. """ +from FeaturesAPI import addPlacement, addRotation, addTranslation + from FeaturesAPI import addFuse, addCut, addCommon from partition import addPartition -from FeaturesAPI import addExtrusion, addRevolution -from extrusion_boolean import addExtrusionCut, addExtrusionFuse +from FeaturesAPI import addExtrusion, addExtrusionCut, addExtrusionFuse +from FeaturesAPI import addRevolution from revolution_boolean import addRevolutionCut, addRevolutionFuse -from placement import addPlacement -from rotation import addRotation -from translation import addTranslation - from group import addGroup -- 2.39.2