X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_BooleanSmash.cpp;h=858f8b70cedc65113c8b492b5180919bd9702470;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=a91647c0979b8e4977479451c6a14cc24ee8e78a;hpb=13c564bef7d39cd31b142d6723caf03501a4f683;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp index a91647c09..858f8b70c 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -23,6 +23,10 @@ #include #include + +static const double DEFAULT_FUZZY = 1.e-5; + + //================================================================================================== FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( const std::shared_ptr& theFeature) @@ -36,13 +40,21 @@ FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash( const std::shared_ptr& theFeature, const std::list& theMainObjects, const std::list& theToolObjects, - const int theVersion) + const ModelHighAPI_Double& theFuzzy) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); - fillAttribute(theMainObjects, mymainObjects); - fillAttribute(theToolObjects, mytoolObjects); + fillAttribute(theMainObjects, VAR_NAME(mainObjects)); + fillAttribute(theToolObjects, VAR_NAME(toolObjects)); + fillAttribute(theFuzzy, VAR_NAME(fuzzyParam)); + + // Get the evaluated fuzzy parameter from the attribute!! + bool aUseFuzzy = (fuzzyParam()->value() > 0); + fillAttribute(aUseFuzzy, VAR_NAME(useFuzzy)); + if (!aUseFuzzy) { + ModelHighAPI_Double aFuzzy(DEFAULT_FUZZY); + fillAttribute(aFuzzy, VAR_NAME(fuzzyParam)); + } execute(false); } @@ -58,7 +70,7 @@ FeaturesAPI_BooleanSmash::~FeaturesAPI_BooleanSmash() void FeaturesAPI_BooleanSmash::setMainObjects( const std::list& theMainObjects) { - fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theMainObjects, VAR_NAME(mainObjects)); execute(); } @@ -67,7 +79,23 @@ void FeaturesAPI_BooleanSmash::setMainObjects( void FeaturesAPI_BooleanSmash::setToolObjects( const std::list& theToolObjects) { - fillAttribute(theToolObjects, mytoolObjects); + fillAttribute(theToolObjects, VAR_NAME(toolObjects)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanSmash::setUseFuzzy(bool theUseFuzzy) +{ + fillAttribute(theUseFuzzy, VAR_NAME(useFuzzy)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanSmash::setFuzzyValue(const ModelHighAPI_Double& theFuzzy) +{ + fillAttribute(theFuzzy, VAR_NAME(fuzzyParam)); execute(); } @@ -84,13 +112,15 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanSmash::VERSION_ID()); + bool aUseFuzzy = aBase->boolean(FeaturesPlugin_BooleanSmash::USE_FUZZY_ID())->value(); + AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_BooleanSmash::FUZZY_PARAM_ID()); theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools; - if (aVersion && aVersion->isInitialized() && - aVersion->value() == FeaturesPlugin_VersionedBoolean::THE_VERSION_1) + if (aUseFuzzy) + theDumper << ", fuzzyParam = " << aFuzzy; + + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; theDumper << ")" << std::endl; @@ -100,13 +130,11 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const BooleanSmashPtr addSmash(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects, + const ModelHighAPI_Double& theFuzzy, const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID()); - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; - return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, - theMainObjects, - theToolObjects, - aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, theMainObjects, theToolObjects, theFuzzy)); }