From 910ad5cd45b974cea91ce98c4dbf6ad2f74a663e Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 1 Feb 2017 16:49:21 +0300 Subject: [PATCH] Issue #1915: boolean failed Fixed PaveFiller error. --- src/FeaturesPlugin/CMakeLists.txt | 1 + src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp | 31 ++++++++++--------- src/FeaturesPlugin/Test/Test1915.py | 19 ++++++++++++ 3 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test1915.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 8fa040447..cf821fd9e 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -142,4 +142,5 @@ ADD_UNIT_TESTS(TestExtrusion.py TestRecover1798.py Test1922.py Test1942.py + Test1915.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index d265fb37c..f3941ec11 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -271,26 +271,29 @@ void FeaturesPlugin_Boolean::execute() aMakeShapeList.appendAlgo(aBoolAlgo); GeomAPI_DataMapOfShapeShape aMapOfShapes; aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); + GeomShapePtr aResultShape = aBoolAlgo->shape(); // Add result to not used solids from compsolid. - ListOfShape aShapesToAdd = aNotUsedSolids; - aShapesToAdd.push_back(aBoolAlgo->shape()); - std::shared_ptr aFillerAlgo( - new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if(!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } + if(!aNotUsedSolids.empty()) { + ListOfShape aShapesToAdd = aNotUsedSolids; + aShapesToAdd.push_back(aBoolAlgo->shape()); + std::shared_ptr aFillerAlgo( + new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); + if(!aFillerAlgo->isDone()) { + std::string aFeatureError = "Error: PaveFiller algorithm failed."; + setError(aFeatureError); + return; + } - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList.appendAlgo(aFillerAlgo); + aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aResultShape = aFillerAlgo->shape(); + } - if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-27) { + if(GeomAlgoAPI_ShapeTools::volume(aResultShape) > 1.e-27) { std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aCompSolid, aTools, - aFillerAlgo->shape(), aMakeShapeList, aMapOfShapes); + loadNamingDS(aResultBody, aCompSolid, aTools, aResultShape, aMakeShapeList, aMapOfShapes); setResult(aResultBody, aResultIndex); aResultIndex++; } diff --git a/src/FeaturesPlugin/Test/Test1915.py b/src/FeaturesPlugin/Test/Test1915.py new file mode 100644 index 000000000..0030af07e --- /dev/null +++ b/src/FeaturesPlugin/Test/Test1915.py @@ -0,0 +1,19 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-143.8658546926619, 0.1897622851492952, 114.0641755357124) +SketchLine_1 = Sketch_1.addLine(-141.3317208711381, 114.2257842537203, -143.8607239569611, -118.2013550640528) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(-111.0503834053735, -148.4878232655183, 89.21253106334201) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1"), model.selection("COMPOUND", "Sketch_2")], model.selection(), 10, 0) +Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2_2"), model.selection("SOLID", "Extrusion_1_2_1")], [model.selection("SOLID", "Extrusion_1_1")]) +model.end() + +assert(model.checkPythonDump()) -- 2.39.2