]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_SWIG/GEOM_tube_geom.py
Salome HOME
Start potring to the VTK OpenGL2 backend.
[modules/geom.git] / src / GEOM_SWIG / GEOM_tube_geom.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 #==============================================================================
25 #  Info.
26 #  Bug (from script, bug)   : tube_geom_corrected.py, PAL5243
27 #  Modified                 : 25/11/2004
28 #  Author                   : Kovaltchuk Alexey
29 #  Project                  : PAL/SALOME
30 #==============================================================================
31 # Geometrie du cas test
32 #
33 import salome
34 salome.salome_init()
35 import GEOM
36 from salome.geom import geomBuilder
37 geompy = geomBuilder.New(salome.myStudy)
38
39 #
40 # base de l'assemblage
41 #
42 L_base = 300.
43 l_base = 150.
44 h_base = 75.
45 e_base = 6.
46
47 base_bot = geompy.MakeBox(0.,0.,0.,L_base,l_base,e_base)
48 base_top = geompy.MakeTranslation(base_bot,0.,0.,h_base-e_base)
49 base_front = geompy.MakeBox(0,0,0,L_base,e_base,h_base)
50 base_rear = geompy.MakeTranslation(base_front,0.,l_base,0.)
51
52 tmp = geompy.MakeBoolean(base_top,base_rear,3)
53 tmp = geompy.MakeBoolean(tmp,base_bot,3)
54 base = geompy.MakeBoolean(tmp,base_front,3)
55
56 geompy.addToStudy(base,"base")
57 #
58 # traverse
59 #
60 L_trav = 60.
61 h_trav = 300.
62 e_trav = 7.
63 marge = 15.
64
65 flange_left = geompy.MakeBox(0.,0.,0,e_trav,L_trav,h_trav)
66 flange_right = geompy.MakeTranslation(flange_left,L_trav-e_trav,0.,0.)
67 flange_front = geompy.MakeBox(0.,0.,0,L_trav,e_trav,h_trav)
68 flange_rear = geompy.MakeTranslation(flange_front,0.,L_trav-e_trav,0.)
69
70 tmp = geompy.MakeBoolean(flange_left,flange_rear,3)
71 tmp = geompy.MakeBoolean(tmp,flange_right,3)
72 flange = geompy.MakeBoolean(tmp,flange_front,3)
73 #
74 # left chamfer
75 #
76 import math
77 length = e_trav/math.sin(math.pi/4.)
78 p1 = geompy.MakeVertex(0,0,0)
79 p2 = geompy.MakeVertex(0,1,0)
80 yaxis = geompy.MakeVector(p1, p2)
81 cut_left = geompy.MakeBox(0.,-marge,0.,-length,L_trav+marge,length)
82 cut_left = geompy.MakeRotation(cut_left,yaxis,-math.pi/4.)
83 cut_left = geompy.MakeTranslation(cut_left,e_trav,0.,0.)
84 #
85 # right chamfer
86 #
87 symPlaneYZ = geompy.MakePlane(
88      geompy.MakeVertex(L_trav/2.,0.,0.),
89      geompy.MakeVector(p1,geompy.MakeVertex(1.,0.,0.)), 10000. )
90 cut_right = geompy.MakeMirrorByPlane(cut_left,symPlaneYZ)
91 #
92 # front chamfer
93 #
94 xaxis = geompy.MakeVector(p1,geompy.MakeVertex(1.,0.,0.))
95 cut_front = geompy.MakeBox(-marge,0.,0.,L_trav+marge,length,length)
96 cut_front = geompy.MakeRotation(cut_front,xaxis,3.*math.pi/4.)
97 cut_front = geompy.MakeTranslation(cut_front,0.,e_trav,0.)
98 #
99 # rear chamfer
100 #
101 symPlaneXZ = geompy.MakePlane(
102      geompy.MakeVertex(0.,L_trav/2.,0.),
103      geompy.MakeVector(p1,geompy.MakeVertex(0.,1.,0.)), 10000. )
104 cut_rear = geompy.MakeMirrorByPlane(cut_front,symPlaneXZ)
105 #
106 # chamfer
107 #
108 trav = geompy.MakeBoolean(flange,cut_left,2)
109 trav = geompy.MakeBoolean(trav,cut_right,2)
110 trav = geompy.MakeBoolean(trav,cut_front,2)
111 trav = geompy.MakeBoolean(trav,cut_rear,2)
112 trav = geompy.MakeTranslation(trav,
113                        L_base/2.-L_trav/2.,
114                        l_base/2.-L_trav/2.,
115                        h_base)
116 geompy.addToStudy(trav,"trav")
117 #
118 # Welding
119 #
120 ground = geompy.MakeBox(-1000.,-1000.,0.,1000.,1000.,-1000.)
121 weld_left = geompy.MakeBoolean(cut_left,ground,2)
122 weld_right = geompy.MakeBoolean(cut_right,ground,2)
123 weld_front = geompy.MakeBoolean(cut_front,ground,2)
124 weld_rear = geompy.MakeBoolean(cut_rear,ground,2)
125 #
126 # Assembly
127 #
128 coarse_weld = geompy.MakeBoolean(weld_left,weld_rear,3)
129 coarse_weld = geompy.MakeBoolean(coarse_weld,weld_right,3)
130 coarse_weld = geompy.MakeBoolean(coarse_weld,weld_front,3)
131 #
132 # Cleaners
133 #
134 left_cleaner = geompy.MakeBox(0.,-10*marge,0.,-10.*marge,10.*marge,10.*marge)
135 left_cleaner = geompy.MakeRotation(left_cleaner,yaxis,math.pi/4.)
136 left_cleaner = geompy.MakeTranslation(left_cleaner,-e_trav-2.*marge,0.,-2.*marge)
137
138 right_cleaner = geompy.MakeMirrorByPlane(left_cleaner,symPlaneYZ)
139
140 front_cleaner = geompy.MakeBox(-10*marge,0.,0.,10.*marge,10.*marge,10.*marge)
141 front_cleaner = geompy.MakeRotation(front_cleaner,xaxis,3.*math.pi/4.)
142 front_cleaner = geompy.MakeTranslation(front_cleaner,0.,2.*marge-e_trav,2.*marge)
143
144 rear_cleaner = geompy.MakeMirrorByPlane(front_cleaner,symPlaneXZ)
145 #
146 # Welding
147 #
148 weld = geompy.MakeBoolean(coarse_weld,left_cleaner,2)
149 weld = geompy.MakeBoolean(weld,rear_cleaner,2)
150 weld = geompy.MakeBoolean(weld,right_cleaner,2)
151 weld = geompy.MakeBoolean(weld,front_cleaner,2)
152 weld = geompy.MakeTranslation(weld,
153                        L_base/2.-L_trav/2.,
154                        l_base/2.-L_trav/2.,
155                        h_base)
156 weldId = geompy.addToStudy(weld,"weld")
157 #
158 # Assembly
159 #
160 assemblage = geompy.Partition([base ,weld ,trav])
161 assemblageId = geompy.addToStudy(assemblage, "assemblage")
162 salome.sg.updateObjBrowser(1)
163 #
164 # Display
165 #
166 ## gg.createAndDisplayGO(assemblageId)
167 ## gg.createAndDisplayGO(baseId)
168 ## gg.setTransparency(baseId,0.5)
169 ## gg.setDisplayMode(baseId,1)
170 ## gg.setColor(baseId,255,0,0)
171 ## gg.createAndDisplayGO(travId)
172 ## gg.setTransparency(travId,0.5)
173 ## gg.setDisplayMode(travId,1)
174 ## gg.setColor(travId,0,255,0)
175
176