X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_BooleanSmash.cpp;h=92aff415c2594ebb88e8cfe06a39036480e0f956;hb=04e2497fc973f0afc95d0a4a6f95e37fb27f45e8;hp=f8336b240b22b06d604c52197c83c014f714bae4;hpb=fe287b144d91e67a33f4761bd4313dc79ffb20db;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index f8336b240..92aff415c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanSmash.h" #include +#include +#include #include #include @@ -33,6 +35,10 @@ #include #include + +static const double DEFAULT_FUZZY = 1.e-5; + + //================================================================================================== FeaturesPlugin_BooleanSmash::FeaturesPlugin_BooleanSmash() : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_SMASH) @@ -45,6 +51,11 @@ void FeaturesPlugin_BooleanSmash::initAttributes() data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + data()->addAttribute(USE_FUZZY_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(FUZZY_PARAM_ID(), ModelAPI_AttributeDouble::typeId()); + boolean(USE_FUZZY_ID())->setValue(false); // Do NOT use the fuzzy parameter by default. + real(FUZZY_PARAM_ID())->setValue(DEFAULT_FUZZY); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); } @@ -100,13 +111,20 @@ void FeaturesPlugin_BooleanSmash::execute() } } + // Getting fuzzy parameter. + // Used as additional tolerance to eliminate tiny results. + // Using -1 as fuzzy value in the GeomAlgoAPI means to ignore it during the boolean operation! + bool aUseFuzzy = boolean(USE_FUZZY_ID())->value(); + double aFuzzy = (aUseFuzzy ? real(FUZZY_PARAM_ID())->value() : -1); + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); if (!aShapesToAdd.empty()) { // Cut objects with not used solids. std::shared_ptr 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 +136,8 @@ void FeaturesPlugin_BooleanSmash::execute() std::shared_ptr 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 +150,8 @@ void FeaturesPlugin_BooleanSmash::execute() std::shared_ptr 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 +174,7 @@ void FeaturesPlugin_BooleanSmash::execute() } else { std::shared_ptr aFillerAlgo( - new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); + new GeomAlgoAPI_PaveFiller(aShapesToAdd, true, aFuzzy)); if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) { setError(anError); return;