1 ## Copyright (C) 2014-2017 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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
22 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
23 from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder
24 from GeomAPI import GeomAPI_Pnt as pnt
25 from GeomAPI import GeomAPI_Ax1 as axis
26 from GeomAPI import GeomAPI_Dir as direction
29 pnt1 = pnt(0., 0., 0.)
30 pnt2 = pnt(10., 10., 10.)
33 yDir = direction(0.,10.,0.)
34 ax1 = axis(pnt1, yDir)
37 edgx = edgeBuilder.line(1., 0., 0.)
38 edgy = edgeBuilder.line(0., 1., 0.)
39 edgz = edgeBuilder.line(0., 0., 1.)
40 edg1 = edgeBuilder.line(0., 10., 0.)
41 edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z())
43 Cylinder_1 = shaperpy.makeCylinder(5., 10.)
44 Cylinder_2 = shaperpy.makeCylinder(pnt2, edgx, 5., 10.)
45 Cylinder_3 = shaperpy.makeCylinder(pnt2, edg1, 7., 12.)
48 Cylinder_4 = shaperpy.makeCylinder(0., 10.)
49 except myExcept as ec:
50 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
53 Cylinder_5 = shaperpy.makeCylinder(-5., 10.)
54 except myExcept as ec:
55 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
58 Cylinder_6 = shaperpy.makeCylinder(5., 0.)
59 except myExcept as ec:
60 assert(ec.what() == "Cylinder builder :: height is negative or null.")
63 Cylinder_7 = shaperpy.makeCylinder(5., -10.)
64 except myExcept as ec:
65 assert(ec.what() == "Cylinder builder :: height is negative or null.")
68 Cylinder_8 = shaperpy.makeCylinder(None, edgz, 5., 10.)
69 except myExcept as ec:
70 assert(ec.what() == "Cylinder builder :: the base point is not valid.")
73 Cylinder_9 = shaperpy.makeCylinder(pnt1, None, 5., 10.)
74 except myExcept as ec:
75 assert(ec.what() == "Cylinder builder :: the axis is not valid.")
77 Cylinder_14 = shaperpy.makeCylinder(5., 10., 45.)
78 Cylinder_15 = shaperpy.makeCylinder(pnt2, edgx, 5., 10., 90.)
79 Cylinder_16 = shaperpy.makeCylinder(pnt2, edgaxis, 7., 12., 120.)
80 Cylinder_17 = shaperpy.makeCylinder(pnt2, edgy, 5., 10., 360.)
83 Cylinder_18 = shaperpy.makeCylinder(0., 10., 45.)
84 except myExcept as ec:
85 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
88 Cylinder_19 = shaperpy.makeCylinder(-5., 10., 45.)
89 except myExcept as ec:
90 assert(ec.what() == "Cylinder builder :: radius is negative or null.")
93 Cylinder_20 = shaperpy.makeCylinder(5., 0., 45.)
94 except myExcept as ec:
95 assert(ec.what() == "Cylinder builder :: height is negative or null.")
98 Cylinder_21 = shaperpy.makeCylinder(5., -10., 45.)
99 except myExcept as ec:
100 assert(ec.what() == "Cylinder builder :: height is negative or null.")
103 Cylinder_22 = shaperpy.makeCylinder(5., 10., 0.)
104 except myExcept as ec:
105 assert(ec.what() == "Cylinder builder :: angle is negative or null.")
108 Cylinder_23 = shaperpy.makeCylinder(5., 10., -45.)
109 except myExcept as ec:
110 assert(ec.what() == "Cylinder builder :: angle is negative or null.")
113 Cylinder_24 = shaperpy.makeCylinder(5., 10., 450.)
114 except myExcept as ec:
115 assert(ec.what() == "Cylinder builder :: angle greater than 360 degrees.")
118 Cylinder_25 = shaperpy.makeCylinder(None, edgz, 5., 10., 90.)
119 except myExcept as ec:
120 assert(ec.what() == "Cylinder builder :: the base point is not valid.")
123 Cylinder_26 = shaperpy.makeCylinder(pnt1, None, 5., 10., 90.)
124 except myExcept as ec:
125 assert(ec.what() == "Cylinder builder :: the axis is not valid.")