From 2817afa82455f6e60026494676968e65451b1545 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 6 Feb 2019 15:45:41 +0300 Subject: [PATCH] Unit test for the issue #2738 is added --- src/FeaturesPlugin/CMakeLists.txt | 1 + src/FeaturesPlugin/Test/Test2738.py | 75 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/FeaturesPlugin/Test/Test2738.py diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 0458345a1..566bd072c 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -446,5 +446,6 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2692.py Test2617.py Test2729.py + Test2738.py Test2751.py ) diff --git a/src/FeaturesPlugin/Test/Test2738.py b/src/FeaturesPlugin/Test/Test2738.py new file mode 100644 index 000000000..d8f8da21c --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2738.py @@ -0,0 +1,75 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from GeomAlgoAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "d", "8") +model.addParameter(Part_1_doc, "nb", "3") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-34.12026714434272, 28.71281409244911, 1.619211673722419) +SketchCircle_2 = Sketch_1.addCircle(-34.12026714434272, 28.71281409244911, 3.180589706721861) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE_2", (-35.73947881806514, 28.71281409244911, 0))], model.selection(), 2, -1) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", (-37.30085685106458, 28.71281409244911, 0))], model.selection(), 5, 0) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1"), model.selection("COMPOUND", "all-in-Extrusion_2")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", (-34.12026714434272, 28.71281409244911, 1.5))]) +Group_1.setName("Group_dechets") +Group_1.result().setName("Group_dechets") +Group_2 = model.addGroup(Part_1_doc, [model.selection("SOLID", (-34.12026714434272, 28.71281409244911, 2.35984679315518))]) +Group_2.setName("Group_colis") +Group_2.result().setName("Group_colis") +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", (-34.12026714434272, 28.71281409244911, 2.5))], model.selection("EDGE", "PartSet/OX"), "d", "nb", model.selection("EDGE", "PartSet/OY"), "d", "nb") +model.do() +# move groups to the end +Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_1.feature()) +Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature()) +model.end() + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() + +# number of solids should be multiplyed by linear copy +selectionList = Group_1.feature().selectionList("group_list") +assert(selectionList.size() == 9) +assert(aFactory.validate(Group_1.feature())) +# checkthat solids in the first group are small, like the origin +for i in range(9): + delta = GeomAlgoAPI_ShapeTools_volume(selectionList.value(i).value()) - 8.236773528312948 + assert(fabs(delta) < 1.e-5) + +# same-plane faces should be merged +selectionList = Group_2.feature().selectionList("group_list") +assert(selectionList.size() == 9) +assert(aFactory.validate(Group_2.feature())) + +# checkthat solids in the secong group are big, like the origin +for i in range(9): + delta = GeomAlgoAPI_ShapeTools_volume(selectionList.value(i).value()) - 150.66735294710597 + assert(fabs(delta) < 1.e-5) + +assert(model.checkPythonDump()) -- 2.39.2