]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2170.py
Salome HOME
Fix for the #1757 with full split of the selected sketch-face.
[modules/shaper.git] / src / ModelAPI / Test / Test2170.py
1 ## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 ##
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
7 ##
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 ## Lesser General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 ##
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 # -*- coding: utf-8 -*-
22
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 model.addParameter(Part_1_doc, "g", "5")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchLine_1 = Sketch_1.addLine(0, 200, 0, 0)
32 SketchLine_2 = Sketch_1.addLine(0, 0, 250, 0)
33 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
34 SketchLine_3 = Sketch_1.addLine(500, 0, 500, 200)
35 SketchArc_1 = Sketch_1.addArc(250, 200.000000000003, 0, 200, 500, 200, True)
36 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
37 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
38 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_1.results()[1])
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
40 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
41 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
42 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
43 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
44 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
45 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
46 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 250)
47 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
48 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchPoint_1.coordinates())
49 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
50 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 200)
51 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 200)
52 SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-32, 0, 500, 0, False)
53 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.center())
54 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
55 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
56 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
57 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
58 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
59 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
60 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
61 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_2.startPoint())
62 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
63 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_3.startPoint())
64 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
65 model.do()
66 Sketch_1.setName("toto")
67 Sketch_1.result().setName("tutu")
68 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "tutu/Face-SketchLine_1r-SketchArc_2_2f-SketchLine_3f-SketchArc_1_2f")], model.selection(), 10, 0)
69 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/SketchLine_2")])
70 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
71 Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_StartVertex]e[Extrusion_2_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_EndVertex]e[Extrusion_2_1/To_Edge]e")])
72 model.do()
73 model.end()
74
75 # check that resulting group selection is valid
76 from ModelAPI import *
77 aFactory = ModelAPI_Session.get().validators()
78 assert(aFactory.validate(Group_1.feature()))
79 assert(Group_1.groupList().size() == 2)
80 assert(Group_1.groupList().value(0).value().shapeTypeStr() == "VERTEX")
81 assert(Group_1.groupList().value(1).value().shapeTypeStr() == "VERTEX")
82
83 assert(model.checkPythonDump())