Salome HOME
f6862ab88afd2c3c536fd2a1adfff58ad94b684c
[modules/shaper.git] / test.API / SHAPER / Primitives / TestAPI_Cylinder.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
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
27
28 # Points
29 pnt1 = pnt(0., 0., 0.)
30 pnt2 = pnt(10., 10., 10.)
31
32 # Axis
33 yDir = direction(0.,10.,0.)
34 ax1 = axis(pnt1, yDir)
35
36 # Edges
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())
42
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.)
46
47 try:
48   Cylinder_4 = shaperpy.makeCylinder(0., 10.)
49 except myExcept,ec:
50   assert(ec.what() == "Cylinder builder :: radius is negative or null.")
51
52 try:
53   Cylinder_5 = shaperpy.makeCylinder(-5., 10.)
54 except myExcept,ec:
55   assert(ec.what() == "Cylinder builder :: radius is negative or null.")
56
57 try:
58   Cylinder_6 = shaperpy.makeCylinder(5., 0.)
59 except myExcept,ec:
60   assert(ec.what() == "Cylinder builder :: height is negative or null.")
61
62 try:
63   Cylinder_7 = shaperpy.makeCylinder(5., -10.)
64 except myExcept,ec:
65   assert(ec.what() == "Cylinder builder :: height is negative or null.")
66
67 try:
68   Cylinder_8 = shaperpy.makeCylinder(None, edgz, 5., 10.)
69 except myExcept,ec:
70   assert(ec.what() == "Cylinder builder :: the base point is not valid.")
71
72 try:
73   Cylinder_9 = shaperpy.makeCylinder(pnt1, None, 5., 10.)
74 except myExcept,ec:
75   assert(ec.what() == "Cylinder builder :: the axis is not valid.")
76
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.)
81
82 try:
83   Cylinder_18 = shaperpy.makeCylinder(0., 10., 45.)
84 except myExcept,ec:
85   assert(ec.what() == "Cylinder builder :: radius is negative or null.")
86
87 try:
88   Cylinder_19 = shaperpy.makeCylinder(-5., 10., 45.)
89 except myExcept,ec:
90   assert(ec.what() == "Cylinder builder :: radius is negative or null.")
91
92 try:
93   Cylinder_20 = shaperpy.makeCylinder(5., 0., 45.)
94 except myExcept,ec:
95   assert(ec.what() == "Cylinder builder :: height is negative or null.")
96
97 try:
98   Cylinder_21 = shaperpy.makeCylinder(5., -10., 45.)
99 except myExcept,ec:
100   assert(ec.what() == "Cylinder builder :: height is negative or null.")
101
102 try:
103   Cylinder_22 = shaperpy.makeCylinder(5., 10., 0.)
104 except myExcept,ec:
105   assert(ec.what() == "Cylinder builder :: angle is negative or null.")
106
107 try:
108   Cylinder_23 = shaperpy.makeCylinder(5., 10., -45.)
109 except myExcept,ec:
110   assert(ec.what() == "Cylinder builder :: angle is negative or null.")
111
112 try:
113   Cylinder_24 = shaperpy.makeCylinder(5., 10., 450.)
114 except myExcept,ec:
115   assert(ec.what() == "Cylinder builder :: angle greater than 360 degrees.")
116
117 try:
118   Cylinder_25 = shaperpy.makeCylinder(None, edgz, 5., 10., 90.)
119 except myExcept,ec:
120   assert(ec.what() == "Cylinder builder :: the base point is not valid.")
121
122 try:
123   Cylinder_26 = shaperpy.makeCylinder(pnt1, None, 5., 10., 90.)
124 except myExcept,ec:
125   assert(ec.what() == "Cylinder builder :: the axis is not valid.")