From: dbv Date: Tue, 21 Aug 2018 15:07:26 +0000 (+0300) Subject: Issue #2596: Application errors when smash big face from small X-Git-Tag: SHAPER_V9_1_0RC1~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=508cf1b487d990c6ec24c656c578968c3bf8631a;p=modules%2Fshaper.git Issue #2596: Application errors when smash big face from small Fixed --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 8361d95d1..98de65383 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -323,4 +323,5 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCommon_CompSolidCompound_Face.py TestBooleanCommon_CompSolidCompound_Shell.py TestBooleanCommon_CompSolidCompound_CompSolidCompound.py + Test2596.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index f0aa745dd..0dbe5a348 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -200,30 +200,39 @@ void FeaturesPlugin_BooleanSmash::execute() aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); // Put all (cut result, tools and not used solids) to PaveFiller. - aShapesToAdd.push_back(aBoolAlgo->shape()); + GeomShapePtr aShape = aBoolAlgo->shape(); + GeomAPI_ShapeIterator anIt(aShape); + if (anIt.more() || aShape->shapeType() == GeomAPI_Shape::VERTEX) { + aShapesToAdd.push_back(aShape); + } aShapesToAdd.insert(aShapesToAdd.end(), aTools.begin(), aTools.end()); - std::shared_ptr aFillerAlgo( - new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if (!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if (aFillerAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aFillerAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; + if (aShapesToAdd.size() == 1) { + aShape = aShapesToAdd.front(); } + else { + std::shared_ptr aFillerAlgo( + new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); + if (!aFillerAlgo->isDone()) { + std::string aFeatureError = "Error: PaveFiller algorithm failed."; + setError(aFeatureError); + return; + } + if (aFillerAlgo->shape()->isNull()) { + static const std::string aShapeError = "Error: Resulting shape is Null."; + setError(aShapeError); + return; + } + if (!aFillerAlgo->isValid()) { + std::string aFeatureError = "Error: Resulting shape is not valid."; + setError(aFeatureError); + return; + } - std::shared_ptr aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aShape = aFillerAlgo->shape(); + aMakeShapeList.appendAlgo(aFillerAlgo); + aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + } std::shared_ptr aFrontShape = anOriginalShapes.front(); anOriginalShapes.pop_front(); @@ -251,7 +260,9 @@ void FeaturesPlugin_BooleanSmash::loadNamingDS(ResultBodyPtr theResultBody, GeomAPI_DataMapOfShapeShape& theMapOfShapes) { //load result - if(theBaseShape->isEqual(theResultShape)) { + if (theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape, false); + } else if (theResultShape->isEqual(theTools.front())) { theResultBody->store(theResultShape, false); } else { const int aModifyVTag = 1; diff --git a/src/FeaturesPlugin/Test/Test2596.py b/src/FeaturesPlugin/Test/Test2596.py new file mode 100644 index 000000000..f64c564a3 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2596.py @@ -0,0 +1,65 @@ +## Copyright (C) 2014-2017 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 + +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(-32.04974271012008, 18.88336192109778, 25.20058663660772) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_2.addLine(22.00171526586623, 64.27272727272731, -86.7941680960549, 64.27272727272731) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_2.addLine(-86.7941680960549, 64.27272727272731, -86.7941680960549, -27.54545454545455) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-86.7941680960549, -27.54545454545455, 22.00171526586623, -27.54545454545455) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(22.00171526586623, -27.54545454545455, 22.00171526586623, 64.27272727272731) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_4.result()) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_1_2")]) +model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Smash_1, 1) +model.testNbSubResults(Smash_1, [0]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [8]) + +assert(model.checkPythonDump())