X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_BooleanCommon.cpp;h=e7ad27b677e4d54a108ae127eec7fc1a408bb7a7;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=bd53854ef0e99c93d25775ab1c77672b7f2ce235;hpb=50cef8966d30d658565b08428b4b313f3449d23c;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp index bd53854ef..e7ad27b67 100644 --- a/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 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 @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "FeaturesAPI_BooleanCommon.h" @@ -24,6 +23,10 @@ #include #include + +static const double DEFAULT_FUZZY = 1.e-5; + + //================================================================================================== FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature) @@ -36,12 +39,47 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( const std::shared_ptr& theFeature, const std::list& theMainObjects, - const std::list& theToolObjects) + const ModelHighAPI_Double& theFuzzy) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + 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); + } +} + +//================================================================================================== +FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const std::list& theToolObjects, + const ModelHighAPI_Double& theFuzzy) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - 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); } @@ -57,7 +95,7 @@ FeaturesAPI_BooleanCommon::~FeaturesAPI_BooleanCommon() void FeaturesAPI_BooleanCommon::setMainObjects( const std::list& theMainObjects) { - fillAttribute(theMainObjects, mymainObjects); + fillAttribute(theMainObjects, VAR_NAME(mainObjects)); execute(); } @@ -66,7 +104,36 @@ void FeaturesAPI_BooleanCommon::setMainObjects( void FeaturesAPI_BooleanCommon::setToolObjects( const std::list& theToolObjects) { - 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(); +} + +//================================================================================================== +void FeaturesAPI_BooleanCommon::setAdvancedMode(const bool theMode) +{ + if (theMode) { + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), VAR_NAME(creationMethod)); + } else { + fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), VAR_NAME(creationMethod)); + } execute(); } @@ -79,21 +146,43 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const theDumper << aBase << " = model.addCommon"; const std::string& aDocName = theDumper.name(aBase->document()); + AttributeStringPtr aMode = aBase->string(FeaturesPlugin_BooleanCommon::CREATION_METHOD()); AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID()); AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID()); + bool aUseFuzzy = aBase->boolean(FeaturesPlugin_BooleanCommon::USE_FUZZY_ID())->value(); + AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_BooleanCommon::FUZZY_PARAM_ID()); + + theDumper << "(" << aDocName << ", " << anObjects; + + if (aMode->value() == FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED()) { + theDumper << ", " << aTools; + } + + if (aUseFuzzy) + theDumper << ", fuzzyParam = " << aFuzzy; + + if (!aBase->data()->version().empty()) + theDumper << ", keepSubResults = True"; - theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl; + theDumper << ")" << std::endl; } //================================================================================================== BooleanCommonPtr addCommon(const std::shared_ptr& thePart, const std::list& theMainObjects, - const std::list& theToolObjects) + const std::list& theToolObjects, + const ModelHighAPI_Double& theFuzzy, + const bool keepSubResults) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID()); - return BooleanCommonPtr(new FeaturesAPI_BooleanCommon(aFeature, - theMainObjects, - theToolObjects)); + 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; }