X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Union.cpp;h=6ff051d09e97e1a4600e1ab2bc433252e8f1fbe6;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=bc8bc1859a8f1a13701ba0f53db3ab10bf17b505;hpb=13c564bef7d39cd31b142d6723caf03501a4f683;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Union.cpp b/src/FeaturesAPI/FeaturesAPI_Union.cpp index bc8bc1859..6ff051d09 100644 --- a/src/FeaturesAPI/FeaturesAPI_Union.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Union.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 @@ -22,6 +22,10 @@ #include #include + +static const double DEFAULT_FUZZY = 1.e-5; + + //================================================================================================ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) @@ -32,12 +36,22 @@ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& th //================================================================================================ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature, const std::list& theBaseObjects, - const int theVersion) + const ModelHighAPI_Double& theFuzzy) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_VersionedBoolean::VERSION_ID())); - setBase(theBaseObjects); + fillAttribute(theBaseObjects, VAR_NAME(baseObjects)); + 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(); } } @@ -50,7 +64,23 @@ FeaturesAPI_Union::~FeaturesAPI_Union() //================================================================================================== void FeaturesAPI_Union::setBase(const std::list& theBaseObjects) { - fillAttribute(theBaseObjects, mybaseObjects); + fillAttribute(theBaseObjects, VAR_NAME(baseObjects)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Union::setUseFuzzy(bool theUseFuzzy) +{ + fillAttribute(theUseFuzzy, VAR_NAME(useFuzzy)); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_Union::setFuzzyValue(const ModelHighAPI_Double& theFuzzy) +{ + fillAttribute(theFuzzy, VAR_NAME(fuzzyParam)); execute(); } @@ -63,13 +93,15 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID()); - AttributeIntegerPtr aVersion = - aBase->integer(FeaturesPlugin_Union::VERSION_ID()); + bool aUseFuzzy = aBase->boolean(FeaturesPlugin_Union::USE_FUZZY_ID())->value(); + AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_Union::FUZZY_PARAM_ID()); theDumper << aBase << " = model.addUnion(" << aDocName << ", " << anAttrObjects; - 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; @@ -78,10 +110,11 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const //================================================================================================== UnionPtr addUnion(const std::shared_ptr& thePart, const std::list& theBaseObjects, + const ModelHighAPI_Double& theFuzzy, const bool keepSubResults) { - int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1 - : FeaturesPlugin_VersionedBoolean::THE_VERSION_0; std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Union::ID()); - return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects, aVersion)); + if (!keepSubResults) + aFeature->data()->setVersion(""); + return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects, theFuzzy)); }