]> SALOME platform Git repositories - modules/shaper.git/blob - src/CollectionPlugin/Test/TestGroupWholeFeature1.py
Salome HOME
Tset case corrected in accordance with improved behaviour due to OCCT 32964 bug fix...
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupWholeFeature1.py
1 # Copyright (C) 2014-2024  CEA, EDF
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 # Tests python API for the whole feature (all results) in group selection
21 from salome.shaper import model
22
23 model.begin()
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0)
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
30 Extrusion_1.setNestedSketch(Sketch_1)
31 Group_1 = model.addGroup(Part_1_doc, "Vertices", [model.selection("COMPOUND", "all-in-Extrusion_1")])
32 Group_1.setName("CylVertices")
33 Group_1.result().setName("CylVertices")
34 Group_2 = model.addGroup(Part_1_doc, "Edges", [model.selection("COMPOUND", "all-in-Extrusion_1")])
35 Group_2.setName("CylEdges")
36 Group_2.result().setName("CylEdges")
37 Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("COMPOUND", "all-in-Extrusion_1")])
38 Group_3.setName("CylFaces")
39 Group_3.result().setName("CylFaces")
40 Group_4 = model.addGroup(Part_1_doc, "Solids", [model.selection("COMPOUND", "all-in-Extrusion_1")])
41 Group_4.setName("CylSolid")
42 Group_4.result().setName("CylSolid")
43 model.end()
44
45 from GeomAPI import GeomAPI_ShapeIterator
46
47 # group variable, type of selection, number of expected sub-shapes, sub-shapes type
48 test_list = [(Group_1, "Vertices", 2, 7), (Group_2, "Edges", 3, 6), (Group_3, "Faces", 3, 4), (Group_4, "Solids", 1, 2)]
49 for test in test_list:
50   assert(test[0].groupList().selectionType() == test[1])
51   assert(len(test[0].results()) == 1)
52   assert(test[0].result().shapeType() == "COMPOUND")
53
54   aResultShape = test[0].feature().firstResult().shape()
55   anIter = GeomAPI_ShapeIterator(aResultShape)
56   aNum = 0
57   while anIter.more():
58     aShape = anIter.current()
59     assert(aShape.shapeType() == test[3])
60     aNum = aNum + 1
61     anIter.next()
62
63   assert(aNum == test[2])
64
65 assert(model.checkPythonDump())