X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Union.cpp;h=6fb7d6388a525a08f39b178ae7ea6400f7e54647;hb=2576167d524fef734f4b8cc40bd79a96b2a0fb6a;hp=3c652adbadc69dac3d5b3bc0ca6c4fc036bac70f;hpb=1fd15bed1c62f994a3438bc4a12f44d0361f98c9;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Union.cpp b/src/FeaturesAPI/FeaturesAPI_Union.cpp index 3c652adba..6fb7d6388 100644 --- a/src/FeaturesAPI/FeaturesAPI_Union.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Union.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // 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) @@ -31,11 +35,23 @@ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& th //================================================================================================ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr& theFeature, - const std::list& theBaseObjects) + const std::list& theBaseObjects, + const ModelHighAPI_Double& theFuzzy) : ModelHighAPI_Interface(theFeature) { if(initialize()) { - 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(); } } @@ -48,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(); } @@ -61,9 +93,14 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_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 (aUseFuzzy) + theDumper << ", fuzzyParam = " << aFuzzy; + if (!aBase->data()->version().empty()) theDumper << ", keepSubResults = True"; @@ -73,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) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Union::ID()); if (!keepSubResults) aFeature->data()->setVersion(""); - return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects)); + return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects, theFuzzy)); }