Salome HOME
updated copyright message
[modules/shaper.git] / test.API / SHAPER / Primitives / TestAPI_Torus.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 email : webmaster.salome@opencascade.com
18 #
19
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
26
27 # Points
28 pnt1 = pnt(0., 0., 0.)
29 pnt2 = pnt(10., 10., 10.)
30
31 # Axis
32 yDir = direction(0.,10.,0.)
33 ax1 = axis(pnt1, yDir)
34
35 # Edges
36 edgaxis = edgeBuilder.line(ax1.dir().x(), ax1.dir().y(), ax1.dir().z())
37
38 Torus_1 = shaperpy.makeTorus(10., 5.)
39
40 try:
41   Torus_2 = shaperpy.makeTorus(0., 5.)
42 except myExcept as ec:
43   assert(ec.what() == "Torus builder :: radius is negative or null.")
44
45 try:
46   Torus_3 = shaperpy.makeTorus(10., 0.)
47 except myExcept as ec:
48   assert(ec.what() == "Torus builder :: ring radius is negative or null.")
49
50 try:
51   Torus_4 = shaperpy.makeTorus(5., 10.)
52 except myExcept as ec:
53   assert(ec.what() == "Torus builder :: ring radius is greater than the radius.")
54
55 Torus_5 = shaperpy.makeTorus(pnt2, edgaxis, 10., 5.)
56
57 try:
58   Torus_6 = shaperpy.makeTorus(None, edgaxis, 10., 5.)
59 except myExcept as ec:
60   assert(ec.what() == "Torus builder :: the base point is not valid.")
61
62 try:
63   Torus_7 = shaperpy.makeTorus(pnt2, None, 10., 5.)
64 except myExcept as ec:
65   assert(ec.what() == "Torus builder :: the axis is not valid.")
66
67 try:
68   Torus_8 = shaperpy.makeTorus(pnt2, edgaxis, 0., 5.)
69 except myExcept as ec:
70   assert(ec.what() == "Torus builder :: radius is negative or null.")
71
72 try:
73   Torus_8 = shaperpy.makeTorus(pnt2, edgaxis, 10., 0.)
74 except myExcept as ec:
75   assert(ec.what() == "Torus builder :: ring radius is negative or null.")