Salome HOME
High level objects history implementation for Translation, Rotation and Scale features.
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove3.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 # Test that partition divides cylinder into 4 faces, there is no edges in a group moved to the end
22 # Based on the CEA report mail 04.12.2018, page 2
23
24 from SketchAPI import *
25
26 from ModelAPI import *
27 from GeomAPI import *
28 from salome.shaper import model
29
30 model.begin()
31 partSet = model.moduleDocument()
32 Part_1 = model.addPart(partSet)
33 Part_1_doc = Part_1.document()
34 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
35 SketchArc_1 = Sketch_1.addArc(-1.103476974288834e-12, 24.99999999999979, 24.49489742783218, 30, 0, 50, False)
36 SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
37 SketchLine_1 = SketchProjection_1.createdFeature()
38 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result())
39 SketchLine_2 = Sketch_1.addLine(0, 50, -10, 50)
40 SketchLine_2.setAuxiliary(True)
41 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.startPoint())
42 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
43 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
44 SketchLine_3 = Sketch_1.addLine(24.49489742783218, 30, 24.49489742783218, 5)
45 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_3.startPoint())
46 SketchLine_4 = Sketch_1.addLine(24.49489742783218, 5, 34.49489742783218, 5)
47 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
48 SketchLine_5 = Sketch_1.addLine(34.49489742783218, 5, 34.49489742783218, 0)
49 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
50 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
51 SketchLine_6 = SketchProjection_2.createdFeature()
52 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
53 SketchLine_7 = Sketch_1.addLine(34.49489742783218, 0, 0, 0)
54 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
55 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_7.endPoint())
56 SketchLine_8 = Sketch_1.addLine(0, 50, 0, 0)
57 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_8.startPoint())
58 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_8.endPoint())
59 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result())
60 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
61 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result())
62 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), 10)
63 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 5)
64 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 25)
65 SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 50)
66 SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_2.result(), 10)
67 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 25)
68 model.do()
69 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_8f-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
70 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3")])
71 Partition_1_objects = [model.selection("SOLID", "Revolution_1_1"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/YOZ")]
72 Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects)
73 model.do()
74
75 # move group
76 Part_1_doc.moveFeature(Group_1.feature(), Partition_1.feature())
77 model.end()
78
79 # Check group: result must be four faces
80 aFactory = ModelAPI_Session.get().validators()
81 selectionList = Group_1.feature().selectionList("group_list")
82 assert(selectionList.size() == 4)
83 assert(aFactory.validate(Group_1.feature()))
84 for i in range(4):
85   assert(Group_1.groupList().value(i).value().shapeType() == GeomAPI_Shape.FACE)
86
87 assert(model.checkPythonDump())