Salome HOME
094dfa376f2f1c1d86e560b8778beeab6370b751
[modules/geom.git] / doc / salome / examples / basic_geom_objs_ex11.py
1 #  -*- coding: utf-8 -*-
2 # Copyright (C) 2022  CEA/DEN, EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import unittest
22
23 import salome
24 salome.salome_init()
25 import GEOM
26 from salome.geom import geomBuilder
27 geompy = geomBuilder.New()
28
29 class BasicGeomObjsEx11(unittest.TestCase):
30
31     def testNoRaiseOnMakeFaceWires(self):
32         """
33         Work in pair with testRaiseOnMakeFaceWires
34         """
35         pts = [(0,0,0),(1,0,0),(1,1,1e-6),(0,1,0)] # diff with testRaiseOnMakeFaceWires is 1e-6 instead of 1e-5
36         vertices = [ geompy.MakeVertex(*list(elt)) for elt in pts]
37         polyline0 =  geompy.MakePolyline([ vertices[nodeidx] for nodeidx in range(len(pts)) ], True)
38         wire_0 =  geompy.MakeFaceWires( [ polyline0 ] , isPlanarWanted = True, theName=None, raiseException=True) # isPlanarWanted and raiseException are expected to be True here !
39         self.assertTrue(wire_0) # wire_0 is expected to be not None because wire has been created and detected to be planar
40         wire_1 =  geompy.MakeFace( polyline0 , isPlanarWanted = True, theName=None, raiseException=True) # isPlanarWanted and raiseException are expected to be True here !
41         self.assertTrue(wire_1)
42
43     def testRaiseOnMakeFaceWires(self):
44         """
45         Work in pair with testNoRaiseOnMakeFaceWires
46         """
47         pts = [(0,0,0),(1,0,0),(1,1,1e-5),(0,1,0)] # diff with testRaiseOnMakeFaceWires is 1e-5 instead of 1e-6
48         vertices = [ geompy.MakeVertex(*list(elt)) for elt in pts]
49         polyline0 =  geompy.MakePolyline([ vertices[nodeidx] for nodeidx in range(len(pts)) ], True)
50         # MakeFaceWires is expected to fail here because third point is too far from Oxy plane
51         self.assertRaises( RuntimeError, geompy.MakeFaceWires, [ polyline0 ] , True, None, True )# isPlanarWanted and raiseException are expected to be True here !
52         wire_0 =  geompy.MakeFaceWires( [ polyline0 ] , isPlanarWanted = True, theName=None, raiseException=False) # returns something bug wire_0 is incorrect
53         self.assertRaises( RuntimeError, geompy.MakeFace, polyline0 , True, None, True )# isPlanarWanted and raiseException are expected to be True here !
54         wire_1 =  geompy.MakeFace( polyline0 , isPlanarWanted = True, theName=None, raiseException=False) # returns something bug wire_1 is incorrect
55
56 if __name__ == '__main__':
57     unittest.main()