From 8b477c311112231355a8627e985c7f8acb543083 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 20 Dec 2017 13:34:37 +0300 Subject: [PATCH] Issue #2377: Wrong extrusion result by bounding planes and offset Fixed --- src/FeaturesPlugin/CMakeLists.txt | 1 + src/FeaturesPlugin/Test/Test2377.py | 53 +++++++++++++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp | 8 ++-- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/FeaturesPlugin/Test/Test2377.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index f6f6f0eeb..9a39487a9 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -241,4 +241,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2255.py Test2289.py Test2304.py + Test2377.py ) diff --git a/src/FeaturesPlugin/Test/Test2377.py b/src/FeaturesPlugin/Test/Test2377.py new file mode 100644 index 000000000..9457daa8d --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2377.py @@ -0,0 +1,53 @@ +## 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")) +SketchLine_1 = Sketch_1.addLine(-1.039451114922807, 35.51457975986278, -38.45969125214407, -21.30874785591767) +SketchLine_2 = Sketch_1.addLine(-38.45969125214407, -21.30874785591767, 46.08233276157804, -21.30874785591767) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(46.08233276157804, -21.30874785591767, -1.039451114922807, 35.51457975986278) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +SketchCircle_1 = Sketch_2.addCircle(-10.74792845018279, -51.46099937127247, 20.55678647017868) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection("EDGE", "PartSet/OX"), model.selection("FACE", "PartSet/YOZ"), 0, model.selection(), 0) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Extrusion_2, 1) +model.testNbSubResults(Extrusion_2, [0]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.EDGE, [6]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.VERTEX, [12]) +model.testResultsVolumes(Extrusion_2, [36480.150452606350881978869438171]) + +assert(model.checkPythonDump()) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 4276537f0..91cd80630 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -150,13 +150,13 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, GeomShapePtr aBasePlane; const bool isBoundingShapesSet = theFromShape.get() || theToShape.get(); BRepBuilderAPI_FindPlane aFindPlane(aBaseShape); - if(theDirection.get()) { + if ((aBaseShape.ShapeType() == TopAbs_VERTEX || aBaseShape.ShapeType() == TopAbs_EDGE) + && theDirection.get()) + { aBaseDir = theDirection; aDirVec = theDirection->impl(); } else { - if(aBaseShape.ShapeType() == TopAbs_VERTEX - || aBaseShape.ShapeType() == TopAbs_EDGE - || aFindPlane.Found() == Standard_False) { + if(aFindPlane.Found() == Standard_False) { return; } -- 2.39.2