Salome HOME
added checkbox in UI for optional fuzzy parameter
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_BooleanFill.cpp
index 511a7f56da102587497eda25cb1921698a5286d2..ed635775d4aad9ef68e6888ea85b60f09c81aa1f 100644 (file)
@@ -1,4 +1,4 @@
-// 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_BooleanFill::FeaturesAPI_BooleanFill(
   const std::shared_ptr<ModelAPI_Feature>& theFeature)
@@ -36,13 +40,16 @@ FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
   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()));
+    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);
   }
@@ -72,6 +79,22 @@ void FeaturesAPI_BooleanFill::setToolObjects(
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanFill::setUseFuzzy(bool theUseFuzzy)
+{
+  fillAttribute(theUseFuzzy, myuseFuzzy);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_BooleanFill::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -84,13 +107,16 @@ void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const
     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();
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanFill::FUZZY_PARAM_ID())->value();
 
   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;
 }
@@ -99,11 +125,11 @@ void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const
 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& fuzzyParam,
+                        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, fuzzyParam));
 }