-// Copyright (C) 2014-2019 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
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+
+static const double DEFAULT_FUZZY = 1.e-5;
+
+
//==================================================================================================
FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
const std::shared_ptr<ModelAPI_Feature>& theFeature)
FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<ModelHighAPI_Selection>& theMainObjects,
- const std::list<ModelHighAPI_Selection>& theToolObjects)
+ const std::list<ModelHighAPI_Selection>& theToolObjects,
+ const ModelHighAPI_Double& theFuzzy)
: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
+ bool aUseFuzzy = (theFuzzy.value() > 0);
+ ModelHighAPI_Double aFuzzy = (aUseFuzzy ? theFuzzy : ModelHighAPI_Double(DEFAULT_FUZZY));
fillAttribute(theMainObjects, mymainObjects);
fillAttribute(theToolObjects, mytoolObjects);
+ fillAttribute(aUseFuzzy, myuseFuzzy);
+ fillAttribute(aFuzzy, myfuzzyParam);
execute(false);
}
execute();
}
+//==================================================================================================
+void FeaturesAPI_BooleanSmash::setUseFuzzy(bool theUseFuzzy)
+{
+ fillAttribute(theUseFuzzy, myuseFuzzy);
+
+ execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_BooleanSmash::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+ fillAttribute(theFuzzy, myfuzzyParam);
+
+ execute();
+}
+
//==================================================================================================
void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const
{
aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID());
AttributeSelectionListPtr aTools =
aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID());
+ bool aUseFuzzy = aBase->boolean(FeaturesPlugin_BooleanSmash::USE_FUZZY_ID())->value();
+ AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_BooleanSmash::FUZZY_PARAM_ID());
+
+ theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
+
+ if (aUseFuzzy)
+ theDumper << ", fuzzyParam = " << aFuzzy;
+
+ if (!aBase->data()->version().empty())
+ theDumper << ", keepSubResults = True";
- theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
+ theDumper << ")" << std::endl;
}
//==================================================================================================
BooleanSmashPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theMainObjects,
- const std::list<ModelHighAPI_Selection>& theToolObjects)
+ const std::list<ModelHighAPI_Selection>& theToolObjects,
+ const ModelHighAPI_Double& fuzzyParam,
+ const bool keepSubResults)
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID());
- return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature,
- theMainObjects,
- theToolObjects));
+ if (!keepSubResults)
+ aFeature->data()->setVersion("");
+ return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, theMainObjects, theToolObjects, fuzzyParam));
}