Back to index

salome-geom  6.5.0
GEOM_tube_geom.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #==============================================================================
00025 #  Info.
00026 #  Bug (from script, bug)   : tube_geom_corrected.py, PAL5243
00027 #  Modified                 : 25/11/2004
00028 #  Author                   : Kovaltchuk Alexey
00029 #  Project                  : PAL/SALOME
00030 #==============================================================================
00031 # Geometrie du cas test
00032 #
00033 import salome
00034 from geompy import *
00035 
00036 #
00037 # base de l'assemblage
00038 #
00039 L_base = 300.
00040 l_base = 150.
00041 h_base = 75.
00042 e_base = 6.
00043 
00044 base_bot = MakeBox(0.,0.,0.,L_base,l_base,e_base)
00045 base_top = MakeTranslation(base_bot,0.,0.,h_base-e_base)
00046 base_front = MakeBox(0,0,0,L_base,e_base,h_base)
00047 base_rear = MakeTranslation(base_front,0.,l_base,0.)
00048 
00049 tmp = MakeBoolean(base_top,base_rear,3)
00050 tmp = MakeBoolean(tmp,base_bot,3)
00051 base = MakeBoolean(tmp,base_front,3)
00052 
00053 addToStudy(base,"base")
00054 #
00055 # traverse
00056 #
00057 L_trav = 60.
00058 h_trav = 300.
00059 e_trav = 7.
00060 marge = 15.
00061 
00062 flange_left = MakeBox(0.,0.,0,e_trav,L_trav,h_trav)
00063 flange_right = MakeTranslation(flange_left,L_trav-e_trav,0.,0.)
00064 flange_front = MakeBox(0.,0.,0,L_trav,e_trav,h_trav)
00065 flange_rear = MakeTranslation(flange_front,0.,L_trav-e_trav,0.)
00066 
00067 tmp = MakeBoolean(flange_left,flange_rear,3)
00068 tmp = MakeBoolean(tmp,flange_right,3)
00069 flange = MakeBoolean(tmp,flange_front,3)
00070 #
00071 # left chamfer
00072 #
00073 import math
00074 length = e_trav/math.sin(math.pi/4.)
00075 p1 = MakeVertex(0,0,0)
00076 p2 = MakeVertex(0,1,0)
00077 yaxis = MakeVector(p1, p2)
00078 cut_left = MakeBox(0.,-marge,0.,-length,L_trav+marge,length)
00079 cut_left = MakeRotation(cut_left,yaxis,-math.pi/4.)
00080 cut_left = MakeTranslation(cut_left,e_trav,0.,0.)
00081 #
00082 # right chamfer
00083 #
00084 symPlaneYZ = MakePlane(
00085      MakeVertex(L_trav/2.,0.,0.),
00086      MakeVector(p1,MakeVertex(1.,0.,0.)), 10000. )
00087 cut_right = MakeMirrorByPlane(cut_left,symPlaneYZ)
00088 #
00089 # front chamfer
00090 #
00091 xaxis = MakeVector(p1,MakeVertex(1.,0.,0.))
00092 cut_front = MakeBox(-marge,0.,0.,L_trav+marge,length,length)
00093 cut_front = MakeRotation(cut_front,xaxis,3.*math.pi/4.)
00094 cut_front = MakeTranslation(cut_front,0.,e_trav,0.)
00095 #
00096 # rear chamfer
00097 #
00098 symPlaneXZ = MakePlane(
00099      MakeVertex(0.,L_trav/2.,0.),
00100      MakeVector(p1,MakeVertex(0.,1.,0.)), 10000. )
00101 cut_rear = MakeMirrorByPlane(cut_front,symPlaneXZ)
00102 #
00103 # chamfer
00104 #
00105 trav = MakeBoolean(flange,cut_left,2)
00106 trav = MakeBoolean(trav,cut_right,2)
00107 trav = MakeBoolean(trav,cut_front,2)
00108 trav = MakeBoolean(trav,cut_rear,2)
00109 trav = MakeTranslation(trav,
00110                        L_base/2.-L_trav/2.,
00111                        l_base/2.-L_trav/2.,
00112                        h_base)
00113 addToStudy(trav,"trav")
00114 #
00115 # Welding
00116 #
00117 ground = MakeBox(-1000.,-1000.,0.,1000.,1000.,-1000.)
00118 weld_left = MakeBoolean(cut_left,ground,2)
00119 weld_right = MakeBoolean(cut_right,ground,2)
00120 weld_front = MakeBoolean(cut_front,ground,2)
00121 weld_rear = MakeBoolean(cut_rear,ground,2)
00122 #
00123 # Assembly
00124 #
00125 coarse_weld = MakeBoolean(weld_left,weld_rear,3)
00126 coarse_weld = MakeBoolean(coarse_weld,weld_right,3)
00127 coarse_weld = MakeBoolean(coarse_weld,weld_front,3)
00128 #
00129 # Cleaners
00130 #
00131 left_cleaner = MakeBox(0.,-10*marge,0.,-10.*marge,10.*marge,10.*marge)
00132 left_cleaner = MakeRotation(left_cleaner,yaxis,math.pi/4.)
00133 left_cleaner = MakeTranslation(left_cleaner,-e_trav-2.*marge,0.,-2.*marge)
00134 
00135 right_cleaner = MakeMirrorByPlane(left_cleaner,symPlaneYZ)
00136 
00137 front_cleaner = MakeBox(-10*marge,0.,0.,10.*marge,10.*marge,10.*marge)
00138 front_cleaner = MakeRotation(front_cleaner,xaxis,3.*math.pi/4.)
00139 front_cleaner = MakeTranslation(front_cleaner,0.,2.*marge-e_trav,2.*marge)
00140 
00141 rear_cleaner = MakeMirrorByPlane(front_cleaner,symPlaneXZ)
00142 #
00143 # Welding
00144 #
00145 weld = MakeBoolean(coarse_weld,left_cleaner,2)
00146 weld = MakeBoolean(weld,rear_cleaner,2)
00147 weld = MakeBoolean(weld,right_cleaner,2)
00148 weld = MakeBoolean(weld,front_cleaner,2)
00149 weld = MakeTranslation(weld,
00150                        L_base/2.-L_trav/2.,
00151                        l_base/2.-L_trav/2.,
00152                        h_base)
00153 weldId = addToStudy(weld,"weld")
00154 #
00155 # Assembly
00156 #
00157 assemblage = Partition([base ,weld ,trav])
00158 assemblageId = addToStudy(assemblage, "assemblage")
00159 salome.sg.updateObjBrowser(1)
00160 #
00161 # Display
00162 #
00163 ## gg.createAndDisplayGO(assemblageId)
00164 ## gg.createAndDisplayGO(baseId)
00165 ## gg.setTransparency(baseId,0.5)
00166 ## gg.setDisplayMode(baseId,1)
00167 ## gg.setColor(baseId,255,0,0)
00168 ## gg.createAndDisplayGO(travId)
00169 ## gg.setTransparency(travId,0.5)
00170 ## gg.setDisplayMode(travId,1)
00171 ## gg.setColor(travId,0,255,0)
00172 
00173