#include "FeaturesAPI_ExtrusionBoolean.h"
#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Reference.h>
#include <ModelHighAPI_Tools.h>
//==================================================================================================
{
}
+//==================================================================================================
+void FeaturesAPI_ExtrusionBoolean::setNestedSketch(const ModelHighAPI_Reference& theSketch)
+{
+ mysketch->setValue(theSketch.feature());
+ mybaseObjects->clear();
+ mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr());
+
+ execIfBaseNotEmpty();
+}
+
//==================================================================================================
void FeaturesAPI_ExtrusionBoolean::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
{
+ mysketch->setValue(ObjectPtr());
+ mybaseObjects->clear();
fillAttribute(theBaseObjects, mybaseObjects);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
{
fillAttribute(theDirection, mydirection);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
fillAttribute(theFromObject, myfromObject);
fillAttribute(theFromOffset, myfromOffset);
- execute();
+ execIfBaseNotEmpty();
}
//==================================================================================================
{
fillAttribute(theBooleanObjects, mybooleanObjects);
- execute();
+ execIfBaseNotEmpty();
+}
+
+//==================================================================================================
+void FeaturesAPI_ExtrusionBoolean::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ AttributeReferencePtr anAttrSketch = aBase->reference(FeaturesPlugin_CompositeSketch::SKETCH_ID());
+ AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID());
+ AttributeSelectionPtr anAttrDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID());
+
+ theDumper << aBase << " = model.addExtrusion";
+ if(aBase->getKind() == FeaturesPlugin_ExtrusionCut::ID()) {
+ theDumper << "Cut";
+ } else if(aBase->getKind() == FeaturesPlugin_ExtrusionFuse::ID()) {
+ theDumper << "Fuse";
+ }
+ theDumper << "(" << aDocName << ", ";
+ anAttrSketch->isInitialized() ? theDumper << "[]" : theDumper << anAttrObjects;
+ theDumper << ", " << anAttrDirection;
+
+ std::string aCreationMethod = aBase->string(FeaturesPlugin_Extrusion::CREATION_METHOD())->value();
+
+ if(aCreationMethod == FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES()) {
+ AttributeDoublePtr anAttrToSize = aBase->real(FeaturesPlugin_Extrusion::TO_SIZE_ID());
+ AttributeDoublePtr anAttrFromSize = aBase->real(FeaturesPlugin_Extrusion::FROM_SIZE_ID());
+
+ theDumper << ", " << anAttrToSize << ", " << anAttrFromSize;
+ } else if(aCreationMethod == FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES()) {
+ AttributeSelectionPtr anAttrToObject = aBase->selection(FeaturesPlugin_Extrusion::TO_OBJECT_ID());
+ AttributeDoublePtr anAttrToOffset = aBase->real(FeaturesPlugin_Extrusion::TO_OFFSET_ID());
+ AttributeSelectionPtr anAttrFromObject = aBase->selection(FeaturesPlugin_Extrusion::FROM_OBJECT_ID());
+ AttributeDoublePtr anAttrFromOffset = aBase->real(FeaturesPlugin_Extrusion::FROM_OFFSET_ID());
+
+ theDumper << ", " << anAttrToObject << ", " << anAttrToOffset << ", " << anAttrFromObject << ", " << anAttrFromOffset;
+ }
+
+ AttributeSelectionListPtr anAttrBoolObjects = aBase->selectionList(FeaturesPlugin_CompositeBoolean::OBJECTS_ID());
+ theDumper << ", " << anAttrBoolObjects << ")" << std::endl;
+
+ if(anAttrSketch->isInitialized()) {
+ theDumper << aBase << ".setNestedSketch(" << anAttrSketch << ")" << std::endl;
+ }
}
+//==================================================================================================
+void FeaturesAPI_ExtrusionBoolean::execIfBaseNotEmpty()
+{
+ if(mybaseObjects->size() > 0) {
+ execute();
+ }
+}
+
+
//==================================================================================================
FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: FeaturesAPI_ExtrusionBoolean(theFeature)
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
setBooleanObjects(theBooleanObjects);
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
setBooleanObjects(theBooleanObjects);
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theSize, mytoSize);
fillAttribute(ModelHighAPI_Double(), myfromSize);
setBooleanObjects(theBooleanObjects);
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
setBooleanObjects(theBooleanObjects);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
fillAttribute(theToSize, mytoSize);
fillAttribute(theFromSize, myfromSize);
setBooleanObjects(theBooleanObjects);
{
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
if(initialize()) {
fillAttribute(theBaseObjects, mybaseObjects);
fillAttribute(theDirection, mydirection);
+ fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
fillAttribute(theToObject, mytoObject);
fillAttribute(theToOffset, mytoOffset);
fillAttribute(theFromObject, myfromObject);
#include "FeaturesAPI.h"
-#include <FeaturesPlugin_CompositeBoolean.h>
#include <FeaturesPlugin_ExtrusionCut.h>
#include <FeaturesPlugin_ExtrusionFuse.h>
#include <ModelHighAPI_Macro.h>
class ModelHighAPI_Double;
+class ModelHighAPI_Reference;
class ModelHighAPI_Selection;
/// \class FeaturesAPI_ExtrusionBoolean
virtual ~FeaturesAPI_ExtrusionBoolean();
INTERFACE_11("",
- sketchLauncher, FeaturesPlugin_Extrusion::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */,
+ sketch, 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 */,
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 setNestedSketch(const ModelHighAPI_Reference& theSketch);
+
/// Modify base attribute of the feature.
FEATURESAPI_EXPORT
void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
FEATURESAPI_EXPORT
void setBooleanObjects(const std::list<ModelHighAPI_Selection>& theBooleanObjects);
+ /// Dump wrapped feature
+ FEATURESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+
protected:
/// Constructor without values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_ExtrusionBoolean(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+private:
+ void execIfBaseNotEmpty();
};
class FeaturesAPI_ExtrusionCut: public FeaturesAPI_ExtrusionBoolean
{
public:
- FEATURESAPI_EXPORT
- virtual std::string getID() {
- return FeaturesPlugin_ExtrusionCut::ID();
- }
+
+ static std::string ID() { return FeaturesPlugin_ExtrusionCut::ID(); }
+ virtual std::string getID() { return ID(); }
+
+ //FEATURESAPI_EXPORT
+ //virtual std::string getID() {
+ // return FeaturesPlugin_ExtrusionCut::ID();
+ //}
/// Constructor without values.
FEATURESAPI_EXPORT