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