Back to index

salome-geom  6.5.0
GEOM_tube_geom_gg2.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_gg2_corrected.py, PAL5243
00027 #  Modified                 : 25/11/2004
00028 #  Author                   : Kovaltchuk Alexey
00029 #  Project                  : PAL/SALOME
00030 #==============================================================================
00031 # Geometrie du cas test
00032 #
00033 from geompy import *
00034 import salome
00035 #
00036 # base de l'assemblage
00037 #
00038 L_base = 300.
00039 l_base = 150.
00040 h_base = 75.
00041 e_base = 6.
00042 
00043 base_bot = MakeBox(0.,0.,0.,L_base,l_base,e_base)
00044 base_top = MakeTranslation(base_bot,0.,0.,h_base-e_base)
00045 base_front = MakeBox(0,0,0,L_base,e_base,h_base)
00046 base_rear = MakeTranslation(base_front,0.,l_base,0.)
00047 
00048 tmp = MakeBoolean(base_top,base_rear,3)
00049 tmp = MakeBoolean(tmp,base_bot,3)
00050 base = MakeBoolean(tmp,base_front,3)
00051 
00052 baseId = addToStudy(base,"base")
00053 #
00054 # traverse
00055 #
00056 L_trav = 60.
00057 h_trav = 300.
00058 e_trav = 7.
00059 marge = 15.
00060 
00061 flange_left = MakeBox(0.,0.,0,e_trav,L_trav,h_trav)
00062 flange_right = MakeTranslation(flange_left,L_trav-e_trav,0.,0.)
00063 flange_front = MakeBox(0.,0.,0,L_trav,e_trav,h_trav)
00064 flange_rear = MakeTranslation(flange_front,0.,L_trav-e_trav,0.)
00065 
00066 tmp = MakeBoolean(flange_left,flange_rear,3)
00067 tmp = MakeBoolean(tmp,flange_right,3)
00068 flange = MakeBoolean(tmp,flange_front,3)
00069 #
00070 # left chamfer
00071 #
00072 import math
00073 length = e_trav/math.sin(math.pi/4.)
00074 yaxis = MakeVectorDXDYDZ(0.,1.,0.)
00075 cut_left = MakeBox(0.,-marge,0.,-length,L_trav+marge,length)
00076 cut_left = MakeRotation(cut_left,yaxis,-math.pi/4.)
00077 cut_left = MakeTranslation(cut_left,e_trav,0.,0.)
00078 #
00079 # right chamfer
00080 #
00081 symPlaneYZ = MakePlane(
00082      MakeVertex(L_trav/2.,0.,0.),
00083      MakeVectorDXDYDZ(1.,0.,0.), 10000. )
00084 cut_right = MakeMirrorByPlane(cut_left,symPlaneYZ)
00085 #
00086 # front chamfer
00087 #
00088 xaxis = MakeVectorDXDYDZ(1.,0.,0.)
00089 cut_front = MakeBox(-marge,0.,0.,L_trav+marge,length,length)
00090 cut_front = MakeRotation(cut_front,xaxis,3.*math.pi/4.)
00091 cut_front = MakeTranslation(cut_front,0.,e_trav,0.)
00092 #
00093 # rear chamfer
00094 #
00095 symPlaneXZ = MakePlane(
00096      MakeVertex(0.,L_trav/2.,0.),
00097      MakeVectorDXDYDZ(0.,1.,0.), 10000. )
00098 cut_rear = MakeMirrorByPlane(cut_front,symPlaneXZ)
00099 #
00100 # chamfer
00101 #
00102 trav = MakeBoolean(flange,cut_left,2)
00103 trav = MakeBoolean(trav,cut_right,2)
00104 trav = MakeBoolean(trav,cut_front,2)
00105 trav = MakeBoolean(trav,cut_rear,2)
00106 trav = MakeTranslation(trav,
00107                        L_base/2.-L_trav/2.,
00108                        l_base/2.-L_trav/2.,
00109                        h_base)
00110 travId = addToStudy(trav,"trav")
00111 #
00112 # Welding
00113 #
00114 ground = MakeBox(-1000.,-1000.,0.,1000.,1000.,-1000.)
00115 weld_left = MakeBoolean(cut_left,ground,2)
00116 weld_right = MakeBoolean(cut_right,ground,2)
00117 weld_front = MakeBoolean(cut_front,ground,2)
00118 weld_rear = MakeBoolean(cut_rear,ground,2)
00119 #
00120 # Assembly
00121 #
00122 coarse_weld = MakeBoolean(weld_left,weld_rear,3)
00123 coarse_weld = MakeBoolean(coarse_weld,weld_right,3)
00124 coarse_weld = MakeBoolean(coarse_weld,weld_front,3)
00125 #
00126 # Cleaners
00127 #
00128 left_cleaner = MakeBox(0.,-10*marge,0.,-10.*marge,10.*marge,10.*marge)
00129 left_cleaner = MakeRotation(left_cleaner,yaxis,math.pi/4.)
00130 left_cleaner = MakeTranslation(left_cleaner,-e_trav-2.*marge,0.,-2.*marge)
00131 
00132 right_cleaner = MakeMirrorByPlane(left_cleaner,symPlaneYZ)
00133 
00134 front_cleaner = MakeBox(-10*marge,0.,0.,10.*marge,10.*marge,10.*marge)
00135 front_cleaner = MakeRotation(front_cleaner,xaxis,3.*math.pi/4.)
00136 front_cleaner = MakeTranslation(front_cleaner,0.,2.*marge-e_trav,2.*marge)
00137 
00138 rear_cleaner = MakeMirrorByPlane(front_cleaner,symPlaneXZ)
00139 #
00140 # Welding
00141 #
00142 weld = MakeBoolean(coarse_weld,left_cleaner,2)
00143 weld = MakeBoolean(weld,rear_cleaner,2)
00144 weld = MakeBoolean(weld,right_cleaner,2)
00145 weld = MakeBoolean(weld,front_cleaner,2)
00146 weld = MakeTranslation(weld,
00147                        L_base/2.-L_trav/2.,
00148                        l_base/2.-L_trav/2.,
00149                        h_base)
00150 weldId = addToStudy(weld,"weld")
00151 #
00152 # Assembly
00153 #
00154 #assemblage = MakePartition([base.,weld.GetName()])
00155 assemblage = MakePartition([base,weld])
00156 addToStudy(assemblage, "base+weld")
00157 #print assemblage.GetName()
00158 #print trav.GetName()
00159 #assemblage = MakePartition([assemblage.GetName(),trav.GetName()])
00160 assemblage = MakePartition([assemblage,trav])
00161 assemblageId = addToStudy(assemblage, "assemblage")
00162 
00163 #
00164 # Display
00165 #
00166 gg = ImportComponentGUI("GEOM")
00167 import salome_ComponentGUI
00168 if not isinstance(gg, type(salome_ComponentGUI)):
00169     gg.initGeomGen()
00170     gg.createAndDisplayGO(baseId)
00171     gg.setTransparency(baseId,0.5)
00172     gg.setDisplayMode(baseId,1)
00173     gg.setColor(baseId,255,0,0)
00174     gg.createAndDisplayGO(travId)
00175     gg.setTransparency(travId,0.5)
00176     gg.setDisplayMode(travId,1)
00177     gg.setColor(travId,255,0,0)
00178     gg.createAndDisplayGO(weldId)
00179     gg.setTransparency(weldId,0.5)
00180     gg.setDisplayMode(weldId,1)
00181     gg.setColor(weldId,0,0,255)