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