1 # Copyright (C) 2014-2021 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
21 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
22 from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder
23 from GeomAPI import GeomAPI_Pnt as pnt
24 from GeomAPI import GeomAPI_Ax1 as axis
25 from GeomAPI import GeomAPI_Dir as direction
28 pnt1 = pnt(0., 0., 0.)
29 pnt2 = pnt(10., 10., 10.)
32 yDir = direction(0.,10.,0.)
33 ax1 = axis(pnt1, yDir)
36 edgx = edgeBuilder.line(1., 0., 0.)
37 edgy = edgeBuilder.line(0., 1., 0.)
38 edgz = edgeBuilder.line(0., 0., 1.)
39 edg1 = edgeBuilder.line(0., 10., 0.)
40 edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z())
42 Cylinder_1 = shaperpy.makeCylinder(5., 10.)
43 Cylinder_2 = shaperpy.makeCylinder(pnt2, edgx, 5., 10.)
44 Cylinder_3 = shaperpy.makeCylinder(pnt2, edg1, 7., 12.)
47 Cylinder_4 = shaperpy.makeCylinder(0., 10.)
48 except myExcept as ec:
49 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
52 Cylinder_5 = shaperpy.makeCylinder(-5., 10.)
53 except myExcept as ec:
54 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
57 Cylinder_6 = shaperpy.makeCylinder(5., 0.)
58 except myExcept as ec:
59 assert(ec.what() == "Cylinder builder :: height is negative or null.")
62 Cylinder_7 = shaperpy.makeCylinder(5., -10.)
63 except myExcept as ec:
64 assert(ec.what() == "Cylinder builder :: height is negative or null.")
67 Cylinder_8 = shaperpy.makeCylinder(None, edgz, 5., 10.)
68 except myExcept as ec:
69 assert(ec.what() == "Cylinder builder :: the base point is not valid.")
72 Cylinder_9 = shaperpy.makeCylinder(pnt1, None, 5., 10.)
73 except myExcept as ec:
74 assert(ec.what() == "Cylinder builder :: the axis is not valid.")
76 Cylinder_14 = shaperpy.makeCylinder(5., 10., 45.)
77 Cylinder_15 = shaperpy.makeCylinder(pnt2, edgx, 5., 10., 90.)
78 Cylinder_16 = shaperpy.makeCylinder(pnt2, edgaxis, 7., 12., 120.)
79 Cylinder_17 = shaperpy.makeCylinder(pnt2, edgy, 5., 10., 360.)
82 Cylinder_18 = shaperpy.makeCylinder(0., 10., 45.)
83 except myExcept as ec:
84 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
87 Cylinder_19 = shaperpy.makeCylinder(-5., 10., 45.)
88 except myExcept as ec:
89 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
92 Cylinder_20 = shaperpy.makeCylinder(5., 0., 45.)
93 except myExcept as ec:
94 assert(ec.what() == "Cylinder builder :: height is negative or null.")
97 Cylinder_21 = shaperpy.makeCylinder(5., -10., 45.)
98 except myExcept as ec:
99 assert(ec.what() == "Cylinder builder :: height is negative or null.")
102 Cylinder_22 = shaperpy.makeCylinder(5., 10., 0.)
103 except myExcept as ec:
104 assert(ec.what() == "Cylinder builder :: angle is negative or null.")
107 Cylinder_23 = shaperpy.makeCylinder(5., 10., -45.)
108 except myExcept as ec:
109 assert(ec.what() == "Cylinder builder :: angle is negative or null.")
112 Cylinder_24 = shaperpy.makeCylinder(5., 10., 450.)
113 except myExcept as ec:
114 assert(ec.what() == "Cylinder builder :: angle greater than 360 degrees.")
117 Cylinder_25 = shaperpy.makeCylinder(None, edgz, 5., 10., 90.)
118 except myExcept as ec:
119 assert(ec.what() == "Cylinder builder :: the base point is not valid.")
122 Cylinder_26 = shaperpy.makeCylinder(pnt1, None, 5., 10., 90.)
123 except myExcept as ec:
124 assert(ec.what() == "Cylinder builder :: the axis is not valid.")