-// 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_Dumper.h>
#include <ModelHighAPI_Tools.h>
+
+static const double DEFAULT_FUZZY = 1.e-5;
+
+
//==================================================================================================
FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
FeaturesAPI_Partition::FeaturesAPI_Partition(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const int theVersion)
+ const ModelHighAPI_Double& theFuzzy)
: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
- fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Partition::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();
}
}
//==================================================================================================
void FeaturesAPI_Partition::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
{
- fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theBaseObjects, VAR_NAME(baseObjects));
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Partition::setUseFuzzy(bool theUseFuzzy)
+{
+ fillAttribute(theUseFuzzy, VAR_NAME(useFuzzy));
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Partition::setFuzzy(const ModelHighAPI_Double& theFuzzy)
+{
+ fillAttribute(theFuzzy, VAR_NAME(fuzzyParam));
execute();
}
AttributeSelectionListPtr anAttrObjects =
aBase->selectionList(FeaturesPlugin_Partition::BASE_OBJECTS_ID());
- AttributeIntegerPtr aVersion =
- aBase->integer(FeaturesPlugin_Partition::VERSION_ID());
+ bool aUseFuzzy = aBase->boolean(FeaturesPlugin_Partition::USE_FUZZY_ID())->value();
+ AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_Partition::FUZZY_PARAM_ID());
theDumper << aBase << " = model.addPartition(" << 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;
//==================================================================================================
PartitionPtr addPartition(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Double& theFuzzy,
const bool keepSubResults)
{
- int aVersion = keepSubResults ? FeaturesPlugin_VersionedBoolean::THE_VERSION_1
- : FeaturesPlugin_VersionedBoolean::THE_VERSION_0;
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Partition::ID());
- return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects, aVersion));
+ if (!keepSubResults)
+ aFeature->data()->setVersion("");
+ return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects, theFuzzy));
}