-// 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
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+
+static const double DEFAULT_FUZZY = 1.e-5;
+
+
//==================================================================================================
FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
const std::shared_ptr<ModelAPI_Feature>& theFeature)
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<ModelHighAPI_Selection>& theMainObjects,
const std::list<ModelHighAPI_Selection>& 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);
}
void FeaturesAPI_BooleanFill::setMainObjects(
const std::list<ModelHighAPI_Selection>& theMainObjects)
{
- fillAttribute(theMainObjects, mymainObjects);
+ fillAttribute(theMainObjects, VAR_NAME(mainObjects));
execute();
}
void FeaturesAPI_BooleanFill::setToolObjects(
const std::list<ModelHighAPI_Selection>& theToolObjects)
{
- fillAttribute(theToolObjects, mytoolObjects);
+ fillAttribute(theToolObjects, VAR_NAME(toolObjects));
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_BooleanFill::setUseFuzzy(bool theUseFuzzy)
+{
+ fillAttribute(theUseFuzzy, VAR_NAME(useFuzzy));
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_BooleanFill::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+ fillAttribute(theFuzzy, VAR_NAME(fuzzyParam));
execute();
}
aBase->selectionList(FeaturesPlugin_BooleanFill::OBJECT_LIST_ID());
AttributeSelectionListPtr aTools =
aBase->selectionList(FeaturesPlugin_BooleanFill::TOOL_LIST_ID());
- AttributeIntegerPtr aVersion =
- aBase->integer(FeaturesPlugin_BooleanFill::VERSION_ID());
+ bool aUseFuzzy = aBase->boolean(FeaturesPlugin_BooleanFill::USE_FUZZY_ID())->value();
+ AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_BooleanFill::FUZZY_PARAM_ID());
theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
- if (aVersion && aVersion->isInitialized())
- theDumper << ", " << aVersion->value();
+ if (aUseFuzzy)
+ theDumper << ", fuzzyParam = " << aFuzzy;
+
+ if (!aBase->data()->version().empty())
+ theDumper << ", keepSubResults = True";
theDumper << ")" << std::endl;
}
BooleanFillPtr addSplit(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theMainObjects,
const std::list<ModelHighAPI_Selection>& theToolObjects,
- const int theVersion)
+ const ModelHighAPI_Double& theFuzzy,
+ const bool keepSubResults)
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFill::ID());
- return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature,
- theMainObjects,
- theToolObjects,
- theVersion));
+ if (!keepSubResults)
+ aFeature->data()->setVersion("");
+ return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, theMainObjects, theToolObjects, theFuzzy));
}