X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FFeaturesPlugin_BooleanSmash.cpp;h=9f1aca9987fb418a7e98c22049bd1cb90f513b2f;hb=660930f24994da13c3a3ac089abfbfa20cb9b109;hp=0c7f3bab1f292731aa907c874482204f10440651;hpb=380f01e1fce1a012267d604a1190d04bf4659447;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index 0c7f3bab1..9f1aca998 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 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 @@ -19,9 +19,8 @@ #include "FeaturesPlugin_BooleanSmash.h" -#include "FeaturesPlugin_Tools.h" - #include +#include #include #include @@ -35,6 +34,7 @@ #include #include + //================================================================================================== FeaturesPlugin_BooleanSmash::FeaturesPlugin_BooleanSmash() : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_SMASH) @@ -47,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())); } @@ -102,15 +108,20 @@ 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 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::volume(anObjectsCutAlgo->shape()) > 1.e-27) { + if (GeomAlgoAPI_ShapeTools::area(anObjectsCutAlgo->shape()) > 1.e-27) { aShapesToSmash.clear(); aShapesToSmash.push_back(anObjectsCutAlgo->shape()); aMakeShapeList->appendAlgo(anObjectsCutAlgo); @@ -120,9 +131,10 @@ 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::volume(aToolsCutAlgo->shape()) > 1.e-27) { + if (GeomAlgoAPI_ShapeTools::area(aToolsCutAlgo->shape()) > 1.e-27) { aTools.clear(); aTools.push_back(aToolsCutAlgo->shape()); aMakeShapeList->appendAlgo(aToolsCutAlgo); @@ -133,7 +145,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)) { @@ -156,7 +169,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; @@ -175,20 +188,20 @@ void FeaturesPlugin_BooleanSmash::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, - anOriginalShapes, - anOriginalShapes, - aMakeShapeList, - aShape); + ModelAPI_Tools::loadModifiedShapes(aResultBody, + anOriginalShapes, + anOriginalShapes, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; - FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, - GeomShapePtr(), - anOriginalShapes, - aMakeShapeList, - aShape); + ModelAPI_Tools::loadDeletedShapes(aResultBody, + GeomShapePtr(), + anOriginalShapes, + aMakeShapeList, + aShape); // remove the rest results if there were produced in the previous pass removeResults(aResultIndex);