X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_BooleanCommon.cpp;h=e7ad27b677e4d54a108ae127eec7fc1a408bb7a7;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=d928b89da6b789ba63c4e0b4b19cc41344f80222;hpb=c0460f35b71f9bde466ec48daccabb2a7b8d3c56;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp index d928b89da..e7ad27b67 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.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_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature) @@ -35,13 +39,21 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const int theVersion) + const ModelHighAPI_Double& theFuzzy) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); - fillAttribute(theMainObjects, mymainObjects); + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), VAR_NAME(creationMethod)); + fillAttribute(theMainObjects, VAR_NAME(mainObjects)); + 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); } @@ -52,14 +64,22 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( 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(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod); - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID())); - fillAttribute(theMainObjects, mymainObjects); - fillAttribute(theToolObjects, mytoolObjects); + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), VAR_NAME(creationMethod)); + 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); } @@ -75,7 +95,7 @@ FeaturesAPI_BooleanCommon::~FeaturesAPI_BooleanCommon() void FeaturesAPI_BooleanCommon::setMainObjects( const std::list& theMainObjects) { - fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theMainObjects, VAR_NAME(mainObjects)); execute(); } @@ -84,8 +104,24 @@ void FeaturesAPI_BooleanCommon::setMainObjects( void FeaturesAPI_BooleanCommon::setToolObjects( const std::list& theToolObjects) { - fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod); - fillAttribute(theToolObjects, mytoolObjects); + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), VAR_NAME(creationMethod)); + fillAttribute(theToolObjects, VAR_NAME(toolObjects)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCommon::setUseFuzzy(bool theUseFuzzy) +{ + fillAttribute(theUseFuzzy, VAR_NAME(useFuzzy)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCommon::setFuzzyValue(const ModelHighAPI_Double& theFuzzy) +{ + fillAttribute(theFuzzy, VAR_NAME(fuzzyParam)); execute(); } @@ -94,9 +130,9 @@ void FeaturesAPI_BooleanCommon::setToolObjects( void FeaturesAPI_BooleanCommon::setAdvancedMode(const bool theMode) { if (theMode) { - fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod); + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), VAR_NAME(creationMethod)); } else { - fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod); + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), VAR_NAME(creationMethod)); } execute(); @@ -115,8 +151,8 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_BooleanCommon::VERSION_ID()); + bool aUseFuzzy = aBase->boolean(FeaturesPlugin_BooleanCommon::USE_FUZZY_ID())->value(); + AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_BooleanCommon::FUZZY_PARAM_ID()); theDumper << "(" << aDocName << ", " << anObjects; @@ -124,31 +160,29 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", " << aTools; } - if (aVersion && aVersion->isInitialized()) { - theDumper << ", " << aVersion->value(); - } + if (aUseFuzzy) + theDumper << ", fuzzyParam = " << aFuzzy; - theDumper << ")" << std::endl; -} + if (!aBase->data()->version().empty()) + theDumper << ", keepSubResults = True"; -//================================================================================================== -BooleanCommonPtr addCommon(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const int theVersion) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); - return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theVersion)); + theDumper << ")" << std::endl; } //================================================================================================== BooleanCommonPtr addCommon(const std::shared_ptr& thePart, const std::list& theMainObjects, const std::list& theToolObjects, - const int theVersion) + const ModelHighAPI_Double& theFuzzy, + const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); - return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, - theMainObjects, - theToolObjects, - theVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + BooleanCommonPtr aCommon; + if (theToolObjects.empty()) + aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theFuzzy)); + else + aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theToolObjects, theFuzzy)); + return aCommon; }