From: mpv Date: Wed, 30 Jan 2019 12:09:46 +0000 (+0300) Subject: Issue #2493 : added a new unit-test X-Git-Tag: Jan2019~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8aedb0c3093107ebb877c7b7dab5fb5f8f0c7efe;p=modules%2Fshaper.git Issue #2493 : added a new unit-test --- diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index b4be377fa..f1f80f0b3 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -241,4 +241,5 @@ ADD_UNIT_TESTS(TestConstants.py Test2828.py TestSelectionRestore.py Test2491.py + Test2493.py ) diff --git a/src/ModelAPI/Test/Test2493.py b/src/ModelAPI/Test/Test2493.py new file mode 100644 index 000000000..f62b4d9d0 --- /dev/null +++ b/src/ModelAPI/Test/Test2493.py @@ -0,0 +1,247 @@ +## 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 SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "h1", "15") +model.addParameter(Part_1_doc, "h3", "7") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(0, 0, 24) +SketchCircle_1.setAuxiliary(True) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "48/2") +SketchCircle_2 = Sketch_1.addCircle(0, -24, 4) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_1 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_1.result()) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_2.results()[1], 4) +SketchLine_2 = Sketch_1.addLine(-7.50000000000032, -15.81138830084174, -7.500000000000001, -27) +SketchLine_2.setName("SketchLine_3") +SketchLine_2.result().setName("SketchLine_3") +SketchLine_3 = Sketch_1.addLine(-4.500000000000001, -30, 4.500000000000001, -30) +SketchLine_3.setName("SketchLine_4") +SketchLine_3.result().setName("SketchLine_4") +SketchLine_4 = Sketch_1.addLine(7.500000000000001, -27, 7.49999999999943, -15.81138830084217) +SketchLine_4.setName("SketchLine_5") +SketchLine_4.result().setName("SketchLine_5") +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintHorizontal_1.setName("SketchConstraintHorizontal_2") +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +SketchPoint_2 = Sketch_1.addPoint(0, -30) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_3.result()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_8") +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_9") +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_5 = SketchProjection_3.createdFeature() +SketchLine_5.setName("SketchLine_6") +SketchLine_5.result().setName("SketchLine_6") +SketchArc_1 = Sketch_1.addArc(-4.500000000000001, -27, -7.500000000000001, -27, -4.500000000000001, -30, False) +SketchPoint_3 = Sketch_1.addPoint(-7.500000000000001, -30) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchLine_5.result(), 30, True) +SketchPoint_3.setAuxiliary(True) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_11") +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_3.result()) +SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_12") +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.endPoint()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_13") +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_14") +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_3.result()) +SketchArc_2 = Sketch_1.addArc(4.500000000000001, -27, 4.500000000000001, -30, 7.500000000000001, -27, False) +SketchPoint_4 = Sketch_1.addPoint(7.5, -30) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchPoint_4.coordinates(), 15, False) +SketchPoint_4.setAuxiliary(True) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_4.result()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_15") +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_3.result()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_16") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_3.endPoint()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_17") +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_18") +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_4.result()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_3.result()) +SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchPoint_2.coordinates(), SketchLine_3.result()) +SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_1.results()[1], 3) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_2.results()[1], SketchArc_1.results()[1]) +SketchArc_3 = Sketch_1.addArc(0, 0, 7.49999999999943, -15.81138830084217, 17.44306393762918, 1.410503622037278, False) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_3.center()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_10") +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_3.results()[1], "35/2") +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_4.endPoint()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_20") +SketchMultiRotation_1_objects = [SketchLine_2.result(), SketchArc_1.results()[1], SketchLine_3.result(), SketchArc_2.results()[1], SketchLine_4.result(), SketchCircle_2.results()[1]] +SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchAPI_Line(SketchLine_5).startPoint(), 120, 3) +[SketchLine_6, SketchLine_7, SketchArc_4, SketchArc_5, SketchLine_8, SketchLine_9, SketchArc_6, SketchArc_7, SketchLine_10, SketchLine_11, SketchCircle_3, SketchCircle_4] = SketchMultiRotation_1.rotated() +SketchLine_11.setName("SketchLine_12") +SketchLine_11.result().setName("SketchLine_12") +SketchLine_10.setName("SketchLine_9") +SketchLine_10.result().setName("SketchLine_9") +SketchArc_6.setName("SketchArc_5") +SketchArc_6.result().setName("SketchArc_5") +SketchArc_6.results()[1].setName("SketchArc_5_2") +SketchLine_9.setName("SketchLine_11") +SketchLine_9.result().setName("SketchLine_11") +SketchArc_5.setName("SketchArc_6") +SketchArc_5.result().setName("SketchArc_6") +SketchArc_5.results()[1].setName("SketchArc_6_2") +SketchLine_7.setName("SketchLine_10") +SketchLine_7.result().setName("SketchLine_10") +SketchLine_6.setName("SketchLine_7") +SketchLine_6.result().setName("SketchLine_7") +SketchArc_8 = Sketch_1.addArc(0, 0, -17.4430639376291, 1.410503622038327, -7.50000000000032, -15.81138830084174, False) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_8.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_21") +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchArc_3.results()[1], SketchArc_8.results()[1]) +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_3.center(), SketchArc_8.center()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_19") +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_8.startPoint(), SketchLine_11.result()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_22") +SketchArc_9 = Sketch_1.addArc(0, 0, 9.943063937629693, 14.40088467880386, -9.943063937628841, 14.40088467880445, False) +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_9.endPoint(), SketchLine_7.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_23") +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchArc_3.results()[1], SketchArc_9.results()[1]) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_3.center(), SketchArc_9.center()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_24") +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_6.result()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_25") +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_9.startPoint(), SketchLine_10.result()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_26") +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchArc_1_2f-SketchLine_4f-SketchArc_2_2f-SketchLine_5f-SketchArc_3_2f-SketchLine_7f-SketchArc_4_2f-SketchLine_9f-SketchArc_5_2f-SketchLine_9f-SketchArc_9_2f-SketchLine_10f-SketchArc_6_2f-SketchLine_11f-SketchArc_7_2f-SketchLine_12f-SketchArc_8_2f-SketchCircle_2_2r-SketchCircle_4_2r-SketchCircle_3_2r")], model.selection(), "h1", 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchLine_12 = Sketch_2.addLine(-7.499999999996014, 12.99038105676981, 7.499999999996014, 12.99038105676981) +SketchLine_12.setName("SketchLine_13") +SketchLine_12.result().setName("SketchLine_13") +SketchLine_13 = Sketch_2.addLine(7.499999999996014, 12.99038105676981, 15, 0) +SketchLine_13.setName("SketchLine_14") +SketchLine_13.result().setName("SketchLine_14") +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_27") +SketchLine_14 = Sketch_2.addLine(15, 0, 7.499999999996014, -12.99038105676981) +SketchLine_14.setName("SketchLine_15") +SketchLine_14.result().setName("SketchLine_15") +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_28") +SketchLine_15 = Sketch_2.addLine(7.499999999996014, -12.99038105676981, -7.499999999996014, -12.99038105676981) +SketchLine_15.setName("SketchLine_16") +SketchLine_15.result().setName("SketchLine_16") +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_29") +SketchLine_16 = Sketch_2.addLine(-7.499999999996014, -12.99038105676981, -15, 0) +SketchLine_16.setName("SketchLine_17") +SketchLine_16.result().setName("SketchLine_17") +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_30") +SketchLine_17 = Sketch_2.addLine(-15, 0, -7.499999999996014, 12.99038105676981) +SketchLine_17.setName("SketchLine_18") +SketchLine_17.result().setName("SketchLine_18") +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_31") +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_12.startPoint(), SketchLine_17.endPoint()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_32") +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_12.result()) +SketchConstraintHorizontal_2.setName("SketchConstraintHorizontal_3") +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_15.result()) +SketchConstraintHorizontal_3.setName("SketchConstraintHorizontal_4") +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_18 = SketchProjection_4.createdFeature() +SketchLine_18.setName("SketchLine_19") +SketchLine_18.result().setName("SketchLine_19") +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_19 = SketchProjection_5.createdFeature() +SketchLine_19.setName("SketchLine_20") +SketchLine_19.result().setName("SketchLine_20") +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchLine_18.result()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_33") +SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchLine_18.result()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_34") +SketchPoint_5 = Sketch_2.addPoint(-1.694065894508601e-21, 12.99038105676981) +SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchLine_12.result()) +SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_35") +SketchConstraintMiddle_2 = Sketch_2.setMiddlePoint(SketchLine_12.result(), SketchPoint_5.coordinates()) +SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchLine_19.result()) +SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_36") +SketchPoint_6 = Sketch_2.addPoint(-2.541098841762901e-21, -12.99038105676981) +SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchLine_15.result()) +SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_37") +SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchLine_19.result()) +SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_38") +SketchConstraintMiddle_3 = Sketch_2.setMiddlePoint(SketchLine_15.result(), SketchPoint_6.coordinates()) +SketchCircle_5 = Sketch_2.addCircle(0, 0, 15) +SketchCircle_5.setAuxiliary(True) +SketchConstraintCoincidence_35 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_18).startPoint(), SketchCircle_5.center()) +SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_39") +SketchConstraintCoincidence_36 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchCircle_5.results()[1]) +SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_40") +SketchConstraintCoincidence_37 = Sketch_2.setCoincident(SketchLine_16.startPoint(), SketchCircle_5.results()[1]) +SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_41") +SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchCircle_5.results()[1]) +SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_42") +SketchConstraintCoincidence_39 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchCircle_5.results()[1]) +SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_43") +SketchConstraintEqual_4 = Sketch_2.setEqual(SketchLine_17.result(), SketchLine_12.result()) +SketchConstraintEqual_5 = Sketch_2.setEqual(SketchLine_16.result(), SketchLine_15.result()) +SketchConstraintRadius_5 = Sketch_2.setRadius(SketchCircle_5.results()[1], 15) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_18r-SketchLine_17r-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r")], model.selection(), "97-h3-h1", 0) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face")) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_20 = SketchProjection_6.createdFeature() +SketchLine_20.setName("SketchLine_21") +SketchLine_20.result().setName("SketchLine_21") +SketchCircle_6 = Sketch_3.addCircle(0, 0, 10) +SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_20).startPoint(), SketchCircle_6.center()) +SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_44") +SketchConstraintRadius_6 = Sketch_3.setRadius(SketchCircle_6.results()[1], 10) +model.do() +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_6_2f")], model.selection(), 0, 60, [model.selection("SOLID", "Extrusion_2_1")]) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/From_Face")) +SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_21 = SketchProjection_7.createdFeature() +SketchLine_21.setName("SketchLine_22") +SketchLine_21.result().setName("SketchLine_22") +SketchCircle_7 = Sketch_4.addCircle(0, 0, 12.5) +SketchConstraintCoincidence_41 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_21).startPoint(), SketchCircle_7.center()) +SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_45") +SketchConstraintRadius_7 = Sketch_4.setRadius(SketchCircle_7.results()[1], "25/2") +model.do() +# check parameter is changed, so, FromFace becomes out of resulting solid, but Sketch_4 is still valid +Extrusion_2.toSize().setValue(48) +model.end() + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Sketch_4.feature()))