Back to index

salome-smesh  6.5.0
SMESH_fixation.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 #  File   : SMESH_fix_volute.py
00025 #  Author : Paul RASCLE, EDF
00026 #  Module : SMESH
00027 #  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH_SWIG/SMESH_fixation.py,v 1.12.2.2.10.2.8.1 2012-04-13 09:31:17 vsr Exp $
00028 #
00029 import salome
00030 import geompy
00031 import math
00032 
00033 # -----------------------------------------------------------------------------
00034 
00035 def MakeFace(lstEdges) :
00036     """
00037     Creates a planar face from 4 edges
00038     """
00039     wire = geompy.MakeWire(lstEdges)
00040     face = geompy.MakeFace(wire, 1)
00041     return face
00042 
00043 # -----------------------------------------------------------------------------
00044 
00045 # ---- dimensions
00046 
00047 ##longueurPlq  = 0.686
00048 ##largeurPlq   = 0.573
00049 ##epaisseurPlq = 0.150
00050 
00051 ##hauteurFlanc   = 0.380
00052 ##epaisseurFlanc = 0.112
00053 ##rayonConge   = 0.150 - epaisseurFlanc
00054 
00055 ##epaisseurFond = 0.162
00056 ##rayonTrou = 0.075
00057 ##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou)
00058 ##marge = 0.01
00059 ##tol3d = 1.e-5
00060 
00061 longueurPlq  = 686
00062 largeurPlq   = 573
00063 epaisseurPlq = 150
00064 
00065 hauteurFlanc   = 380
00066 epaisseurFlanc = 112
00067 rayonConge   = 150 - epaisseurFlanc
00068 
00069 epaisseurFond = 162
00070 rayonTrou = 75
00071 posAxeTrou = hauteurFlanc - (180 + rayonTrou)
00072 marge = 10
00073 tol3d = 1.e-3
00074 
00075 # ---- points, directions de base
00076 
00077 p0 = geompy.MakeVertex(0., 0., 0.)
00078 
00079 vx = geompy.MakeVectorDXDYDZ(100., 0., 0.)
00080 vy = geompy.MakeVectorDXDYDZ(0., 100., 0.)
00081 vz = geompy.MakeVectorDXDYDZ(0., 0., 100.)
00082 
00083 # ---- ellipse du flanc
00084 
00085 he = hauteurFlanc - 2*rayonConge
00086 re = 0.5*(largeurPlq - epaisseurFond) - rayonConge
00087 sine = re/he
00088 cose = math.sqrt(1. - sine*sine)
00089 
00090 ve = geompy.MakeVectorDXDYDZ(sine, 0., cose)
00091 cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he)
00092 cyl1 = geompy.MakeRotation(cyl0, ve, 0.5)
00093 cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose)
00094 
00095 pbe = geompy.MakeVertex(3*he, -2*re, 3*he)
00096 boxe = geompy.MakeBoxTwoPnt(p0, pbe)
00097 
00098 cylcoup = geompy.MakeBoolean(cyle, boxe, 2)
00099 
00100 aretes = []
00101 aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"])
00102 
00103 shape = geompy.MakeCopy(aretes[0])
00104 aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge)
00105 
00106 
00107 # -----------------------------------------------------------------------------
00108 # ---- decoupage de la piece en volumes a 6 faces de 4 cotes
00109 # -----------------------------------------------------------------------------
00110 
00111 # ---- cotes x
00112 
00113 x0  = 0.
00114 x0h = rayonConge
00115 x1  = rayonConge + epaisseurFlanc
00116 xc  = longueurPlq/2
00117 x2  = longueurPlq - rayonConge - epaisseurFlanc
00118 x3h = longueurPlq - rayonConge
00119 x3  = longueurPlq
00120 
00121 # ---- cotes y
00122 
00123 y0  = 0.
00124 y0h = rayonConge
00125 y1  = largeurPlq - epaisseurFond
00126 y1m = y1 - marge
00127 y2  = largeurPlq
00128 y2p = largeurPlq + marge
00129 
00130 # ---- cotes z
00131 
00132 z0  = 0.
00133 z1m = epaisseurPlq - marge
00134 z1  = epaisseurPlq
00135 z2  = epaisseurPlq + rayonConge
00136 z3  = epaisseurPlq + 2*rayonConge
00137 z4  = epaisseurPlq + hauteurFlanc
00138 z4p = epaisseurPlq + hauteurFlanc + marge
00139 
00140 zc  = epaisseurPlq + posAxeTrou
00141 zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3
00142 zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3
00143 
00144 # ---- decoupe du fond
00145 
00146 p11 = geompy.MakeVertex(x1, y1m, z1)
00147 p12 = geompy.MakeVertex(x1, y1m, z2)
00148 p13 = geompy.MakeVertex(x1, y1m, z3)
00149 p14 = geompy.MakeVertex(x1, y1m, z4)
00150 pc1 = geompy.MakeVertex(xc, y1m, z1)
00151 pc2 = geompy.MakeVertex(xc, y1m, zc2)
00152 pc3 = geompy.MakeVertex(xc, y1m, zc3)
00153 pcc = geompy.MakeVertex(xc, y1m, zc)
00154 pc4 = geompy.MakeVertex(xc, y1m, z4)
00155 p21 = geompy.MakeVertex(x2, y1m, z1)
00156 p22 = geompy.MakeVertex(x2, y1m, z2)
00157 p23 = geompy.MakeVertex(x2, y1m, z3)
00158 p24 = geompy.MakeVertex(x2, y1m, z4)
00159 pcf = geompy.MakeVertex(xc, y2p, zc)
00160 
00161 arc2 = geompy.MakeArc(p12,pc2,p22)
00162 arc3 = geompy.MakeArc(p13,pc3,p23)
00163 
00164 segz1  = geompy.MakeVector(p11,p21)
00165 segz41 = geompy.MakeVector(p14,pc4)
00166 segz42 = geompy.MakeVector(pc4,p24)
00167 segx11 = geompy.MakeVector(p11,p12)
00168 segx12 = geompy.MakeVector(p12,p13)
00169 segx13 = geompy.MakeVector(p13,p14)
00170 segxc2 = geompy.MakeVector(pc1,pc2)
00171 segxc3 = geompy.MakeVector(pc2,pc3)
00172 segxc4 = geompy.MakeVector(pcc,pc4)
00173 segx21 = geompy.MakeVector(p21,p22)
00174 segx22 = geompy.MakeVector(p22,p23)
00175 segx23 = geompy.MakeVector(p23,p24)
00176 segx1c1 = geompy.MakeVector(p13,pcc)
00177 segx1c2 = geompy.MakeVector(p14,pcc)
00178 segx2c1 = geompy.MakeVector(p23,pcc)
00179 segx2c2 = geompy.MakeVector(p24,pcc)
00180 
00181 facef = []
00182 facef.append(MakeFace([segx13,segx1c2,segx1c1]))
00183 facef.append(MakeFace([segx23,segx2c2,segx2c1]))
00184 facef.append(MakeFace([segx2c2,segxc4,segz42]))
00185 facef.append(MakeFace([segx1c2,segz41,segxc4]))
00186 facef.append(MakeFace([segx1c1,arc3,segx2c1]))
00187 facef.append(MakeFace([segx12,arc2,segx22,arc3]))
00188 facef.append(MakeFace([segx11,segz1,segx21,arc2]))
00189 
00190 vcccf = geompy.MakeVector(pcc, pcf)
00191 hcccf = y2p - y1m
00192 decf = []
00193 for face in facef:
00194     decf.append(geompy.MakePrismVecH(face,vcccf,hcccf))
00195 
00196 pc  = geompy.MakeVertex(xc, 0., zc)
00197 py2 = geompy.MakeVertex(xc, y2, zc)
00198 axeCyl = geompy.MakeVector(pc, py2)
00199 
00200 cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq)
00201 cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi)
00202 
00203 fondec = []
00204 for id in (0,1,2,3):
00205     fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2))
00206 fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2))
00207 for id in (5,6):
00208     fondec.append(decf[id])
00209 
00210 p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p)
00211 p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p)
00212 pxc = geompy.MakeVertex(xc,y0,z0)
00213 bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p)
00214 bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p)
00215 
00216 fondec2 = []
00217 for id in (0,1,2,3):
00218     fondec2.append(fondec[id])
00219 for id in (4,5,6):
00220     fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1))
00221     fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1))
00222 
00223 # ----- autres blocs de decoupe
00224 
00225 bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2)
00226 bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2)
00227 bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2)
00228 bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2)
00229 
00230 pcylx0 = geompy.MakeVertex(0., -marge, z2)
00231 pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2)
00232 pcyly0 = geompy.MakeVertex(-marge, 0., z2)
00233 
00234 cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge)
00235 cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge)
00236 cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge)
00237 
00238 bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2)
00239 bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2)
00240 bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2)
00241 #NRI : inverse order of BOP
00242 bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2)
00243 bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2)
00244 bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2)
00245 
00246 pf1 = geompy.MakeVertex(0., y0h, z3)
00247 pf2 = geompy.MakeVertex(0., y1, z3)
00248 pf3 = geompy.MakeVertex(0., y1, z4)
00249 pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4)
00250 
00251 vf1 = geompy.MakeEdge(pf1, pf2)
00252 vf2 = geompy.MakeEdge(pf2, pf3)
00253 vf3 = geompy.MakeEdge(pf3, pf4)
00254 
00255 faceFlanc = MakeFace([vf1,vf2,vf3,aShape])
00256 
00257 flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc)
00258 flanc2 = geompy.MakeCopy(flanc1)
00259 flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.)
00260 flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.)
00261 
00262 # ---- constitution et decoupe des blocs
00263 boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p)
00264 
00265 blocs = []
00266 for dec in fondec2:
00267     blocs.append(geompy.MakeBoolean(boxfond2, dec, 1))
00268 
00269 blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1))
00270 blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1))
00271 blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1))
00272 blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1))
00273 blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1))
00274 blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1))
00275 blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1))
00276 blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1))
00277 blocs.append(bcong2)
00278 blocs.append(bcong4)
00279 blocs.append(bcong1)
00280 blocs.append(bcong3)
00281 blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3))
00282 blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3))
00283 blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3))
00284 blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3))
00285 blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4))
00286 blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4))
00287 blocs.append(flanc1)
00288 blocs.append(flanc2)
00289 
00290 compbloc = geompy.MakeCompound(blocs)
00291 idcomp = geompy.addToStudy(compbloc, "compbloc")
00292 
00293 # ---- eliminer les faces en double, solid-->shell
00294 
00295 compshell = geompy.MakeGlueFaces(compbloc,tol3d)
00296 idcomp = geompy.addToStudy(compshell, "compshell")