]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
support fuzzy parameter in all boolean operations
authormbs <martin.bernhard@opencascade.com>
Tue, 20 Dec 2022 19:25:10 +0000 (19:25 +0000)
committerGérald NICOLAS <gerald.nicolas@edf.fr>
Wed, 1 Feb 2023 16:32:07 +0000 (17:32 +0100)
73 files changed:
src/FeaturesAPI/FeaturesAPI_BooleanCommon.cpp
src/FeaturesAPI/FeaturesAPI_BooleanCommon.h
src/FeaturesAPI/FeaturesAPI_BooleanCut.cpp
src/FeaturesAPI/FeaturesAPI_BooleanCut.h
src/FeaturesAPI/FeaturesAPI_BooleanFill.cpp
src/FeaturesAPI/FeaturesAPI_BooleanFill.h
src/FeaturesAPI/FeaturesAPI_BooleanFuse.cpp
src/FeaturesAPI/FeaturesAPI_BooleanFuse.h
src/FeaturesAPI/FeaturesAPI_BooleanSmash.cpp
src/FeaturesAPI/FeaturesAPI_BooleanSmash.h
src/FeaturesAPI/FeaturesAPI_Intersection.cpp
src/FeaturesAPI/FeaturesAPI_Intersection.h
src/FeaturesAPI/FeaturesAPI_Partition.cpp
src/FeaturesAPI/FeaturesAPI_Partition.h
src/FeaturesAPI/FeaturesAPI_Union.cpp
src/FeaturesAPI/FeaturesAPI_Union.h
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h
src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp
src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp
src/FeaturesPlugin/FeaturesPlugin_Intersection.h
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/FeaturesPlugin/FeaturesPlugin_Partition.h
src/FeaturesPlugin/FeaturesPlugin_Union.cpp
src/FeaturesPlugin/FeaturesPlugin_Union.h
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp
src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.h
src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts
src/FeaturesPlugin/FeaturesPlugin_msg_ru.ts
src/FeaturesPlugin/Test/TestBooleanCommon_Fuzzy.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_1.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_2.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestBooleanFuse_Fuzzy.py [new file with mode: 0644]
src/FeaturesPlugin/boolean_common_widget.xml
src/FeaturesPlugin/boolean_fuse_widget.xml
src/FeaturesPlugin/boolean_smash_widget.xml
src/FeaturesPlugin/boolean_split_widget.xml
src/FeaturesPlugin/boolean_widget.xml
src/FeaturesPlugin/doc/booleanArguments.rst
src/FeaturesPlugin/doc/commonFeature.rst
src/FeaturesPlugin/doc/cutFeature.rst
src/FeaturesPlugin/doc/fuseFeature.rst
src/FeaturesPlugin/doc/images/Partition.png
src/FeaturesPlugin/doc/images/Smash.png
src/FeaturesPlugin/doc/images/Split_panel.png
src/FeaturesPlugin/doc/images/boolean_common_advanced_property_panel.png
src/FeaturesPlugin/doc/images/boolean_common_simple_property_panel.png
src/FeaturesPlugin/doc/images/boolean_cut_property_panel.png
src/FeaturesPlugin/doc/images/boolean_fuse_advanced_property_panel.png
src/FeaturesPlugin/doc/images/boolean_fuse_simple_property_panel.png
src/FeaturesPlugin/doc/images/intersection_property_panel.png
src/FeaturesPlugin/doc/intersectionFeature.rst
src/FeaturesPlugin/doc/partitionFeature.rst
src/FeaturesPlugin/doc/smashFeature.rst
src/FeaturesPlugin/doc/splitFeature.rst
src/FeaturesPlugin/doc/unionFeature.rst
src/FeaturesPlugin/intersection_widget.xml
src/FeaturesPlugin/partition_widget.xml
src/FeaturesPlugin/tests.set
src/FeaturesPlugin/union_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h
src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h
src/GeomAlgoAPI/GeomAlgoAPI_Partition.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Partition.h
src/GeomAlgoAPI/GeomAlgoAPI_PaveFiller.cpp
src/GeomAlgoAPI/GeomAlgoAPI_PaveFiller.h

index b6d06c30cd31796ec74bac350c51cacc3746ffe1..7b8fe4217c42b2b17904ffb9287fdd05b8cceb47 100644 (file)
@@ -34,12 +34,14 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 //==================================================================================================
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
-  const std::list<ModelHighAPI_Selection>& theMainObjects)
+  const std::list<ModelHighAPI_Selection>& theMainObjects,
+  const ModelHighAPI_Double& theFuzzy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
     fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_SIMPLE(), mycreationMethod);
     fillAttribute(theMainObjects, mymainObjects);
+    fillAttribute(theFuzzy, myfuzzyValue);
 
     execute(false);
   }
@@ -49,13 +51,15 @@ FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
 FeaturesAPI_BooleanCommon::FeaturesAPI_BooleanCommon(
   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()) {
     fillAttribute(FeaturesPlugin_BooleanCommon::CREATION_METHOD_ADVANCED(), mycreationMethod);
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
+    fillAttribute(theFuzzy, myfuzzyValue);
 
     execute(false);
   }
@@ -86,6 +90,14 @@ void FeaturesAPI_BooleanCommon::setToolObjects(
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanCommon::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyValue);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanCommon::setAdvancedMode(const bool theMode)
 {
@@ -111,6 +123,7 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanCommon::TOOL_LIST_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanCommon::FUZZY_PARAM_ID())->value();
 
   theDumper << "(" << aDocName << ", " << anObjects;
 
@@ -118,6 +131,8 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
     theDumper << ", " << aTools;
   }
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -128,6 +143,7 @@ void FeaturesAPI_BooleanCommon::dump(ModelHighAPI_Dumper& theDumper) const
 BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
                            const std::list<ModelHighAPI_Selection>& theMainObjects,
                            const std::list<ModelHighAPI_Selection>& theToolObjects,
+                           const ModelHighAPI_Double& fuzzyParam,
                            const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCommon::ID());
@@ -135,8 +151,8 @@ BooleanCommonPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
     aFeature->data()->setVersion("");
   BooleanCommonPtr aCommon;
   if (theToolObjects.empty())
-    aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects));
+    aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, fuzzyParam));
   else
-    aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theToolObjects));
+    aCommon.reset(new FeaturesAPI_BooleanCommon(aFeature, theMainObjects, theToolObjects, fuzzyParam));
   return aCommon;
 }
index c2a055d3002550959d3c5802c440cf262ea9cddd..b5daab10933efa7d67ae25d767de46a15248001c 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
@@ -43,25 +44,29 @@ public:
     /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                            const std::list<ModelHighAPI_Selection>& theMainObjects);
+                            const std::list<ModelHighAPI_Selection>& theMainObjects,
+                            const ModelHighAPI_Double& theFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCommon(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_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_BooleanCommon();
 
-  INTERFACE_3(FeaturesPlugin_BooleanCommon::ID(),
+  INTERFACE_4(FeaturesPlugin_BooleanCommon::ID(),
               creationMethod, FeaturesPlugin_BooleanCommon::CREATION_METHOD(),
               ModelAPI_AttributeString, /** Creation method */,
               mainObjects, FeaturesPlugin_BooleanCommon::OBJECT_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Main objects */,
               toolObjects, FeaturesPlugin_BooleanCommon::TOOL_LIST_ID(),
-              ModelAPI_AttributeSelectionList, /** Tool objects*/)
+              ModelAPI_AttributeSelectionList, /** Tool objects*/,
+              fuzzyValue, FeaturesPlugin_BooleanCommon::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter*/)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -71,6 +76,10 @@ public:
   FEATURESAPI_EXPORT
   void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Set mode.
   FEATURESAPI_EXPORT
   void setAdvancedMode(const bool theMode);
@@ -89,6 +98,7 @@ FEATURESAPI_EXPORT BooleanCommonPtr addCommon(
     const std::shared_ptr<ModelAPI_Document>& part,
     const std::list<ModelHighAPI_Selection>& objects,
     const std::list<ModelHighAPI_Selection>& tools = std::list<ModelHighAPI_Selection>(),
+    const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
     const bool keepSubResults = false);
 
 #endif // FeaturesAPI_BooleanCommon_H_
index 658defee7ede5de568a460fa7d7da2ac876dc337..8bb3e9e40dc97a295a89d4d4512c5d8903ff0f63 100644 (file)
@@ -34,12 +34,14 @@ FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(const std::shared_ptr<ModelAPI_Fe
 FeaturesAPI_BooleanCut::FeaturesAPI_BooleanCut(
   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()) {
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute(false);
   }
@@ -67,6 +69,14 @@ void FeaturesAPI_BooleanCut::setToolObjects(const std::list<ModelHighAPI_Selecti
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanCut::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanCut::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -79,9 +89,12 @@ void FeaturesAPI_BooleanCut::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanCut::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanCut::TOOL_LIST_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanCut::FUZZY_PARAM_ID())->value();
 
   theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -92,12 +105,11 @@ void FeaturesAPI_BooleanCut::dump(ModelHighAPI_Dumper& theDumper) const
 BooleanCutPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                      const std::list<ModelHighAPI_Selection>& theMainObjects,
                      const std::list<ModelHighAPI_Selection>& theToolObjects,
+                     const ModelHighAPI_Double& fuzzyParam,
                      const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanCut::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return BooleanCutPtr(new FeaturesAPI_BooleanCut(aFeature,
-                                                  theMainObjects,
-                                                  theToolObjects));
+  return BooleanCutPtr(new FeaturesAPI_BooleanCut(aFeature, theMainObjects, theToolObjects, fuzzyParam));
 }
index 0035c6fdbf8789af3f4756005e8798af2de03518..09f67374329d5e60b55f922315a47d01c742c125 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
@@ -44,17 +45,20 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanCut(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_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_BooleanCut();
 
-  INTERFACE_2(FeaturesPlugin_BooleanCut::ID(),
+  INTERFACE_3(FeaturesPlugin_BooleanCut::ID(),
               mainObjects, FeaturesPlugin_BooleanCut::OBJECT_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Main objects */,
               toolObjects, FeaturesPlugin_BooleanCut::TOOL_LIST_ID(),
-              ModelAPI_AttributeSelectionList, /** Tool objects*/)
+              ModelAPI_AttributeSelectionList, /** Tool objects*/,
+              fuzzyParam, FeaturesPlugin_BooleanCut::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -64,6 +68,10 @@ public:
   FEATURESAPI_EXPORT
   void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -78,6 +86,7 @@ FEATURESAPI_EXPORT
 BooleanCutPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                      const std::list<ModelHighAPI_Selection>& theMainObjects,
                      const std::list<ModelHighAPI_Selection>& theToolObjects,
+                     const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                      const bool keepSubResults = false);
 
 #endif // FeaturesAPI_BooleanCut_H_
index 7c4716cec4c77e2078a6234c60843de957c91da2..09d4a477401ea24d3af6defbf45e7830902de839 100644 (file)
@@ -35,12 +35,14 @@ FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
 FeaturesAPI_BooleanFill::FeaturesAPI_BooleanFill(
   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()) {
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute(false);
   }
@@ -70,6 +72,14 @@ void FeaturesAPI_BooleanFill::setToolObjects(
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanFill::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -82,9 +92,12 @@ void FeaturesAPI_BooleanFill::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanFill::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanFill::TOOL_LIST_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanFill::FUZZY_PARAM_ID())->value();
 
   theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -95,10 +108,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 ModelHighAPI_Double& fuzzyParam,
                         const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFill::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, theMainObjects, theToolObjects));
+  return BooleanFillPtr(new FeaturesAPI_BooleanFill(aFeature, theMainObjects, theToolObjects, fuzzyParam));
 }
index 9a80cbce48269f2501960e46ba5d3c6196e32603..35743ffc9cab2727d3bffbe50019f932cd188d88 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
@@ -44,17 +45,20 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFill(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_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_BooleanFill();
 
-  INTERFACE_2(FeaturesPlugin_BooleanFill::ID(),
+  INTERFACE_3(FeaturesPlugin_BooleanFill::ID(),
               mainObjects, FeaturesPlugin_BooleanFill::OBJECT_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Main objects */,
               toolObjects, FeaturesPlugin_BooleanFill::TOOL_LIST_ID(),
-              ModelAPI_AttributeSelectionList, /** Tool objects*/)
+              ModelAPI_AttributeSelectionList, /** Tool objects*/,
+              fuzzyParam, FeaturesPlugin_BooleanFill::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -64,6 +68,10 @@ public:
   FEATURESAPI_EXPORT
   void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -78,6 +86,7 @@ FEATURESAPI_EXPORT
 BooleanFillPtr addSplit(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const std::list<ModelHighAPI_Selection>& theMainObjects,
                         const std::list<ModelHighAPI_Selection>& theToolObjects,
+                        const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                         const bool keepSubResults = false);
 
 #endif // FeaturesAPI_BooleanFill_H_
index 5d3ceffed4d120e5e7d769b1d2e1b7b85ec53574..2fd8df0936e0f384b0850cdd417592d1d0e12a24 100644 (file)
@@ -35,13 +35,15 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
 FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
-  const bool theRemoveEdges)
+  const bool theRemoveEdges,
+  const ModelHighAPI_Double& theFuzzy)
   : ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
     fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod);
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theRemoveEdges, myremoveEdges);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute(false);
   }
@@ -52,7 +54,8 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<ModelHighAPI_Selection>& theMainObjects,
   const std::list<ModelHighAPI_Selection>& theToolObjects,
-  const bool theRemoveEdges)
+  const bool theRemoveEdges,
+  const ModelHighAPI_Double& theFuzzy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
@@ -60,6 +63,7 @@ FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
     fillAttribute(theRemoveEdges, myremoveEdges);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute(false);
   }
@@ -98,6 +102,14 @@ void FeaturesAPI_BooleanFuse::setRemoveEdges(const bool theRemoveEdges)
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanFuse::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanFuse::setAdvancedMode(const bool theMode)
 {
@@ -125,6 +137,7 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanFuse::TOOL_LIST_ID());
   AttributeBooleanPtr aRemoveEdges =
     aBase->boolean(FeaturesPlugin_BooleanFuse::REMOVE_INTERSECTION_EDGES_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanFuse::FUZZY_PARAM_ID())->value();
 
   theDumper << "(" << aDocName << ", " << anObjects;
 
@@ -136,6 +149,10 @@ void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const
     theDumper << ", removeEdges = True";
   }
 
+  if (aFuzzy != 1.e-8) {
+    theDumper << ", fuzzyParam = " << aFuzzy;
+  }
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -147,6 +164,7 @@ BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
                        const std::list<ModelHighAPI_Selection>& theMainObjects,
                        const std::pair<std::list<ModelHighAPI_Selection>, bool>& theToolObjects,
                        const bool theRemoveEdges,
+                       const ModelHighAPI_Double& fuzzyParam,
                        const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID());
@@ -159,10 +177,10 @@ BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
 
   BooleanFusePtr aFuse;
   if (theToolObjects.first.empty())
-    aFuse.reset(new FeaturesAPI_BooleanFuse(aFeature, theMainObjects, aRemoveEdges));
+    aFuse.reset(new FeaturesAPI_BooleanFuse(aFeature, theMainObjects, aRemoveEdges, fuzzyParam));
   else {
     aFuse.reset(new FeaturesAPI_BooleanFuse(aFeature, theMainObjects, theToolObjects.first,
-                                            aRemoveEdges));
+                                            aRemoveEdges, fuzzyParam));
   }
   return aFuse;
 }
index 3c4fdccdf44b08dc53a66b64cb80fea3fe80fbc6..04da890e67fc59797a214b1d53885ae0c22522dc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
@@ -44,20 +45,22 @@ public:
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                           const std::list<ModelHighAPI_Selection>& theMainObjects,
-                          const bool theRemoveEdges = false);
+                          const bool theRemoveEdges = false,
+                          const ModelHighAPI_Double& theFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Constructor with values.
   FEATURESAPI_EXPORT
   FeaturesAPI_BooleanFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                           const std::list<ModelHighAPI_Selection>& theMainObjects,
                           const std::list<ModelHighAPI_Selection>& theToolObjects,
-                          const bool theRemoveEdges = false);
+                          const bool theRemoveEdges = false,
+                          const ModelHighAPI_Double& theFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_BooleanFuse();
 
-  INTERFACE_4(FeaturesPlugin_BooleanFuse::ID(),
+  INTERFACE_5(FeaturesPlugin_BooleanFuse::ID(),
               creationMethod, FeaturesPlugin_BooleanFuse::CREATION_METHOD(),
               ModelAPI_AttributeString, /** Creation method */,
               mainObjects, FeaturesPlugin_BooleanFuse::OBJECT_LIST_ID(),
@@ -65,7 +68,9 @@ public:
               toolObjects, FeaturesPlugin_BooleanFuse::TOOL_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Tool objects*/,
               removeEdges, FeaturesPlugin_BooleanFuse::REMOVE_INTERSECTION_EDGES_ID(),
-              ModelAPI_AttributeBoolean, /** Remove edges */)
+              ModelAPI_AttributeBoolean, /** Remove edges */,
+              fuzzyParam, FeaturesPlugin_BooleanFuse::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -79,6 +84,10 @@ public:
   FEATURESAPI_EXPORT
   void setRemoveEdges(const bool theRemoveEdges);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Set mode.
   FEATURESAPI_EXPORT
   void setAdvancedMode(const bool theMode);
@@ -101,6 +110,7 @@ FEATURESAPI_EXPORT BooleanFusePtr addFuse(
     const std::list<ModelHighAPI_Selection>& objects,
     const std::pair<std::list<ModelHighAPI_Selection>, bool>& tools = DUMMY_TOOLS,
     const bool removeEdges = false,
+    const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
     const bool keepSubResults = false);
 
 #endif // FeaturesAPI_BooleanFuse_H_
index 4a4d0330f66fb62cfd158bb6ed123b43996fa34b..7c5ce1722b1a032ed013653c55f4a2c2961a71bb 100644 (file)
@@ -35,12 +35,14 @@ FeaturesAPI_BooleanSmash::FeaturesAPI_BooleanSmash(
 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()) {
     fillAttribute(theMainObjects, mymainObjects);
     fillAttribute(theToolObjects, mytoolObjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute(false);
   }
@@ -70,6 +72,14 @@ void FeaturesAPI_BooleanSmash::setToolObjects(
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_BooleanSmash::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -82,9 +92,12 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID());
   AttributeSelectionListPtr aTools =
     aBase->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_BooleanSmash::FUZZY_PARAM_ID())->value();
 
   theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -95,10 +108,11 @@ void FeaturesAPI_BooleanSmash::dump(ModelHighAPI_Dumper& theDumper) const
 BooleanSmashPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
                          const std::list<ModelHighAPI_Selection>& theMainObjects,
                          const std::list<ModelHighAPI_Selection>& theToolObjects,
+                         const ModelHighAPI_Double& fuzzyParam,
                          const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanSmash::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, theMainObjects, theToolObjects));
+  return BooleanSmashPtr(new FeaturesAPI_BooleanSmash(aFeature, theMainObjects, theToolObjects, fuzzyParam));
 }
index a59db43d0a5a228c01c2199776565759d36caf12..188079af7a55f592e84aa2d6c251c3154ff82eec 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Integer;
 class ModelHighAPI_Selection;
@@ -44,17 +45,20 @@ public:
   FEATURESAPI_EXPORT
   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_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_BooleanSmash();
 
-  INTERFACE_2(FeaturesPlugin_BooleanSmash::ID(),
+  INTERFACE_3(FeaturesPlugin_BooleanSmash::ID(),
               mainObjects, FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Main objects */,
               toolObjects, FeaturesPlugin_BooleanSmash::TOOL_LIST_ID(),
-              ModelAPI_AttributeSelectionList, /** Tool objects*/)
+              ModelAPI_AttributeSelectionList, /** Tool objects*/,
+              fuzzyParam, FeaturesPlugin_BooleanSmash::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -64,6 +68,10 @@ public:
   FEATURESAPI_EXPORT
   void setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -78,6 +86,7 @@ FEATURESAPI_EXPORT
 BooleanSmashPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
                          const std::list<ModelHighAPI_Selection>& theMainObjects,
                          const std::list<ModelHighAPI_Selection>& theToolObjects,
+                         const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                          const bool keepSubResults = false);
 
 #endif // FeaturesAPI_BooleanSmash_H_
index 6ac09629c0ed9684c83492cbbedf775bd209cdb0..6ceafb17045494d1a8e669f88b09c488c75f301d 100644 (file)
@@ -33,11 +33,13 @@ FeaturesAPI_Intersection::FeaturesAPI_Intersection(
 //==================================================================================================
 FeaturesAPI_Intersection::FeaturesAPI_Intersection(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
-  const std::list<ModelHighAPI_Selection>& theObjects)
+  const std::list<ModelHighAPI_Selection>& theObjects,
+  const ModelHighAPI_Double& theFuzzy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
     fillAttribute(theObjects, myobjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
 
     execute();
   }
@@ -57,6 +59,14 @@ void FeaturesAPI_Intersection::setObjects(const std::list<ModelHighAPI_Selection
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Intersection::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -65,9 +75,12 @@ void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
 
   AttributeSelectionListPtr anAttrObjects =
     aBase->selectionList(FeaturesPlugin_Intersection::OBJECT_LIST_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_Intersection::FUZZY_PARAM_ID())->value();
 
   theDumper << aBase << " = model.addIntersection(" << aDocName << ", " << anAttrObjects;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -77,10 +90,11 @@ void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
 //==================================================================================================
 IntersectionPtr addIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
                                 const std::list<ModelHighAPI_Selection>& theObjects,
+                                const ModelHighAPI_Double& fuzzyParam,
                                 const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Intersection::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return IntersectionPtr(new FeaturesAPI_Intersection(aFeature, theObjects));
+  return IntersectionPtr(new FeaturesAPI_Intersection(aFeature, theObjects, fuzzyParam));
 }
index acaff95bc5570effebae067f13800f6f9041fe07..f69daaff6cba982e138d4f63aa19147891fad20e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Dumper;
 class ModelHighAPI_Selection;
@@ -43,20 +44,27 @@ public:
   /// Constructor with values.
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_Intersection(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                    const std::list<ModelHighAPI_Selection>& theObjects);
+                                    const std::list<ModelHighAPI_Selection>& theObjects,
+                                    const ModelHighAPI_Double& aFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_Intersection();
 
-  INTERFACE_1(FeaturesPlugin_Intersection::ID(),
+  INTERFACE_2(FeaturesPlugin_Intersection::ID(),
               objects, FeaturesPlugin_Intersection::OBJECT_LIST_ID(),
-              ModelAPI_AttributeSelectionList, /** Objects */)
+              ModelAPI_AttributeSelectionList, /** Objects */,
+              fuzzyParam, FeaturesPlugin_Intersection::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Modify objects attribute of the feature.
   FEATURESAPI_EXPORT
   void setObjects(const std::list<ModelHighAPI_Selection>& theObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -70,6 +78,7 @@ typedef std::shared_ptr<FeaturesAPI_Intersection> IntersectionPtr;
 FEATURESAPI_EXPORT
 IntersectionPtr addIntersection(const std::shared_ptr<ModelAPI_Document>& part,
                                 const std::list<ModelHighAPI_Selection>& objects,
+                                const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                                 const bool keepSubResults = false);
 
 #endif // FeaturesAPI_Intersection_H_
index 54ff44bb30f6f0789e89d80db12b3bbd680618f3..c7ca9aa40f6aac7741722f0c84eb894ec90179f2 100644 (file)
@@ -32,11 +32,14 @@ FeaturesAPI_Partition::FeaturesAPI_Partition(const std::shared_ptr<ModelAPI_Feat
 //==================================================================================================
 FeaturesAPI_Partition::FeaturesAPI_Partition(
     const std::shared_ptr<ModelAPI_Feature>& theFeature,
-    const std::list<ModelHighAPI_Selection>& theBaseObjects)
+    const std::list<ModelHighAPI_Selection>& theBaseObjects,
+    const ModelHighAPI_Double& theFuzzy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setBase(theBaseObjects);
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
+    execute();
   }
 }
 
@@ -54,6 +57,14 @@ void FeaturesAPI_Partition::setBase(const std::list<ModelHighAPI_Selection>& the
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Partition::setFuzzy(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_Partition::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -62,9 +73,12 @@ void FeaturesAPI_Partition::dump(ModelHighAPI_Dumper& theDumper) const
 
   AttributeSelectionListPtr anAttrObjects =
     aBase->selectionList(FeaturesPlugin_Partition::BASE_OBJECTS_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_Partition::FUZZY_PARAM_ID())->value();
 
   theDumper << aBase << " = model.addPartition(" << aDocName << ", " << anAttrObjects;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -74,10 +88,11 @@ void FeaturesAPI_Partition::dump(ModelHighAPI_Dumper& theDumper) const
 //==================================================================================================
 PartitionPtr addPartition(const std::shared_ptr<ModelAPI_Document>& thePart,
                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                          const ModelHighAPI_Double& fuzzyParam,
                           const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Partition::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects));
+  return PartitionPtr(new FeaturesAPI_Partition(aFeature, theBaseObjects, fuzzyParam));
 }
index eb125b78f93435b4e8456a9b6dc8a853700b006e..3e533ff9305c7b262aa7772fabee2a0057d15868 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Dumper;
 class ModelHighAPI_Selection;
@@ -43,20 +44,27 @@ public:
   /// Constructor with values.
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_Partition(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                 const std::list<ModelHighAPI_Selection>& theBaseObjects);
+                                 const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                 const ModelHighAPI_Double& theFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_Partition();
 
-  INTERFACE_1(FeaturesPlugin_Partition::ID(),
+  INTERFACE_2(FeaturesPlugin_Partition::ID(),
               baseObjects, FeaturesPlugin_Partition::BASE_OBJECTS_ID(),
-              ModelAPI_AttributeSelectionList, /** Base objects */)
+              ModelAPI_AttributeSelectionList, /** Base objects */,
+              fuzzyParam, FeaturesPlugin_Partition::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Modify base attribute of the feature.
   FEATURESAPI_EXPORT
   void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
 
+  /// Modify fuzzy parameter attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setFuzzy(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -70,6 +78,7 @@ typedef std::shared_ptr<FeaturesAPI_Partition> PartitionPtr;
 FEATURESAPI_EXPORT
 PartitionPtr addPartition(const std::shared_ptr<ModelAPI_Document>& thePart,
                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                          const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                           const bool keepSubResults = false);
 
 #endif // FeaturesAPI_Partition_H_
index 082016c98ec49d5811dc17721edc850a330b4764..30e4234b2fef671f0fd08c4162405bda7e3dc0b7 100644 (file)
@@ -31,11 +31,15 @@ FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& th
 
 //================================================================================================
 FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                     const std::list<ModelHighAPI_Selection>& theBaseObjects)
+                                     const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                     const ModelHighAPI_Double& theFuzzy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setBase(theBaseObjects);
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theFuzzy, myfuzzyParam);
+
+    execute();
   }
 }
 
@@ -53,6 +57,14 @@ void FeaturesAPI_Union::setBase(const std::list<ModelHighAPI_Selection>& theBase
   execute();
 }
 
+//==================================================================================================
+void FeaturesAPI_Union::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
+{
+  fillAttribute(theFuzzy, myfuzzyParam);
+
+  execute();
+}
+
 //==================================================================================================
 void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -61,9 +73,12 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const
 
   AttributeSelectionListPtr anAttrObjects =
     aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
+  double aFuzzy = aBase->real(FeaturesPlugin_Union::FUZZY_PARAM_ID())->value();
 
   theDumper << aBase << " = model.addUnion(" << aDocName << ", " << anAttrObjects;
 
+  theDumper << ", fuzzyParam = " << aFuzzy;
+
   if (!aBase->data()->version().empty())
     theDumper << ", keepSubResults = True";
 
@@ -73,10 +88,11 @@ void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const
 //==================================================================================================
 UnionPtr addUnion(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                  const ModelHighAPI_Double& fuzzyParam,
                   const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Union::ID());
   if (!keepSubResults)
     aFeature->data()->setVersion("");
-  return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects));
+  return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects, fuzzyParam));
 }
index af6de974623cbbfba19e858d8b4160d069d4fd68..022d14130f6b242eefdc2747292e2b5c06fc590d 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
+#include <ModelHighAPI_Double.h>
 
 class ModelHighAPI_Dumper;
 class ModelHighAPI_Selection;
@@ -43,20 +44,27 @@ public:
   /// Constructor with values.
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                             const std::list<ModelHighAPI_Selection>& theBaseObjects);
+                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                             const ModelHighAPI_Double& theFuzzy = ModelHighAPI_Double(1.e-8));
 
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_Union();
 
-  INTERFACE_1(FeaturesPlugin_Union::ID(),
+  INTERFACE_2(FeaturesPlugin_Union::ID(),
               baseObjects, FeaturesPlugin_Union::BASE_OBJECTS_ID(),
-              ModelAPI_AttributeSelectionList, /** Base objects */)
+              ModelAPI_AttributeSelectionList, /** Base objects */,
+              fuzzyParam, FeaturesPlugin_Union::FUZZY_PARAM_ID(),
+              ModelAPI_AttributeDouble, /** Fuzzy parameter */)
 
   /// Modify base attribute of the feature.
   FEATURESAPI_EXPORT
   void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
 
+  /// Set fuzzy parameter.
+  FEATURESAPI_EXPORT
+  void setFuzzyValue(const ModelHighAPI_Double& theFuzzy);
+
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -70,6 +78,7 @@ typedef std::shared_ptr<FeaturesAPI_Union> UnionPtr;
 FEATURESAPI_EXPORT
 UnionPtr addUnion(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                  const ModelHighAPI_Double& fuzzyParam = ModelHighAPI_Double(1.e-8),
                   const bool keepSubResults = false);
 
 #endif // FeaturesAPI_Union_H_
index bb277c3824f832975a35b9b2d6194c25c0d945a6..82f08f1820016dff6df9acfb2636463799df0cdb 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_ResultBody.h>
@@ -54,12 +55,14 @@ FeaturesPlugin_Boolean::FeaturesPlugin_Boolean(const OperationType theOperationT
 //=================================================================================================
 void FeaturesPlugin_Boolean::initAttributes()
 {
-  AttributeSelectionListPtr aSelection =
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+  data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+  data()->addAttribute(FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 
-  aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+  data()->addAttribute(FeaturesPlugin_Boolean::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);
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
@@ -120,10 +123,10 @@ void FeaturesPlugin_Boolean::storeResult(
       document()->createBody(data(), theResultIndex);
 
   ModelAPI_Tools::loadModifiedShapes(aResultBody,
-                                           theObjects,
-                                           theTools,
-                                           theMakeShapeList,
-                                           theResultShape);
+                                     theObjects,
+                                     theTools,
+                                     theMakeShapeList,
+                                     theResultShape);
   setResult(aResultBody, theResultIndex++);
 
   // merge algorithms
index 960edb58431382057908280b94c7ee57c4b36eb5..fc88bcbab14cd89d79e04517c1a350b33f1b4a61 100644 (file)
@@ -51,6 +51,13 @@ public:
     return MY_TOOL_LIST_ID;
   }
 
+  /// Attribute name of fuzzy parameter.
+  inline static const std::string& FUZZY_PARAM_ID()
+  {
+    static const std::string MY_FUZZY_PARAM_ID("fuzzy_param");
+    return MY_FUZZY_PARAM_ID;
+  }
+
   /// \return boolean operation type.
   FEATURESPLUGIN_EXPORT OperationType operationType();
 
index e3023859edafe0a6ec66b74dfbd48f34d9e81075..b3d4e4c53f20bc59cf7a5b2710742216a6f187d3 100644 (file)
@@ -20,6 +20,7 @@
 #include "FeaturesPlugin_BooleanCommon.h"
 
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -38,6 +39,7 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Tools.h>
 
+
 //==================================================================================================
 FeaturesPlugin_BooleanCommon::FeaturesPlugin_BooleanCommon()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_COMMON)
@@ -52,6 +54,13 @@ void FeaturesPlugin_BooleanCommon::initAttributes()
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::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);
+
   initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
 }
 
@@ -86,6 +95,10 @@ void FeaturesPlugin_BooleanCommon::execute()
     return;
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   // version of COMMON feature
   const std::string aCommonVersion = data()->version();
 
@@ -104,7 +117,8 @@ void FeaturesPlugin_BooleanCommon::execute()
       std::shared_ptr<GeomAlgoAPI_Boolean> aCommonAlgo(
         new GeomAlgoAPI_Boolean(aShape,
                                 *anObjectsIt,
-                                GeomAlgoAPI_Tools::BOOL_COMMON));
+                                GeomAlgoAPI_Tools::BOOL_COMMON,
+                                aFuzzy));
 
       if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) {
         setError(anError);
@@ -129,10 +143,10 @@ void FeaturesPlugin_BooleanCommon::execute()
       ListOfShape anObjectList = anObjects.objects();
       ListOfShape aToolsList;
       ModelAPI_Tools::loadModifiedShapes(aResultBody,
-                                               anObjectList,
-                                               aToolsList,
-                                               aMakeShapeList,
-                                               aShape);
+                                         anObjectList,
+                                         aToolsList,
+                                         aMakeShapeList,
+                                         aShape);
       GeomShapePtr aBaseShape = anObjectList.front();
       anObjectList.pop_front();
       setResult(aResultBody, aResultIndex);
@@ -167,6 +181,7 @@ void FeaturesPlugin_BooleanCommon::execute()
           // Compound handling
           isOk = processCompound(GeomAlgoAPI_Tools::BOOL_COMMON,
                                  anObjects, aParent, aTools.objects(),
+                                 aFuzzy,
                                  aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                  aResultCompound);
         }
@@ -174,6 +189,7 @@ void FeaturesPlugin_BooleanCommon::execute()
           // Compsolid handling
           isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_COMMON,
                                   anObjects, aParent, aTools.objects(), ListOfShape(),
+                                  aFuzzy,
                                   aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                   aResultCompound);
         }
@@ -181,6 +197,7 @@ void FeaturesPlugin_BooleanCommon::execute()
         // process object as is
         isOk = processObject(GeomAlgoAPI_Tools::BOOL_COMMON,
                              anObject, aTools.objects(), aPlanes,
+                             aFuzzy,
                              aResultIndex, aResultBaseAlgoList, aResultShapesList,
                              aResultCompound);
       }
@@ -195,8 +212,8 @@ void FeaturesPlugin_BooleanCommon::execute()
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
   ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
-                                          aTools.objects(),
-                                          aResultCompound);
+                                    aTools.objects(),
+                                    aResultCompound);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index 7e46caf233ca9563024900b79e00de9f09a726b8..8817a5748787d87bb66f7fc898af7166a14b6cfe 100644 (file)
@@ -66,20 +66,6 @@ public:
     return MY_CREATION_METHOD_ID;
   }
 
-  /// Attribute name of main objects.
-  inline static const std::string& OBJECT_LIST_ID()
-  {
-    static const std::string MY_OBJECT_LIST_ID("main_objects");
-    return MY_OBJECT_LIST_ID;
-  }
-
-  /// Attribute name of tool objects.
-  inline static const std::string& TOOL_LIST_ID()
-  {
-    static const std::string MY_TOOL_LIST_ID("tool_objects");
-    return MY_TOOL_LIST_ID;
-  }
-
   /// Request for initialization of data model of the feature: adding all attributes.
   FEATURESPLUGIN_EXPORT virtual void initAttributes();
 
index 3095f40fdfde59cca6ea5b8cee03bc3fc96b00a8..50de25d0cecd6ddbb011ec9b4d6bf57e5349f95c 100644 (file)
@@ -20,6 +20,7 @@
 #include "FeaturesPlugin_BooleanCut.h"
 
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 
@@ -33,6 +34,7 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
+
 //==================================================================================================
 FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT)
@@ -78,6 +80,10 @@ void FeaturesPlugin_BooleanCut::execute()
         keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   // For solids cut each object with all tools.
   bool isOk = true;
   for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
@@ -92,6 +98,7 @@ void FeaturesPlugin_BooleanCut::execute()
         // Compound handling
         isOk = processCompound(GeomAlgoAPI_Tools::BOOL_CUT,
                                anObjects, aParent, aTools.objects(),
+                               aFuzzy,
                                aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                aResultCompound);
       }
@@ -99,6 +106,7 @@ void FeaturesPlugin_BooleanCut::execute()
         // Compsolid handling
         isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_CUT,
                                 anObjects, aParent, aTools.objects(), ListOfShape(),
+                                aFuzzy,
                                 aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                 aResultCompound);
       }
@@ -106,6 +114,7 @@ void FeaturesPlugin_BooleanCut::execute()
       // process object as is
       isOk = processObject(GeomAlgoAPI_Tools::BOOL_CUT,
                            anObject, aTools.objects(), aPlanes,
+                           aFuzzy,
                            aResultIndex, aResultBaseAlgoList, aResultShapesList,
                            aResultCompound);
     }
@@ -119,8 +128,8 @@ void FeaturesPlugin_BooleanCut::execute()
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
   ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
-                                          aTools.objects(),
-                                          aResultCompound);
+                                    aTools.objects(),
+                                    aResultCompound);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index e0e2c6ed18b4c11c66939210a9a9e067cfbc13e2..247fd35610931694a4cfe970850f88b60ef764d7 100644 (file)
@@ -20,6 +20,7 @@
 #include "FeaturesPlugin_BooleanFill.h"
 
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 
@@ -39,6 +40,7 @@
 #include <algorithm>
 #include <map>
 
+
 //=================================================================================================
 FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill()
   : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_FILL)
@@ -89,6 +91,10 @@ void FeaturesPlugin_BooleanFill::execute()
         keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   // For solids cut each object with all tools.
   bool isOk = true;
   for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
@@ -103,12 +109,14 @@ void FeaturesPlugin_BooleanFill::execute()
       // compsolid handling
       isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_PARTITION,
                               anObjects, aParent, aTools.objects(), aPlanes,
+                              aFuzzy,
                               aResultIndex, aResultBaseAlgoList, aResultShapesList,
                               aResultCompound);
     } else {
       // process object as is
       isOk = processObject(GeomAlgoAPI_Tools::BOOL_PARTITION,
                            anObject, aTools.objects(), aPlanes,
+                           aFuzzy,
                            aResultIndex, aResultBaseAlgoList, aResultShapesList,
                            aResultCompound);
     }
@@ -122,8 +130,8 @@ void FeaturesPlugin_BooleanFill::execute()
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
   ModelAPI_Tools::loadDeletedShapes(aResultBaseAlgoList,
-                                          aTools.objects(),
-                                          aResultCompound);
+                                    aTools.objects(),
+                                    aResultCompound);
 
   // remove the rest results if there were produced in the previous pass
   removeResults(aResultIndex);
index 764a7752f13316a460f8d9f9ce0a8334ed601f3b..a10fead97811daf2ed32203bcf9f9d79ef3ccf72 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
@@ -39,6 +40,8 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
+
+//==================================================================================================
 static void explodeCompound(const GeomShapePtr& theShape, ListOfShape& theResult)
 {
   if (theShape->shapeType() == GeomAPI_Shape::COMPOUND) {
@@ -69,6 +72,12 @@ void FeaturesPlugin_BooleanFuse::initAttributes()
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::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);
+
   data()->addAttribute(REMOVE_INTERSECTION_EDGES_ID(), ModelAPI_AttributeBoolean::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
@@ -115,6 +124,10 @@ void FeaturesPlugin_BooleanFuse::execute()
     return;
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   // version of FUSE feature
   const std::string aFuseVersion = data()->version();
 
@@ -161,7 +174,7 @@ void FeaturesPlugin_BooleanFuse::execute()
   GeomShapePtr aCuttedEdgesAndFaces;
   if (!anEdgesAndFaces.empty()) {
     std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
-      anOriginalShapes, GeomAlgoAPI_Tools::BOOL_CUT));
+      anOriginalShapes, GeomAlgoAPI_Tools::BOOL_CUT, aFuzzy));
     if (aCutAlgo->isDone()) {
       aCuttedEdgesAndFaces = aCutAlgo->shape();
       aMakeShapeList->appendAlgo(aCutAlgo);
@@ -181,7 +194,7 @@ void FeaturesPlugin_BooleanFuse::execute()
       ListOfShape aOneObjectList;
       aOneObjectList.push_back(*anIt);
       std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(
-        new GeomAlgoAPI_Boolean(aOneObjectList, aShapesToAdd, GeomAlgoAPI_Tools::BOOL_CUT));
+        new GeomAlgoAPI_Boolean(aOneObjectList, aShapesToAdd, GeomAlgoAPI_Tools::BOOL_CUT, aFuzzy));
 
       if (GeomAlgoAPI_ShapeTools::area(aCutAlgo->shape()) > 1.e-27) {
         aSolidsToFuse.push_back(aCutAlgo->shape());
@@ -206,7 +219,8 @@ void FeaturesPlugin_BooleanFuse::execute()
   } else if ((anObjects.size() + aTools.size()) > 1) {
     std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects,
       aTools,
-      GeomAlgoAPI_Tools::BOOL_FUSE));
+      GeomAlgoAPI_Tools::BOOL_FUSE,
+      aFuzzy));
 
     // Checking that the algorithm worked properly.
     if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFuseAlgo, getKind(), anError)) {
@@ -229,7 +243,7 @@ void FeaturesPlugin_BooleanFuse::execute()
       aShapesToAdd.push_back(aShape);
     }
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
-      new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+      new GeomAlgoAPI_PaveFiller(aShapesToAdd, true, aFuzzy));
     if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
       setError(anError);
       return;
index 019d27a314d38da9de8c2d8c9fd85b7f791104b7..9f1aca9987fb418a7e98c22049bd1cb90f513b2f 100644 (file)
@@ -20,6 +20,7 @@
 #include "FeaturesPlugin_BooleanSmash.h"
 
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 
@@ -33,6 +34,7 @@
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
+
 //==================================================================================================
 FeaturesPlugin_BooleanSmash::FeaturesPlugin_BooleanSmash()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_SMASH)
@@ -45,6 +47,12 @@ void FeaturesPlugin_BooleanSmash::initAttributes()
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::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);
+
   initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
 }
 
@@ -100,13 +108,18 @@ void FeaturesPlugin_BooleanSmash::execute()
     }
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   if (!aShapesToAdd.empty()) {
     // Cut objects with not used solids.
     std::shared_ptr<GeomAlgoAPI_Boolean> anObjectsCutAlgo(
       new GeomAlgoAPI_Boolean(aShapesToSmash,
                               aShapesToAdd,
-                              GeomAlgoAPI_Tools::BOOL_CUT));
+                              GeomAlgoAPI_Tools::BOOL_CUT,
+                              aFuzzy));
 
     if (GeomAlgoAPI_ShapeTools::area(anObjectsCutAlgo->shape()) > 1.e-27) {
       aShapesToSmash.clear();
@@ -118,7 +131,8 @@ void FeaturesPlugin_BooleanSmash::execute()
     std::shared_ptr<GeomAlgoAPI_Boolean> aToolsCutAlgo(
       new GeomAlgoAPI_Boolean(aTools,
                               aShapesToAdd,
-                              GeomAlgoAPI_Tools::BOOL_CUT));
+                              GeomAlgoAPI_Tools::BOOL_CUT,
+                              aFuzzy));
 
     if (GeomAlgoAPI_ShapeTools::area(aToolsCutAlgo->shape()) > 1.e-27) {
       aTools.clear();
@@ -131,7 +145,8 @@ void FeaturesPlugin_BooleanSmash::execute()
   std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(
     new GeomAlgoAPI_Boolean(aShapesToSmash,
                             aTools,
-                            GeomAlgoAPI_Tools::BOOL_CUT));
+                            GeomAlgoAPI_Tools::BOOL_CUT,
+                            aFuzzy));
 
   // Checking that the algorithm worked properly.
   if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
@@ -154,7 +169,7 @@ void FeaturesPlugin_BooleanSmash::execute()
   }
   else {
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
-      new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+      new GeomAlgoAPI_PaveFiller(aShapesToAdd, true, aFuzzy));
     if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) {
       setError(anError);
       return;
index 4d8705ab5905627a98b93ec6f8a17744a4f7d161..42dff80df439f7fa30c40b2e0b91aadb66620af4 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_BodyBuilder.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 
@@ -33,6 +34,7 @@
 
 #include <sstream>
 
+
 static const std::string INTERSECTION_VERSION_1("v9.5");
 
 //=================================================================================================
@@ -46,6 +48,12 @@ void FeaturesPlugin_Intersection::initAttributes()
   AttributePtr anObjectsAttr = data()->addAttribute(OBJECT_LIST_ID(),
                        ModelAPI_AttributeSelectionList::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);
+
   initVersion(INTERSECTION_VERSION_1, anObjectsAttr, AttributePtr());
 }
 
@@ -60,11 +68,15 @@ void FeaturesPlugin_Intersection::execute()
     return;
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   int aResultIndex = 0;
 
   // Create result.
   const ListOfShape& anObjects = anObjectsHierarchy.objects();
-  GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects));
+  GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects, aFuzzy));
 
   // Checking that the algorithm worked properly.
   std::string anError;
index 0b0dc9d1c2a39de09b157f712d23986991dd4480..08e3e7a72c41db9c845f322ac2c934ae05a4488d 100644 (file)
@@ -48,6 +48,13 @@ public:
     return MY_OBJECT_LIST_ID;
   }
 
+  /// Attribute name of fuzzy parameter.
+  inline static const std::string& FUZZY_PARAM_ID()
+  {
+    static const std::string MY_FUZZY_PARAM_ID("fuzzy_param");
+    return MY_FUZZY_PARAM_ID;
+  }
+
   /// Returns the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
index 46a16c54c80c358dcdbd13136d19a03b457f5418..7e1a77c7a34580d7fa7582f9353ffe36f85fd9c1 100644 (file)
@@ -20,6 +20,7 @@
 #include "FeaturesPlugin_Partition.h"
 
 #include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeSelectionList.h>
@@ -58,6 +59,13 @@ FeaturesPlugin_Partition::FeaturesPlugin_Partition()
 void FeaturesPlugin_Partition::initAttributes()
 {
   data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::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);
+  
   initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
 }
 
@@ -75,6 +83,10 @@ void FeaturesPlugin_Partition::execute()
     return;
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   ListOfShape aBaseObjects = anObjects.objects();
   aBaseObjects.insert(aBaseObjects.end(), aPlanes.begin(), aPlanes.end());
 
@@ -85,7 +97,7 @@ void FeaturesPlugin_Partition::execute()
   // cut unused solids of composolids from the objects of partition
   ListOfShape aTargetObjects, anUnusedSubs;
   std::string aError;
-  if (!cutSubs(anObjects, aTargetObjects, anUnusedSubs, aMakeShapeList, aError)) {
+  if (!cutSubs(anObjects, aTargetObjects, anUnusedSubs, aFuzzy, aMakeShapeList, aError)) {
     setError(aError);
     return;
   }
@@ -93,7 +105,7 @@ void FeaturesPlugin_Partition::execute()
 
   // perform partition first time to split target solids by planes
   std::shared_ptr<GeomAlgoAPI_Partition> aPartitionAlgo(
-      new GeomAlgoAPI_Partition(aTargetObjects, aPlanes));
+      new GeomAlgoAPI_Partition(aTargetObjects, aPlanes, aFuzzy));
 
   // Checking that the algorithm worked properly.
   if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) {
@@ -209,9 +221,9 @@ void FeaturesPlugin_Partition::storeResult(
 
 
 //=================================================================================================
-
 static bool cutSubs(ListOfShape& theSubsToCut,
                     const ListOfShape& theTools,
+                    const double theFuzzy,
                     std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
                     std::string& theError)
 {
@@ -220,7 +232,7 @@ static bool cutSubs(ListOfShape& theSubsToCut,
 
   // cut from current list of solids
   std::shared_ptr<GeomAlgoAPI_MakeShape> aCutAlgo(
-      new GeomAlgoAPI_Boolean(theSubsToCut, theTools, GeomAlgoAPI_Tools::BOOL_CUT));
+      new GeomAlgoAPI_Boolean(theSubsToCut, theTools, GeomAlgoAPI_Tools::BOOL_CUT, theFuzzy));
   if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, "", theError))
     return false;
   theMakeShapeList->appendAlgo(aCutAlgo);
@@ -233,10 +245,12 @@ static bool cutSubs(ListOfShape& theSubsToCut,
   return true;
 }
 
+//=================================================================================================
 bool FeaturesPlugin_Partition::cutSubs(
     GeomAPI_ShapeHierarchy& theHierarchy,
     ListOfShape& theUsed,
     ListOfShape& theNotUsed,
+    const double theFuzzy,
     std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
     std::string& theError)
 {
@@ -272,8 +286,8 @@ bool FeaturesPlugin_Partition::cutSubs(
     else
       aUsed.push_back(*anIt);
 
-    isOk = ::cutSubs(aUsed, aToolsForUsed, theMakeShapeList, theError)
-        && ::cutSubs(aNotUsed, aToolsForUnused, theMakeShapeList, theError);
+    isOk = ::cutSubs(aUsed, aToolsForUsed, theFuzzy, theMakeShapeList, theError)
+        && ::cutSubs(aNotUsed, aToolsForUnused, theFuzzy, theMakeShapeList, theError);
     if (isOk) {
       theUsed.insert(theUsed.end(), aUsed.begin(), aUsed.end());
       theNotUsed.insert(theNotUsed.end(), aNotUsed.begin(), aNotUsed.end());
index 59cd7742106ac0ebe5d6c4e65e8dae56e42b997e..1448ff724a384d8cbfdfb74da12a0d631e9a7aac 100644 (file)
@@ -46,6 +46,13 @@ public:
     return MY_BASE_OBJECTS_ID;
   }
 
+  /// Attribute name of fuzzy parameter.
+  inline static const std::string& FUZZY_PARAM_ID()
+  {
+    static const std::string MY_FUZZY_PARAM_ID("fuzzy_param");
+    return MY_FUZZY_PARAM_ID;
+  }
+
   /// \return the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -76,6 +83,7 @@ private:
   bool cutSubs(GeomAPI_ShapeHierarchy& theHierarchy,
                ListOfShape& theUsed,
                ListOfShape& theNotUsed,
+               const double theFuzzy,
                std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
                std::string& theError);
 };
index 192e15e75157861316f5b7ed32746a673b3e56d3..9627e7bf020b31ccfd74f970b0dbd3c9d3d2a99d 100644 (file)
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_ShapeIterator.h>
 
+#include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
 
+
 //=================================================================================================
 FeaturesPlugin_Union::FeaturesPlugin_Union()
 {
@@ -42,6 +44,13 @@ FeaturesPlugin_Union::FeaturesPlugin_Union()
 void FeaturesPlugin_Union::initAttributes()
 {
   data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::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);
+
   initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
 }
 
@@ -60,6 +69,10 @@ void FeaturesPlugin_Union::execute()
     return;
   }
 
+  // Getting fuzzy parameter.
+  // Used as additional tolerance to eliminate tiny results.
+  double aFuzzy = real(FUZZY_PARAM_ID())->value();
+
   std::string anError;
   int aResultIndex = 0;
   std::vector<ModelAPI_Tools::ResultBaseAlgo> aResultBaseAlgoList;
@@ -81,12 +94,14 @@ void FeaturesPlugin_Union::execute()
       // compsolid handling
       isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_FUSE,
                               anObjects, aParent, anEmptyList, anEmptyList,
+                              aFuzzy,
                               aResultIndex, aResultBaseAlgoList, aResultShapesList,
                               aResultCompound);
     } else {
       // process object as is
       isOk = processObject(GeomAlgoAPI_Tools::BOOL_FUSE,
                            anObject, anEmptyList, anEmptyList,
+                           aFuzzy,
                            aResultIndex, aResultBaseAlgoList, aResultShapesList,
                            aResultCompound);
     }
index 99b7369a583f284a0279486d09e569c889866dfa..52688310af39a332770c2183be40c6d977c22d49 100644 (file)
@@ -43,6 +43,13 @@ public:
     return MY_BASE_OBJECTS_ID;
   }
 
+  /// Attribute name of fuzzy parameter.
+  inline static const std::string& FUZZY_PARAM_ID()
+  {
+    static const std::string MY_FUZZY_PARAM_ID("fuzzy_param");
+    return MY_FUZZY_PARAM_ID;
+  }
+
   /// \return the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
index 3270605e89a77ce0860d9cd05035f060bd242dda..e748063bb52d9d8106c601eeaafed35d0a519569 100644 (file)
 #include <algorithm>
 #include <map>
 
+
+//=================================================================================================
 static void performBoolean(const GeomAlgoAPI_Tools::BOPType theBooleanType,
                            GeomMakeShapePtr& theBooleanAlgo,
                            const ListOfShape& theObjects,
-                           const ListOfShape& theTools)
+                           const ListOfShape& theTools,
+                           const double theFuzzy)
 {
   if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
     theBooleanAlgo.reset(new GeomAlgoAPI_Partition(theObjects, theTools));
@@ -62,11 +65,11 @@ static void performBoolean(const GeomAlgoAPI_Tools::BOPType theBooleanType,
         ListOfShape anObjects = theObjects;
         ListOfShape aTools;
         aTools.splice(aTools.begin(), anObjects, anObjects.begin());
-        theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(anObjects, aTools, theBooleanType));
+        theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(anObjects, aTools, theBooleanType, theFuzzy));
       }
     }
     else
-      theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(theObjects, theTools, theBooleanType));
+      theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(theObjects, theTools, theBooleanType, theFuzzy));
   }
 }
 
@@ -122,6 +125,7 @@ bool FeaturesPlugin_VersionedBoolean::processObject(
     const GeomShapePtr& theObject,
     const ListOfShape& theTools,
     const ListOfShape& thePlanes,
+    const double theFuzzy,
     int& theResultIndex,
     std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
@@ -140,11 +144,12 @@ bool FeaturesPlugin_VersionedBoolean::processObject(
   aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
 
   if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
-    aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
+    aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes, theFuzzy));
   else
     aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
                                             aToolsWithPlanes,
-                                            theBooleanType));
+                                            theBooleanType,
+                                            theFuzzy));
 
   // Checking that the algorithm worked properly.
   std::string anError;
@@ -214,6 +219,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
     const GeomShapePtr& theCompsolid,
     const ListOfShape& theTools,
     const ListOfShape& thePlanes,
+    const double theFuzzy,
     int& theResultIndex,
     std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
@@ -232,7 +238,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
   aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
 
   std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
-  performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationSolids, aToolsWithPlanes);
+  performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationSolids, aToolsWithPlanes, theFuzzy);
 
   // Checking that the algorithm worked properly.
   std::string anError;
@@ -251,7 +257,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompsolid(
     ListOfShape aShapesToAdd = aNotUsedSolids;
     aShapesToAdd.push_back(aBoolAlgo->shape());
     std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
-        new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
+        new GeomAlgoAPI_PaveFiller(aShapesToAdd, true, theFuzzy));
     if (!aFillerAlgo->isDone()) {
       std::string aFeatureError = "Error: PaveFiller algorithm failed.";
       setError(aFeatureError);
@@ -308,6 +314,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompound(
     GeomAPI_ShapeHierarchy& theCompoundHierarchy,
     const GeomShapePtr& theCompound,
     const ListOfShape& theTools,
+    const double theFuzzy,
     int& theResultIndex,
     std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
     ListOfShape& theResultShapesList,
@@ -324,7 +331,7 @@ bool FeaturesPlugin_VersionedBoolean::processCompound(
 
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
   std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
-  performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationShapes, theTools);
+  performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationShapes, theTools, theFuzzy);
 
   // Checking that the algorithm worked properly.
   std::string anError;
index eb5336fa1227e765e5e059267e8802868219721c..e589457332c6228b87f8d513b965afb64c35ba58 100644 (file)
@@ -70,6 +70,7 @@ protected:
                      const GeomShapePtr& theObject,
                      const ListOfShape& theTools,
                      const ListOfShape& thePlanes,
+                     const double theFuzzy,
                      int& theResultIndex,
                      std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                      ListOfShape& theResultShapesList,
@@ -84,6 +85,7 @@ protected:
                         const GeomShapePtr& theCompsolid,
                         const ListOfShape& theTools,
                         const ListOfShape& thePlanes,
+                        const double theFuzzy,
                         int& theResultIndex,
                         std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                         ListOfShape& theResultShapesList,
@@ -97,6 +99,7 @@ protected:
                        GeomAPI_ShapeHierarchy& theCompoundHierarchy,
                        const GeomShapePtr& theCompound,
                        const ListOfShape& theTools,
+                       const double theFuzzy,
                        int& theResultIndex,
                        std::vector<ModelAPI_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
                        ListOfShape& theResultShapesList,
index 18459cc64986f9545efb321e7ef422e274edc84f..41fa7dca7e680655f889a68c332aa2810d20c982 100644 (file)
       <translation>Objets outils</translation>
     </message>
   </context>
+  <context>
+    <name>Common:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
   <context>
     <name>Model_Data</name>
     <message>
       <translation>Objets outils</translation>
     </message>
   </context>
+  <context>
+    <name>Cut:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Split -->
   <context>
       <translation>Objets outils</translation>
     </message>
   </context>
+  <context>
+    <name>Fuse:fuzzy_param</name>
+    <message>
+      <source>Fuzzy Parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- FusionFaces -->
   <context>
       <translation>Sélectionner des objets.</translation>
     </message>
   </context>
+  <context>
+    <name>Intersection:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Partition -->
   <context>
       <translation>Sélectionner des objets pour le partitionnement.</translation>
     </message>
   </context>
+  <context>
+    <name>Partition:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Pipe -->
   <context>
       <translation>Objets outils</translation>
     </message>
   </context>
+  <context>
+    <name>Smash:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Split -->
   <context>
       <translation>Objets outils</translation>
     </message>
   </context>
+  <context>
+    <name>Split:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Union -->
   <context>
       <translation>Sélectionner les solides pour la réunion.</translation>
     </message>
   </context>
+  <context>
+    <name>Union:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
 
   <!-- Validators -->
 
       <translation>La forme sélectionnée est du mauvais type.</translation>
     </message>
   </context>
+  <context>
+    <name>Boolean:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Paramètre flou</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Tolérance supplémentaire pour éliminer les petits résultats.</translation>
+    </message>
+  </context>
   <context>
     <name>Boolean:GeomValidators_BooleanArguments</name>
     <message>
index 3b2c6196a0ee6f4825c447f82fdf3ade474160f2..d04a6bd01912df773b85f625ba1131fde687ffa7 100644 (file)
     <message>
       <source>Error: Empty shape.</source>
       <translation>Выбранные вспомогательные объекты невалидны.</translation>
-  </message>
+    </message>
     <message>
       <source>Error: Local selection not allowed.</source>
       <translation>Локальная селекция запрещена.</translation>
       <translation>Выбраныне вспомогательные объекты имеют недопустимый тип.</translation>
     </message>
   </context>
+  <context>
+    <name>Boolean:fuzzy_param</name>
+    <message>
+      <source>Fuzzy parameter</source>
+      <translation>Нечеткий параметр</translation>
+    </message>
+    <message>
+      <source>Additional tolerance to eliminate tiny result.</source>
+      <translation>Дополнительный допуск для устранения крошечного результата.</translation>
+    </message>
+  </context>
   <context>
     <name>Boolean:GeomValidators_BooleanArguments</name>
     <message>
diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Fuzzy.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Fuzzy.py
new file mode 100644 (file)
index 0000000..9d01e24
--- /dev/null
@@ -0,0 +1,80 @@
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+  GeomAPI_Shape.SOLID:  "GeomAPI_Shape.SOLID",
+  GeomAPI_Shape.FACE:   "GeomAPI_Shape.FACE",
+  GeomAPI_Shape.EDGE:   "GeomAPI_Shape.EDGE",
+  GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+  """ Tests number of unique feature sub-shapes of passed type for each result.
+  :param theFeature: feature to test.
+  :param theShapeType: shape type of sub-shapes to test.
+  :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+  """
+  aResults = theFeature.feature().results()
+  aNbResults = len(aResults)
+  aListSize = len(theExpectedNbSubShapes)
+  assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+  for anIndex in range(0, aNbResults):
+    aNbResultSubShapes = 0
+    anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+    aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+    assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_fuzzy = model.addParameter(Part_1_doc, "fuzzy", '1e-06')
+
+### Create Sphere
+Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 5)
+
+### Create Point
+Point_2 = model.addPoint(Part_1_doc, 9.999995, 0, 0)
+
+### Create Sphere
+Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_1"), 5)
+
+### Create Common
+Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Sphere_2_1"), model.selection("SOLID", "Sphere_1_1")], fuzzyParam = "fuzzy", keepSubResults = True)
+model.do()
+
+model.testNbResults(Common_1, 1)
+model.testNbSubResults(Common_1, [0])
+testNbUniqueSubShapes(Common_1, GeomAPI_Shape.SOLID, [1])
+testNbUniqueSubShapes(Common_1, GeomAPI_Shape.FACE, [3])
+testNbUniqueSubShapes(Common_1, GeomAPI_Shape.EDGE, [3])
+testNbUniqueSubShapes(Common_1, GeomAPI_Shape.VERTEX, [2])
+
+### Set a higher fuzzy value
+Param_fuzzy.setValue(1.e-5)
+model.do()
+
+model.end()
+
+model.testNbResults(Common_1, 0)
+
+model.end()
diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_1.py b/src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_1.py
new file mode 100644 (file)
index 0000000..d880a32
--- /dev/null
@@ -0,0 +1,89 @@
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+  GeomAPI_Shape.SOLID:  "GeomAPI_Shape.SOLID",
+  GeomAPI_Shape.FACE:   "GeomAPI_Shape.FACE",
+  GeomAPI_Shape.EDGE:   "GeomAPI_Shape.EDGE",
+  GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+  """ Tests number of unique feature sub-shapes of passed type for each result.
+  :param theFeature: feature to test.
+  :param theShapeType: shape type of sub-shapes to test.
+  :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+  """
+  aResults = theFeature.feature().results()
+  aNbResults = len(aResults)
+  aListSize = len(theExpectedNbSubShapes)
+  assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+  for anIndex in range(0, aNbResults):
+    aNbResultSubShapes = 0
+    anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+    aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+    assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_offset = model.addParameter(Part_1_doc, "offset", '5e-5')
+Param_fuzzy = model.addParameter(Part_1_doc, "fuzzy", '1e-05')
+
+### Create Point
+Point_2 = model.addPoint(Part_1_doc, "offset", "5", "5")
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+Box_1.result().setColor(255, 0, 0)
+
+### Create Cylinder
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 6, 13)
+Cylinder_1.result().setColor(255, 255, 0)
+Cylinder_1.result().setTransparency(0.6)
+
+### Create Cut
+Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SOLID", "Cylinder_1_1")], fuzzyParam = "fuzzy", keepSubResults = True)
+model.do()
+
+model.testNbResults(Cut_1, 1)
+model.testNbSubResults(Cut_1, [0])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [1])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [14])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
+model.testResultsVolumes(Cut_1, [49.093623770546])
+
+### Set a higher fuzzy value
+Param_fuzzy.setValue(5.e-5)
+model.do()
+
+model.end()
+
+model.testNbResults(Cut_1, 1)
+model.testNbSubResults(Cut_1, [4])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [20])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [24])
+model.testResultsVolumes(Cut_1, [49.088834629314])
diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_2.py b/src/FeaturesPlugin/Test/TestBooleanCut_Fuzzy_2.py
new file mode 100644 (file)
index 0000000..61a2642
--- /dev/null
@@ -0,0 +1,132 @@
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+  GeomAPI_Shape.SOLID:  "GeomAPI_Shape.SOLID",
+  GeomAPI_Shape.FACE:   "GeomAPI_Shape.FACE",
+  GeomAPI_Shape.EDGE:   "GeomAPI_Shape.EDGE",
+  GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+  """ Tests number of unique feature sub-shapes of passed type for each result.
+  :param theFeature: feature to test.
+  :param theShapeType: shape type of sub-shapes to test.
+  :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+  """
+  aResults = theFeature.feature().results()
+  aNbResults = len(aResults)
+  aListSize = len(theExpectedNbSubShapes)
+  assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+  for anIndex in range(0, aNbResults):
+    aNbResultSubShapes = 0
+    anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+    aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+    assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_fuzzy = model.addParameter(Part_1_doc, "fuzzy", '1e-07')
+
+### Create Point
+Point_2 = model.addPoint(Part_1_doc, 5, 9.9999, 0)
+
+### Create Point
+Point_3 = model.addPoint(Part_1_doc, 10, 10, 0)
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(5, 0, 0, 0)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
+SketchLine_2 = Sketch_1.addLine(0, 0, 0, 9.9999)
+SketchLine_3 = Sketch_1.addLine(0, 9.9999, 5, 9.9999)
+SketchLine_4 = Sketch_1.addLine(5, 9.9999, 5, 0)
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+Sketch_1.setHorizontal(SketchLine_1.result())
+Sketch_1.setVertical(SketchLine_2.result())
+Sketch_1.setHorizontal(SketchLine_3.result())
+Sketch_1.setVertical(SketchLine_4.result())
+SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "Point_1"), False)
+SketchPoint_2 = SketchProjection_2.createdFeature()
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchPoint_2.result())
+SketchProjection_3 = Sketch_1.addProjection(model.selection("VERTEX", "Point_2"), False)
+SketchPoint_3 = SketchProjection_3.createdFeature()
+model.do()
+
+### Create Sketch
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_5 = Sketch_2.addLine(10, 0, 0, 0)
+SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_4 = SketchProjection_4.createdFeature()
+Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchPoint_4.result())
+SketchLine_6 = Sketch_2.addLine(0, 0, 0, 10)
+SketchLine_7 = Sketch_2.addLine(0, 10, 10, 10)
+SketchLine_8 = Sketch_2.addLine(10, 10, 10, 0)
+Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint())
+Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+Sketch_2.setHorizontal(SketchLine_5.result())
+Sketch_2.setVertical(SketchLine_6.result())
+Sketch_2.setHorizontal(SketchLine_7.result())
+Sketch_2.setVertical(SketchLine_8.result())
+SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "Point_2"), False)
+SketchPoint_5 = SketchProjection_5.createdFeature()
+Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchPoint_5.result())
+model.do()
+
+### Create Face
+Face_1 = model.addFace(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")])
+Face_1.result().setColor(255, 0, 0)
+
+### Create Face
+Face_2 = model.addFace(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")])
+Face_2.result().setColor(0, 255, 0)
+
+### Create Cut
+Cut_1 = model.addCut(Part_1_doc, [model.selection("FACE", "Face_2_1")], [model.selection("FACE", "Face_1_1")], fuzzyParam = "fuzzy", keepSubResults = True)
+model.do()
+
+model.testNbResults(Cut_1, 1)
+model.testNbSubResults(Cut_1, [0])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [6])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [6])
+
+### Set a higher fuzzy value
+Param_fuzzy.setValue(1.e-4)
+model.do()
+
+model.end()
+
+model.testNbResults(Cut_1, 1)
+model.testNbSubResults(Cut_1, [0])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.FACE, [1])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.EDGE, [4])
+testNbUniqueSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4])
diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Fuzzy.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Fuzzy.py
new file mode 100644 (file)
index 0000000..6a85356
--- /dev/null
@@ -0,0 +1,85 @@
+# 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+from GeomAPI import GeomAPI_Shape
+
+aShapeTypes = {
+  GeomAPI_Shape.SOLID:  "GeomAPI_Shape.SOLID",
+  GeomAPI_Shape.FACE:   "GeomAPI_Shape.FACE",
+  GeomAPI_Shape.EDGE:   "GeomAPI_Shape.EDGE",
+  GeomAPI_Shape.VERTEX: "GeomAPI_Shape.VERTEX"}
+
+def testNbUniqueSubShapes(theFeature, theShapeType, theExpectedNbSubShapes):
+  """ Tests number of unique feature sub-shapes of passed type for each result.
+  :param theFeature: feature to test.
+  :param theShapeType: shape type of sub-shapes to test.
+  :param theExpectedNbSubShapes: list of sub-shapes numbers. Size of list should be equal to len(theFeature.results()).
+  """
+  aResults = theFeature.feature().results()
+  aNbResults = len(aResults)
+  aListSize = len(theExpectedNbSubShapes)
+  assert (aNbResults == aListSize), "Number of results: {} not equal to list size: {}.".format(aNbResults, aListSize)
+  for anIndex in range(0, aNbResults):
+    aNbResultSubShapes = 0
+    anExpectedNbSubShapes = theExpectedNbSubShapes[anIndex]
+    aNbResultSubShapes = aResults[anIndex].shape().subShapes(theShapeType, True).size()
+    assert (aNbResultSubShapes == anExpectedNbSubShapes), "Number of sub-shapes of type {} for result[{}]: {}. Expected: {}.".format(aShapeTypes[theShapeType], anIndex, aNbResultSubShapes, anExpectedNbSubShapes)
+
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Param_fuzzy = model.addParameter(Part_1_doc, "fuzzy", '1e-07')
+
+Point_2 = model.addPoint(Part_1_doc, 10, 0, 0)
+Point_3 = model.addPoint(Part_1_doc, 20, 10.0001, 10.0001)
+
+### Create Box
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+
+### Create Box
+Box_2 = model.addBox(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2"))
+
+### Create Fuse
+Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")], fuzzyParam = "fuzzy", keepSubResults = True)
+model.do()
+
+model.testNbResults(Fuse_1, 1)
+model.testNbSubResults(Fuse_1, [0])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [11])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [24])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [15])
+model.testResultsVolumes(Fuse_1, [2000.02000010])
+
+### Set a higher fuzzy value
+Param_fuzzy.setValue(1.e-4)
+model.do()
+
+model.end()
+
+model.testNbResults(Fuse_1, 1)
+model.testNbSubResults(Fuse_1, [0])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.FACE, [10])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [20])
+testNbUniqueSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [12])
+model.testResultsVolumes(Fuse_1, [2000.02166677])
index ebf6cf1b11d9260112419c4ef93c9ac9b00e4fb4..c34682a3d8a5298caecd5d48c378271e65deed28 100644 (file)
       </multi_selector>
     </box>
   </toolbox>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="FeaturesPlugin_ValidatorBooleanCommonArguments"
              parameters="main_objects,tool_objects"/>
 </source>
index 8617460db436c417b70d714f97e6c2ee231be99a..1e9635a600483173ce1aa22a205fde8ff11f8343 100644 (file)
       </multi_selector>
     </box>
   </toolbox>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <boolvalue id="remove_intersection_edges"
            label="Remove intersection edges"
            tooltip="Remove intersection edges if they laying on the same surface"
index 07abf751d819cab11ba71ce0276c778be356793e..c7077ef4176823d575c70be8e7426da362acf885 100644 (file)
     <validator id="PartSet_DifferentObjects"/>
     <validator id="FeaturesPlugin_ValidatorBooleanSmashSelection"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="FeaturesPlugin_ValidatorBooleanArguments" parameters="main_objects,tool_objects"/>
 </source>
index 2131c8dda7e2e6ed0f978be6b6771082decae8f9..7db9399c154e514280e0cf05b62751c3858141ba 100644 (file)
     <validator id="PartSet_DifferentObjects"/>
     <validator id="FeaturesPlugin_ValidatorBooleanSelection"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="FeaturesPlugin_ValidatorBooleanArguments" parameters="main_objects,tool_objects"/>
 </source>
index dca9d22a906ef1ca8133c66aba4441940638d82a..222e8007e9f495899875f1fc9880ff704a1b6bf5 100644 (file)
     <validator id="PartSet_DifferentObjects"/>
     <validator id="FeaturesPlugin_ValidatorBooleanSelection"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-5"
+                  default="1.e-5">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="FeaturesPlugin_ValidatorBooleanArguments" parameters="main_objects,tool_objects"/>
   <validator id="GeomValidators_NotSelfIntersected" parameters="main_objects,tool_objects"/>
 </source>
index ad2f3c3071de9a7f45048d330305ba7f323c5ac4..1de32398b3944ed390bb70a6e40bfb60844ae004 100644 (file)
@@ -68,3 +68,8 @@ Construction planes (mentioned PLANE) can be used in several operations, but not
 | |union.icon|            | 3 (SOLIDs from COMPSOLID) |          ---            |
 | :ref:`featureUnion`     |                           |                         |
 +-------------------------+---------------------------+-------------------------+
+
+The fuzzy parameter of each boolean operation is used as an additional tolerance to eliminate tiny results.
+
+*Note*: If a value is given, which is smaller than the lowest meaningful tolerance of 1.e-7, the boolean operation
+will use the default internal fuzzy parameter.
index a63df77cde3807f9e462a5357456a6521d85a149..e96f00124c23705683f43e06675d741ee0daac71 100644 (file)
@@ -39,14 +39,16 @@ Simple
 
 - **Objects** contains a list of objects selected in the Object Browser or in the Viewer.
   If a subshape that belongs to a compsolid/compound was selected, other shapes of this compsolid/compound will be ignored.
+- **Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
 - **See preview** button shows a result of the operation.
 
 **TUI Command**:
 
-.. py:function:: model.addCommon(Part_doc, objects)
+.. py:function:: model.addCommon(Part_doc, objects, fuzzy)
 
     :param part: The current part object
     :param list: A list of objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object
 
 Result
@@ -74,17 +76,19 @@ Advanced
   other objects (to avoid self-intersection) and added to the result.
 - **Tools** contains a list of objects selected in the Object Browser or in the Viewer, which will be intersected with tool objects.
   If a subshape that belongs to a compsolid/compound was selected, other shapes of this compsolid/compound will be ignored.
+- **Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
 - **See preview** button shows a result of the operation.
 
 Any kind of shape is supported as an object or a tool of Common. Moreover, constructions planes can be selected as tools.
 
 **TUI Command**:
 
-.. py:function:: model.addCommon(Part_doc, objects, tools)
+.. py:function:: model.addCommon(Part_doc, objects, tools, fuzzy)
 
     :param part: The current part object
     :param list: A list of objects.
     :param list: A list of tools.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object
 
 Result
index 9ce390dbedba97e2dc95eb56f0d5f133f23368d9..6fe34e58e6e33a013fda4df49af49094fb657f09 100644 (file)
@@ -26,17 +26,19 @@ The following property panel will be opened:
 - **Tool Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will cut main objects.
   Any kind of shape can be selected, including subshapes of compsolids/compounds.
   Non-selected subshapes from compsolids/compounds will be ignored.
+- **Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
 - **See preview** button shows a result of the operation.
 
 The minimal dimension of Tool Objects should be not less than the maximal dimension of Main Objects.
 
 **TUI Command**:
 
-.. py:function:: model.addCut(Part_doc, mainObjects, toolObjects)
+.. py:function:: model.addCut(Part_doc, mainObjects, toolObjects, fuzzy)
 
     :param part: The current part object
     :param list: A list of main objects.
     :param list: A list of tool objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object
 
 Result
index e9fb6962038e9fab32b94eec145cfda863177b08..e3bed71144e86d1ce8f4a92f5c0ed5845be09510 100644 (file)
@@ -40,15 +40,17 @@ Simple
 - **Objects** - contains a list of objects selected in the Object Browser or in the Viewer, which will be fused to a single result.
   If a subshape that belongs to a compsolid/compound was selected, other shapes of this compsolid/compound will cut the fuse shape then will be joined to the result.
 - **Remove intersection edges** -  if enabled, edges that lie on the same surface will be removed.
+- **Fuzzy Parameter** - defines the additional tolerance value used to eliminate tiny results.
 - **See preview** - button shows a result of the operation.
 
 **TUI Command**:
 
-.. py:function:: model.addFuse(Part_doc, objects, isRemoveEdges)
+.. py:function:: model.addFuse(Part_doc, objects, isRemoveEdges, fuzzyParam)
 
     :param part: The current part object.
     :param list: A list of objects.
     :param boolean: Remove edges flag (optional).
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object.
 
 Result
@@ -77,16 +79,18 @@ Advanced
 - **Tools** - contains a list of objects selected in the Object Browser or in the Viewer, which will be fused with tool objects.
   If a subshape that belongs to a compsolid/compound was selected, other shapes of this compsolid/compound will be ignored.
 - **Remove intersection edges** - if enabled, edges that lie on the same surface will be removed.
+- **Fuzzy Parameter** - defines the additional tolerance value used to eliminate tiny results.
 - **See preview** - button shows a result of the operation.
 
 **TUI Command**:
 
-.. py:function:: model.addFuse(Part_doc, objects, tools, isRemoveEdges)
+.. py:function:: model.addFuse(Part_doc, objects, tools, isRemoveEdges, fuzzyParam)
 
     :param part: The current part object.
     :param list: A list of objects.
     :param list: A list of tools.
     :param boolean: Remove edges flag (optional).
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object.
 
 Result
index 70fb721a2fcd00a43c577092d2af54d887be3174..02499b2b9c4bd333f1dac95d40af5d5c15e86d56 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/Partition.png and b/src/FeaturesPlugin/doc/images/Partition.png differ
index 2104b03818bda68478f2f2733112736fdb565468..1bcebe21624c5659412b6027cf0766101d210d5d 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/Smash.png and b/src/FeaturesPlugin/doc/images/Smash.png differ
index 7673ef4a3000d58972f4becabda5b5120d7b0b3a..7d80c5f846b2960c06cd85c374395e0323b9ceda 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/Split_panel.png and b/src/FeaturesPlugin/doc/images/Split_panel.png differ
index 3a28dcb4642a77dab9c5f9e73e04ca3dcff2ca18..879ea0075c50c7da1572cc98003fa149b50bee23 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/boolean_common_advanced_property_panel.png and b/src/FeaturesPlugin/doc/images/boolean_common_advanced_property_panel.png differ
index 3a7577ee860ddd4aaa5d0b6c5c00f06068eaa8ec..0a592579c5af748dc5f8e8c5bd03d926d5aac041 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/boolean_common_simple_property_panel.png and b/src/FeaturesPlugin/doc/images/boolean_common_simple_property_panel.png differ
index ba79dd1421209bc575bdd7c154dca6943a7fd6e6..696067fd43e90734135ff41b2108eae8c552417a 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/boolean_cut_property_panel.png and b/src/FeaturesPlugin/doc/images/boolean_cut_property_panel.png differ
index 6c218f94cd82db049ac568bb5a9a82e3cb74b664..4dd19cba08de6d6379e33857a9e8626618f5c52d 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/boolean_fuse_advanced_property_panel.png and b/src/FeaturesPlugin/doc/images/boolean_fuse_advanced_property_panel.png differ
index 48b017ef297ff4e14f5b1fd3073b622d8bd62933..069eb59da67e89b618b6bb2225939039ff25eb83 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/boolean_fuse_simple_property_panel.png and b/src/FeaturesPlugin/doc/images/boolean_fuse_simple_property_panel.png differ
index d3fd35333e1cdcb208ba57c2c04fce90226b6f4a..b439ac3e49ab24bf91a6d0e2efb740d34561bf75 100644 (file)
Binary files a/src/FeaturesPlugin/doc/images/intersection_property_panel.png and b/src/FeaturesPlugin/doc/images/intersection_property_panel.png differ
index e4057a2d56d59162bb03ba492c9b4319fdbde5ce..20731bb07772357fd5bb4fb928afbf87224dc383 100644 (file)
@@ -19,16 +19,20 @@ The following property panel will be opened:
 
    **Intersection operation**
 
-**Objects** - contains a list of objects selected in the Object Browser or in the Viewer, which will be intersected.
+**Objects** - contains a list of objects selected in the Object Browser or in the Viewer, which will be intersected. 
 
-All intersected objects should be 1- or 2-dimensional (edges, faces, shells). However, it is allowed to select 3-dimensional objects, but only their shells will be taken into operation.
+**Fuzzy Parameter** - defines the additional tolerance value used to eliminate tiny results. 
+
+All intersected objects should be 1- or 2-dimensional (edges, faces, shells). However, it is allowed to select 
+3-dimensional objects, but only their shells will be taken into operation.
 
 **TUI Command**:
 
-.. py:function:: model.addIntersection(Part_doc, Objects)
+.. py:function:: model.addIntersection(Part_doc, Objects, fuzzy)
 
     :param part: The current part object.
     :param list: A list of objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object.
 
 Result
index e549310d23a91213349f9609d1977891f1aad81c..1e8f3f34d10c551a92dae9632c18fe4cd24dd479 100644 (file)
@@ -19,14 +19,19 @@ The following property panel will be opened:
 
    **Partition operation**
 
-**Base Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will be partitioned. Constuction planes are allowed too if at least one non-construction entity is selected.
+**Base Objects** contains a list of objects selected in the Object Browser or in the Viewer,
+which will be partitioned. Constuction planes are allowed too if at least one non-construction
+entity is selected.
+
+**Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results. 
 
 **TUI Command**:
 
-.. py:function:: model.addPartition(Part_doc, objects)
+.. py:function:: model.addPartition(Part_doc, objects, fuzzy)
 
     :param part: The current part object.
     :param object: A list of objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Created object.
 
 Result
index 2e3b45828ab3cf0674d2fce36972cb2afc3ffc1a..da77ad4432c39e8d3f016f71471601d0926e8b57 100644 (file)
@@ -25,17 +25,19 @@ The following property panel will be opened:
   other objects (to avoid self intersection) and added to the result.
 - **Tool Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will be smashed into main objects.
   If a subshape that belongs to a compsolid/compound was selected, other shapes of this compsolid/compound will be ignored.
+- **Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
 - **See preview** button shows a result of the operation.
 
 Main objects and Tools objects should have the same dimension. There are supported 2-dimensional (face) or 3-dimensional (solid, compsolid) arguments.
 
 **TUI Command**:
 
-.. py:function:: model.addSmash(Part_doc, mainObjects, toolObjects)
+.. py:function:: model.addSmash(Part_doc, mainObjects, toolObjects, fuzzy)
 
     :param part: The current part object.
     :param list: A list of main objects.
     :param list: A list of tool objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Rotated object.
 
 Result
index d31bee857268e2334b31dacd185c88deb8d5d84e..eb5c49217d17a79221ecbaf49e8ed489dd6f1890 100644 (file)
@@ -22,15 +22,17 @@ The following property panel will be opened:
 
 - **Main Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will be cut and splitted by tool objects.
 - **Tool Objects** contains a list of objects selected in the Object Browser or in the Viewer, which will cut and split the main objects. Construction planes may be selected too.
+- **Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
 - **See preview** button shows a result of the operation.
 
 **TUI Command**:
 
-.. py:function:: model.addSplit(Part_doc, mainObjects, toolObjects)
+.. py:function:: model.addSplit(Part_doc, mainObjects, toolObjects, fuzzy)
 
     :param part: The current part object.
     :param list: A list of main objects.
     :param list: A list of tool objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Result object.
 
 Result
index 9847642861d1b33872d3dba9a5149dc500796708..8bb04da461ae867eb284a8f536ea38e8621a40a0 100644 (file)
@@ -23,16 +23,19 @@ The following property panel will be opened:
 
 Here it is necessary to select some objects. Only faces with shared edges or solids with shared faces are allowed for selection.
 
+**Fuzzy Parameter** defines the additional tolerance value used to eliminate tiny results.
+
 **Apply** button creates a union shape.
   
 **Cancel** button cancels the operation.
 
 **TUI Command**:
 
-.. py:function:: model.addUnion(Part_doc, objects)
+.. py:function:: model.addUnion(Part_doc, objects, fuzzy)
 
     :param part: The current part object.
     :param objects: A list of objects.
+    :param real: Additional tolerance used to eliminate tiny results (optional).
     :return: Result object.
 
 Result
index bc07db63046ca749af016817d7f0c361d1938bd4..bafcf13285f91fb1cf482ae40c2cda4c57012f62 100644 (file)
@@ -9,4 +9,15 @@
     <validator id="PartSet_DifferentObjects"/>
     <validator id="FeaturesPlugin_IntersectionSelection"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
 </source>
index ad5e97ef545f4fdd06c5ec8c5a428ca1f2992a03..6a2eda74342c6879396b360143ffb31bd3b0b916 100644 (file)
@@ -7,5 +7,16 @@
     clear_in_neutral_point="false">
     <validator id="FeaturesPlugin_ValidatorPartitionSelection" parameters="Plane"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="GeomValidators_MinObjectsSelected" parameters="base_objects,1"/>
 </source>
index 3186ba3687058673f4665435d960b457bffe2273..75aabe51e61e879e3fb6d328cf13c6460676e9bc 100644 (file)
@@ -538,6 +538,10 @@ SET(TEST_NAMES_PARA
                TestGlueFaces_Solids.py
                TestLimitTolerance.py
                TestLimitTolerance_Face.py
+               TestBooleanCut_Fuzzy_1.py
+               TestBooleanCut_Fuzzy_2.py
+               TestBooleanFuse_Fuzzy.py
+               TestBooleanCommon_Fuzzy.py
 )
 
 SET(TEST_NAMES_SEQ
index 6bbc3239554fb3474ea8809f4a886c5ed2e23858..f8676877b8e6fb9760eb48a67080199b0177befb 100644 (file)
@@ -7,6 +7,17 @@
     concealment="true">
     <validator id="FeaturesPlugin_ValidatorUnionSelection"/>
   </multi_selector>
+  <groupbox>
+    <doublevalue id="fuzzy_param"
+                  label="Fuzzy parameter"
+                  tooltip="Additional tolerance to eliminate tiny result."
+                  min="1.e-7"
+                  max="10"
+                  step="1.e-7"
+                  default="1.e-7">
+      <validator id="GeomValidators_Positive"/>
+    </doublevalue>
+  </groupbox>
   <validator id="GeomValidators_MinObjectsSelected" parameters="base_objects,2"/>
   <validator id="FeaturesPlugin_ValidatorUnionArguments"/>
 </source>
index 2812b0ee19745ece8280b8265c68f6616c0b5baa..6e3c60df1b0729ed54285d2f353b71679ecfb796 100644 (file)
 #include <TopoDS_Iterator.hxx>
 #include <TopExp_Explorer.hxx>
 
+
 //=================================================================================================
 GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const GeomShapePtr theObject,
                                          const GeomShapePtr theTool,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType)
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy/*= 1.e-8*/)
 {
   ListOfShape aListWithObject, aListWithTool;
   aListWithObject.push_back(theObject);
   aListWithTool.push_back(theTool);
-  build(aListWithObject, aListWithTool, theOperationType);
+  build(aListWithObject, aListWithTool, theOperationType, theFuzzy);
 }
 
 //=================================================================================================
 GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const GeomShapePtr theObject,
                                          const ListOfShape& theTools,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType)
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy/*= 1.e-8*/)
 {
   ListOfShape aListWithObject;
   aListWithObject.push_back(theObject);
-  build(aListWithObject, theTools, theOperationType);
+  build(aListWithObject, theTools, theOperationType, theFuzzy);
 }
 
 //=================================================================================================
 GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
                                          const ListOfShape& theTools,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType)
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy/*= 1.e-8*/)
 {
-  build(theObjects, theTools, theOperationType);
+  build(theObjects, theTools, theOperationType, theFuzzy);
 }
 
 
 //=================================================================================================
 void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
                                 const ListOfShape& theTools,
-                                const GeomAlgoAPI_Tools::BOPType theOperationType)
+                                const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                const double theFuzzy)
 {
-  if(theObjects.empty() || theTools.empty()) {
+  if (theObjects.empty() || theTools.empty()) {
     return;
   }
 
@@ -111,7 +116,9 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
   aBuilder->SetRunParallel(bRunParallel);
 
   // Set fuzzy value to eliminate thin results
-  static const Standard_Real aFuzzy = 1.e-5;
+  // => Either use the value set by the user (greater or equal than minimum valid value 1.e-7)
+  // => or use the old default value of 1.e-5
+  Standard_Real aFuzzy = (theFuzzy >= 1.e-7 ? theFuzzy : 1.e-5);
   aBuilder->SetFuzzyValue(aFuzzy);
 
   // Building and getting result.
@@ -139,11 +146,13 @@ void GeomAlgoAPI_Boolean::build(const ListOfShape& theObjects,
   this->setDone(true);
 }
 
+//=================================================================================================
 static bool isHistoryType(TopAbs_ShapeEnum theType) {
   return theType == TopAbs_VERTEX || theType == TopAbs_EDGE ||
          theType == TopAbs_FACE || theType == TopAbs_SOLID;
 }
 
+//=================================================================================================
 /// searches the corresponding result for theOld
 static void searchResult(const TopoDS_Shape& theOld, const TopoDS_Shape& theResult,
   BOPAlgo_BOP* theBuilder, TopTools_MapOfShape& theNews)
@@ -179,6 +188,7 @@ static void searchResult(const TopoDS_Shape& theOld, const TopoDS_Shape& theResu
   }
 }
 
+//=================================================================================================
 // check the shape is on the higher level of compound or compsolid
 bool isInComp(const TopoDS_Shape& theComp, const TopoDS_Shape& theShape) {
   if (theComp.ShapeType() == TopAbs_COMPOUND || theComp.ShapeType() == TopAbs_COMPSOLID) {
index f1c86be083ccf8f572e6bc592a0ba39b2eb0e976..0182ff054fa9d575b031dcf6ba57a9a802dd35ba 100644 (file)
@@ -34,20 +34,41 @@ class GeomAlgoAPI_Boolean : public GeomAlgoAPI_MakeShape
 public:
 
   /// Constructor.
+  /// \param[in] theObject the main object.
+  /// \param[in] theTool the tool object.
+  /// \param[in] theOperationType type of boolean operation.
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            boolean operation will use a default additional tolerance value of 1.e-5.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const GeomShapePtr theObject,
                                          const GeomShapePtr theTool,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType);
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy = 1.e-8);
 
   /// Constructor.
+  /// \param[in] theObject the main object.
+  /// \param[in] theTools list of tools.
+  /// \param[in] theOperationType type of boolean operation.
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            boolean operation will use a default additional tolerance value of 1.e-5.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const GeomShapePtr theObject,
                                          const ListOfShape& theTools,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType);
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy = 1.e-8);
 
 
   /// Constructor.
+  /// \param[in] theObjects list of main objects.
+  /// \param[in] theTools list of tools.
+  /// \param[in] theOperationType type of boolean operation.
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            boolean operation will use a default additional tolerance value of 1.e-5.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const ListOfShape& theObjects,
                                          const ListOfShape& theTools,
-                                         const GeomAlgoAPI_Tools::BOPType theOperationType);
+                                         const GeomAlgoAPI_Tools::BOPType theOperationType,
+                                         const double theFuzzy = 1.e-8);
 
   /// Redefinition of the generic method for the Fuse problem: OCCT 30481
   GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape,
@@ -57,7 +78,8 @@ private:
   /// Builds resulting shape.
   void build(const ListOfShape& theObjects,
              const ListOfShape& theTools,
-             const GeomAlgoAPI_Tools::BOPType theOperationType);
+             const GeomAlgoAPI_Tools::BOPType theOperationType,
+             const double theFuzzy);
 };
 
 #endif
index 4958c32485b79efa5a649bdab5a03f1e441a9d6f..8ab6a1b07dfdc14c465c10da63f8c777bfe4c608 100644 (file)
 #include <BOPAlgo_PaveFiller.hxx>
 #include <BOPAlgo_Section.hxx>
 
+
 //==================================================================================================
-GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects)
+GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects, const double theFuzzy)
   : myFiller(0)
 {
-  build(theObjects);
+  build(theObjects, theFuzzy);
 }
 
+//==================================================================================================
 GeomAlgoAPI_Intersection::~GeomAlgoAPI_Intersection() {
   if (myFiller)
     delete (BOPAlgo_PaveFiller*)myFiller;
 }
+
 //==================================================================================================
-void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects)
+void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects, const double theFuzzy)
 {
   if (theObjects.empty()) {
     return;
@@ -64,6 +67,7 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects)
   aDSFiller->SetRunParallel(false);
   aDSFiller->SetNonDestructive(false);
   aDSFiller->SetGlue(BOPAlgo_GlueOff);
+  if (theFuzzy >= 1.e-7) aDSFiller->SetFuzzyValue(theFuzzy);
 
   // optimization for the issue #2399
   BOPAlgo_SectionAttribute theSecAttr(Standard_True,
@@ -79,6 +83,7 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects)
   anOperation->SetArguments(anObjects);
   anOperation->SetRunParallel(false);
   anOperation->SetCheckInverted(true);
+  if (theFuzzy >= 1.e-7) anOperation->SetFuzzyValue(theFuzzy);
 
   anOperation->PerformWithFiller(*aDSFiller); // it references a filler fields, so keep the filler
   myFiller = 0;
index 8762e2c0ab6919a3288af70fdb051519ac19ac6f..39228ebc370d05176ae04732dd64e5b6da03550f 100644 (file)
@@ -34,15 +34,18 @@ class GeomAlgoAPI_Intersection : public GeomAlgoAPI_MakeShape
 public:
   /// \brief Constructor.
   /// \param[in] theObjects list of objects.
-  /// \param[in] theTools list of tools.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Intersection(const ListOfShape& theObjects);
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            algorithm will use the default internal fuzzy value from OCCT.
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Intersection(const ListOfShape& theObjects,
+      const double theFuzzy = 1.e-8);
 
   /// Destructor to erase the filler
   GEOMALGOAPI_EXPORT virtual ~GeomAlgoAPI_Intersection();
 
 private:
   /// Builds resulting shape.
-  void build(const ListOfShape& theObjects);
+  void build(const ListOfShape& theObjects, const double theFuzzy);
 
 };
 
index cfd2c967f065a9e16e221bdb9f0e6d809085d240..fe49e167a2ea42a4d6d744b2ff6eb6b2a8b74d7c 100644 (file)
@@ -127,9 +127,10 @@ static void sortCompound(TopoDS_Shape& theCompound, GEOMAlgo_Splitter* theOperat
 
 //=================================================================================================
 GeomAlgoAPI_Partition::GeomAlgoAPI_Partition(const ListOfShape& theObjects,
-                                             const ListOfShape& theTools)
+                                             const ListOfShape& theTools,
+                                             const double theFuzzy)
 {
-  build(theObjects, theTools);
+  build(theObjects, theTools, theFuzzy);
 }
 
 static void prepareShapes(const TopoDS_Shape&   theShape,
@@ -150,7 +151,8 @@ static void prepareShapes(const TopoDS_Shape&   theShape,
 
 //=================================================================================================
 void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects,
-                                  const ListOfShape& theTools)
+                                  const ListOfShape& theTools,
+                                  const double theFuzzy)
 {
   if (theObjects.empty()) {
     return;
@@ -200,6 +202,8 @@ void GeomAlgoAPI_Partition::build(const ListOfShape& theObjects,
   Standard_Boolean bRunParallel = Standard_True;
   anOperation->SetRunParallel(bRunParallel);
 
+  if (theFuzzy >= 1.e-7) anOperation->SetFuzzyValue(theFuzzy);
+
   // Building and getting result.
   anOperation->Perform();
   if (anOperation->HasErrors())
index 5676a660b4da9a446d99c930bb977e84a0faeb46..b04982ad2062d6657d05134acd72fadd631c2ce8 100644 (file)
@@ -32,13 +32,20 @@ class GeomAlgoAPI_Partition : public GeomAlgoAPI_MakeShape
 {
 public:
   /// Constructor.
+  /// \param[in] theObjects list of main objects.
+  /// \param[in] theTools list of tools.
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            algorithm will use the default internal fuzzy value from OCCT.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Partition(const ListOfShape& theObjects,
-                                           const ListOfShape& theTools);
+                                           const ListOfShape& theTools,
+                                           const double theFuzzy = 1.e-8);
 
 private:
   /// Builds resulting shape.
   void build(const ListOfShape& theObjects,
-             const ListOfShape& theTools);
+             const ListOfShape& theTools,
+             const double theFuzzy);
 };
 
 #endif
index 1ac8829a2633fb963fe7d04c087c60fe7b569cd9..3801c8064a5fc5c7afc3e43ab4f144f654a4ed8c 100644 (file)
 #include <TopoDS_Builder.hxx>
 #include <TopoDS_Iterator.hxx>
 
+
 //=================================================================================================
 GeomAlgoAPI_PaveFiller::GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape,
-                                               const bool theIsMakeCompSolids)
+                                               const bool theIsMakeCompSolids,
+                                               const double theFuzzy)
 {
-  build(theListOfShape, theIsMakeCompSolids);
+  build(theListOfShape, theIsMakeCompSolids, theFuzzy);
 }
 
 
 //=================================================================================================
 void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
-                                   const bool theIsMakeCompSolids)
+                                   const bool theIsMakeCompSolids,
+                                   const double theFuzzy)
 {
   BOPAlgo_PaveFiller* aPaveFiller = new BOPAlgo_PaveFiller;
   TopTools_ListOfShape aListOfShape;
@@ -53,6 +56,7 @@ void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
     }
   }
   aPaveFiller->SetArguments(aListOfShape);
+  if (theFuzzy >= 1.e-7) aPaveFiller->SetFuzzyValue(theFuzzy);
   aPaveFiller->Perform();
   if (aPaveFiller->HasErrors())
     return;
@@ -61,6 +65,7 @@ void GeomAlgoAPI_PaveFiller::build(const ListOfShape& theListOfShape,
   this->setImpl(aBuilder);
   this->setBuilderType(OCCT_BOPAlgo_Builder);
   aBuilder->SetArguments(aListOfShape);
+  if (theFuzzy >= 1.e-7) aBuilder->SetFuzzyValue(theFuzzy);
   aBuilder->PerformWithFiller(*aPaveFiller);
   if (aBuilder->HasErrors())
     return;
index f068642d853b8957617646070493f94d0e88e264..913c2960f8ee887137defd936f29567f41809e1c 100644 (file)
@@ -35,12 +35,16 @@ public:
   /// \brief Constructor.
   /// \param[in] theListOfShape list of shape which should be splitted.
   /// \param[in] theIsMakeCompSolids if true gather shapes with shared faces to compsolids.
+  /// \param[in] theFuzzy additional tolerance value.
+  ///            If the fuzzy value is below the minimum tolerance value (1.e-7), the
+  ///            algorithm will use the default internal fuzzy value from OCCT.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_PaveFiller(const ListOfShape& theListOfShape,
-                                            const bool theIsMakeCompSolids = false);
+                                            const bool theIsMakeCompSolids = false,
+                                            const double theFuzzy = 1.e-8);
 
 private:
   /// Builds resulting shape.
-  void build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids);
+  void build(const ListOfShape& theListOfShape, const bool theIsMakeCompSolids, const double theFuzzy);
 };
 
 #endif