Salome HOME
Merge branch 'V9_2_2_BR'
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMove04.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 of deep nested results history. Cylinders divided to two by cut, then each divided to
22 # two by partition by plane, then resulting compsolids are collected in compound.
23 # Checking that group on initial extrusion moved to the end contains the corresponding
24 # results, but divided.
25
26 from salome.shaper import model
27 from ModelAPI import *
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchCircle_1 = Sketch_1.addCircle(-4.602216748768477, 10.94581280788177, 9.660420057801511)
35 model.do()
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0)
37 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2")])
38 Group_2 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")])
39 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 1, True)
40 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
41 SketchCircle_2 = Sketch_2.addCircle(-5.643073116097736, 11.91382008305256, 15.03576198961618)
42 model.do()
43 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 2, -4)
44 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
45 Partition_1 = model.addPartition(Part_1_doc, [model.selection("COMPOUND", "Cut_1_1"), model.selection("FACE", "Plane_1")])
46 Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1"), model.selection("COMPSOLID", "Partition_1_2")])
47 model.do()
48 # move groups to the end
49 Part_1_doc.moveFeature(Group_1.feature(), Compound_1.feature())
50 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
51 model.end()
52
53 aFactory = ModelAPI_Session.get().validators()
54 # check group 1: cylindical face is divided to 6 (because of seam edge)
55 selectionList = Group_1.feature().selectionList("group_list")
56 assert(selectionList.size() == 6)
57 assert(aFactory.validate(Group_1.feature()))
58
59 # check group 2: solid is divided to 4 solids
60 selectionList = Group_2.feature().selectionList("group_list")
61 assert(selectionList.size() == 4)
62 assert(aFactory.validate(Group_2.feature()))
63
64 assert(model.checkPythonDump())