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