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