Salome HOME
Copyright update 2022
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupWholeResult1.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 # Tests python API for the whole result in group selection
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(-16, -4, -4, 29)
30 SketchLine_2 = Sketch_1.addLine(-4, 29, 21, -9)
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
32 SketchLine_3 = Sketch_1.addLine(21, -9, -16, -4)
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
34 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
35 model.do()
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 10, 0)
37 Group_1 = model.addGroup(Part_1_doc, "EDGE", [model.selection("SOLID", "Extrusion_1_1")])
38 model.end()
39
40 # check the group result: it must be compound of 9 edges
41 assert(Group_1.groupList().selectionType() == "EDGE")
42 assert(len(Group_1.results()) == 1)
43 assert(Group_1.result().shapeType() == "COMPOUND")
44
45 from GeomAPI import GeomAPI_ShapeIterator
46 aResultShape = Group_1.feature().firstResult().shape()
47 anIter = GeomAPI_ShapeIterator(aResultShape)
48 aNum = 0
49 while anIter.more():
50   anEdge = anIter.current()
51   assert(anEdge.isEdge())
52   aNum = aNum + 1
53   anIter.next()
54
55 assert(aNum == 9)
56
57 assert(model.checkPythonDump())