Salome HOME
5a1aaa5c245410318fb9152861a6f7799a9f5bda
[modules/shaper.git] / test.API / SHAPER / Primitives / TestAPI_Cone.py
1 # Copyright (C) 2014-2022  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 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 Cone_1 = shaperpy.makeCone(5., 10., 10.)
39 Cone_2 = shaperpy.makeCone(0., 10., 10.)
40 Cone_3 = shaperpy.makeCone(5., 0., 10.)
41
42 try:
43   Cone_4 = shaperpy.makeCone(5., 10., 0.)
44 except myExcept as ec:
45   assert(ec.what() == "Cone builder :: height is negative or null.")
46
47 Cone_5 = shaperpy.makeCone(pnt2, edgaxis, 5., 10., 10.)
48 Cone_6 = shaperpy.makeCone(pnt2, edgaxis, 0., 10., 10.)
49 Cone_7 = shaperpy.makeCone(pnt2, edgaxis, 5., 0., 10.)
50
51 try:
52   Cone_8 = shaperpy.makeCone(None, edgaxis, 5., 10., 10.)
53 except myExcept as ec:
54   assert(ec.what() == "Cone builder :: the base point is not valid.")
55
56 try:
57   Cone_9 = shaperpy.makeCone(pnt2, None, 5., 10., 10.)
58 except myExcept as ec:
59   assert(ec.what() == "Cone builder :: the axis is not valid.")
60
61 try:
62   Cone_10 = shaperpy.makeCone(pnt2, edgaxis, 5., 10., 0.)
63 except myExcept as ec:
64   assert(ec.what() == "Cone builder :: height is negative or null.")