1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2018-2022 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 class TestGeometry(unittest.TestCase):
29 def processGuiEvents(self):
31 if salome.sg.hasDesktop():
32 salome.sg.updateObjBrowser();
34 SalomePyQt.SalomePyQt().processEvents()
36 def test_geometry(self):
37 """Quick test for Geometry module"""
40 print('Testing Geometry module')
42 from salome.geom import geomBuilder
43 geompy = geomBuilder.New()
46 print('... Create box')
47 box = geompy.MakeBox(0., 0., 0., 100., 200., 300, theName='box')
48 self.assertIsNotNone(box)
49 self.assertEqual(box.GetName(), 'box')
50 self.processGuiEvents()
52 # ---- extract shell from box
53 print('... Extract shell from box')
54 shells = geompy.SubShapeAll(box, geompy.ShapeType['SHELL'], theName=['shell'])
55 self.assertEqual(len(shells), 1)
57 self.assertIsNotNone(shell)
58 self.assertEqual(shell.GetName(), 'shell')
59 self.processGuiEvents()
61 # ---- extract faces from box
62 print('... Extract faces from box')
63 faces = geompy.SubShapeAll(box, geompy.ShapeType['FACE'], theName='face')
64 self.assertEqual(len(faces), 6)
65 for i, face in enumerate(faces):
66 self.assertIsNotNone(face)
67 self.assertEqual(face.GetName(), 'face_{}'.format(i+1))
68 self.processGuiEvents()
70 # ---- extract edges from 1st face
71 print('... Extract edges from 1st face')
72 edges = geompy.SubShapeAll(faces[0], geompy.ShapeType['EDGE'], theName='edge')
73 self.assertEqual(len(edges), 4)
74 for i, edge in enumerate(edges):
75 self.assertIsNotNone(edge)
76 self.assertEqual(edge.GetName(), 'edge_{}'.format(i+1))
77 self.processGuiEvents()
79 if __name__ == '__main__':