From 9609e10b4a2ec308325d6227ae88ec0511be7b22 Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 17 Aug 2018 10:48:16 +0300 Subject: [PATCH] Small fixes for Fuse --- src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp | 44 ++++++++++++------- src/FeaturesAPI/FeaturesAPI_BooleanFuse.h | 16 +++++-- .../Test/TestBooleanCompSolids.py | 3 +- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp index b0e1c76a4..d92cd7976 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp @@ -32,6 +32,22 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( initialize(); } +//================================================================================================== +FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const bool theRemoveEdges) + : ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod); + fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theRemoveEdges, myremoveEdges); + + execute(false); + } +} + //================================================================================================== FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( const std::shared_ptr& theFeature, @@ -41,12 +57,7 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse( : ModelHighAPI_Interface(theFeature) { if(initialize()) { - if (theToolObjects.empty()) { - fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod); - } else { - fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod); - } - + fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod); fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); fillAttribute(theRemoveEdges, myremoveEdges); @@ -76,12 +87,6 @@ void FeaturesAPI_BooleanFuse::setToolObjects( { fillAttribute(theToolObjects, mytoolObjects); - if (theToolObjects.empty()) { - fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod); - } else { - fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod); - } - execute(); } @@ -93,6 +98,16 @@ void FeaturesAPI_BooleanFuse::setRemoveEdges(const bool theRemoveEdges) execute(); } +//================================================================================================== +void FeaturesAPI_BooleanFuse::setAdvancedMode(const bool theMode) +{ + if (theMode) { + fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod); + } else { + fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod); + } +} + //================================================================================================== void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const { @@ -101,6 +116,7 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const theDumper << aBase << " = model.addFuse"; const std::string& aDocName = theDumper.name(aBase->document()); + AttributeStringPtr aMode = aBase->string(FeaturesPlugin_BooleanFuse::CREATION_METHOD()); AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_BooleanFuse::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = @@ -110,7 +126,7 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const theDumper << "(" << aDocName << ", " << anObjects; - if (aTools->size() > 0) { + if (aMode->value() == FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED()) { theDumper << ", " << aTools; } @@ -127,10 +143,8 @@ BooleanFusePtr addFuse(const std::shared_ptr& thePart, const bool theRemoveEdges) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID()); - std::list aToolObjects; return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature, theObjects, - aToolObjects, theRemoveEdges)); } diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h index 495add44e..7c5f8a239 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h +++ b/src/FeaturesAPI/FeaturesAPI_BooleanFuse.h @@ -41,12 +41,18 @@ public: FEATURESAPI_EXPORT explicit FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature); + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const bool theRemoveEdges = false); + /// Constructor with values. FEATURESAPI_EXPORT FeaturesAPI_BooleanFuse(const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const std::list& theToolObjects, - const bool theRemoveEdges = false); + const std::list& theMainObjects, + const std::list& theToolObjects, + const bool theRemoveEdges = false); /// Destructor. FEATURESAPI_EXPORT @@ -74,6 +80,10 @@ public: FEATURESAPI_EXPORT void setRemoveEdges(const bool theRemoveEdges); + /// Set mode. + FEATURESAPI_EXPORT + void setAdvancedMode(const bool theMode); + /// Dump wrapped feature FEATURESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; diff --git a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py index d529c4cc5..638f27955 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py +++ b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py @@ -133,7 +133,8 @@ aSession.undo() #========================================================================= aSession.startOperation() aBooleanFt = aPart.addFeature("Fuse") -aBooleanFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(extrudedObjects[0]).subResult(1), None) +aBooleanFt.string("creation_method").setValue("advanced") +aBooleanFt.selectionList("main_objects").append(extrudedObjects[0].subResult(1), None) aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], None) aBooleanFt.boolean("remove_intersection_edges").setValue(False) aBooleanFt.execute() -- 2.39.2