Salome HOME
830ce7769946cfa618fbf3caf8a74a474148169e
[modules/smesh.git] / src / SMESH_SWIG / SMESH_test3.py
1 #! /usr/bin/python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 #  File   : SMESH_test3.py
25 #  Module : SMESH
26 #import salome
27 #
28 import math
29 import geompy
30
31 pi = math.pi
32
33 # ---------------------------------------------
34 xa = math.sin(pi/12)
35 ya = 0
36 za = math.cos(pi/12)
37
38 xb = 0
39 yb = math.sin(pi/18)
40 zb = math.cos(pi/18)
41
42 xc = math.cos(-pi/18)
43 yc = 0
44 zc = math.sin(-pi/18)
45
46 rc1 = 150
47 rc2 = 150
48 rc3 = 150
49 rc4 = 300
50
51 hc1 = 300
52 hc2 = 2*hc1
53 hc3 = 2*hc1
54 hc4 = 2*hc1
55
56 # ---------------------------------------------
57 point_0 = geompy.MakeVertex(0, 0, 0)
58 point_z = geompy.MakeVertex(0, 0, 1)
59
60 point_a = geompy.MakeVertex(xa, ya, za)
61 point_b = geompy.MakeVertex(xb, yb, zb)
62 point_c = geompy.MakeVertex(xc, yc, zc)
63
64 dir_z = geompy.MakeVector(point_0, point_z)
65 dir_a = geompy.MakeVector(point_0, point_a)
66 dir_b = geompy.MakeVector(point_0, point_b)
67 dir_c = geompy.MakeVector(point_0, point_c)
68
69 axe_z = dir_z
70 axe_a = dir_a
71 axe_b = dir_b
72 axe_c = dir_c
73
74 cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1)
75
76 cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2)
77 cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1)
78
79 cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3)
80 cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1)
81
82 cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4)
83 cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2)
84 cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0)
85 cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4)
86
87 inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common
88
89 blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut
90 blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2)
91
92 blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common
93
94 idblob = geompy.addToStudy(blob,"blob")
95 #idc = geompy.addToStudy(cyl_c,"cyl_c")
96 #idd = geompy.addToStudy(cyl_d,"cyl_d")