Salome HOME
added checkbox in UI for optional fuzzy parameter
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Partition.cpp
index 7e1a77c7a34580d7fa7582f9353ffe36f85fd9c1..e8788e76ad16a9a2e1486e8c7527810b395b9d5f 100644 (file)
@@ -50,6 +50,9 @@
 #include <sstream>
 
 
+static const double DEFAULT_FUZZY = 1.e-5;
+
+
 //=================================================================================================
 FeaturesPlugin_Partition::FeaturesPlugin_Partition()
 {
@@ -60,11 +63,10 @@ void FeaturesPlugin_Partition::initAttributes()
 {
   data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
 
+  data()->addAttribute(USE_FUZZY_ID(), ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(FUZZY_PARAM_ID(), ModelAPI_AttributeDouble::typeId());
-  // Initialize the fuzzy parameter with a value below Precision::Confusion() to indicate,
-  // that the internal algorithms should use their default fuzzy value, if none was specified
-  // by the user.
-  real(FUZZY_PARAM_ID())->setValue(1.e-8);
+  boolean(USE_FUZZY_ID())->setValue(false); // Do NOT use the fuzzy parameter by default.
+  real(FUZZY_PARAM_ID())->setValue(DEFAULT_FUZZY);
   
   initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
 }
@@ -85,7 +87,9 @@ void FeaturesPlugin_Partition::execute()
 
   // Getting fuzzy parameter.
   // Used as additional tolerance to eliminate tiny results.
-  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+  // Using -1 as fuzzy value in the GeomAlgoAPI means to ignore it during the boolean operation!
+  bool aUseFuzzy = boolean(USE_FUZZY_ID())->value();
+  double aFuzzy = (aUseFuzzy ? real(FUZZY_PARAM_ID())->value() : -1);
 
   ListOfShape aBaseObjects = anObjects.objects();
   aBaseObjects.insert(aBaseObjects.end(), aPlanes.begin(), aPlanes.end());