1 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_fix_volute.py
23 # Author : Paul RASCLE, EDF
31 # -----------------------------------------------------------------------------
33 def MakeFace(lstEdges) :
35 Creates a planar face from 4 edges
37 wire = geompy.MakeWire(lstEdges)
38 face = geompy.MakeFace(wire, 1)
41 # -----------------------------------------------------------------------------
47 ##epaisseurPlq = 0.150
49 ##hauteurFlanc = 0.380
50 ##epaisseurFlanc = 0.112
51 ##rayonConge = 0.150 - epaisseurFlanc
53 ##epaisseurFond = 0.162
55 ##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou)
65 rayonConge = 150 - epaisseurFlanc
69 posAxeTrou = hauteurFlanc - (180 + rayonTrou)
73 # ---- points, directions de base
75 p0 = geompy.MakeVertex(0., 0., 0.)
77 vx = geompy.MakeVectorDXDYDZ(100., 0., 0.)
78 vy = geompy.MakeVectorDXDYDZ(0., 100., 0.)
79 vz = geompy.MakeVectorDXDYDZ(0., 0., 100.)
81 # ---- ellipse du flanc
83 he = hauteurFlanc - 2*rayonConge
84 re = 0.5*(largeurPlq - epaisseurFond) - rayonConge
86 cose = math.sqrt(1. - sine*sine)
88 ve = geompy.MakeVectorDXDYDZ(sine, 0., cose)
89 cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he)
90 cyl1 = geompy.MakeRotation(cyl0, ve, 0.5)
91 cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose)
93 pbe = geompy.MakeVertex(3*he, -2*re, 3*he)
94 boxe = geompy.MakeBoxTwoPnt(p0, pbe)
96 cylcoup = geompy.MakeBoolean(cyle, boxe, 2)
99 aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"])
101 shape = geompy.MakeCopy(aretes[0])
102 aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge)
105 # -----------------------------------------------------------------------------
106 # ---- decoupage de la piece en volumes a 6 faces de 4 cotes
107 # -----------------------------------------------------------------------------
113 x1 = rayonConge + epaisseurFlanc
115 x2 = longueurPlq - rayonConge - epaisseurFlanc
116 x3h = longueurPlq - rayonConge
123 y1 = largeurPlq - epaisseurFond
126 y2p = largeurPlq + marge
131 z1m = epaisseurPlq - marge
133 z2 = epaisseurPlq + rayonConge
134 z3 = epaisseurPlq + 2*rayonConge
135 z4 = epaisseurPlq + hauteurFlanc
136 z4p = epaisseurPlq + hauteurFlanc + marge
138 zc = epaisseurPlq + posAxeTrou
139 zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3
140 zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3
142 # ---- decoupe du fond
144 p11 = geompy.MakeVertex(x1, y1m, z1)
145 p12 = geompy.MakeVertex(x1, y1m, z2)
146 p13 = geompy.MakeVertex(x1, y1m, z3)
147 p14 = geompy.MakeVertex(x1, y1m, z4)
148 pc1 = geompy.MakeVertex(xc, y1m, z1)
149 pc2 = geompy.MakeVertex(xc, y1m, zc2)
150 pc3 = geompy.MakeVertex(xc, y1m, zc3)
151 pcc = geompy.MakeVertex(xc, y1m, zc)
152 pc4 = geompy.MakeVertex(xc, y1m, z4)
153 p21 = geompy.MakeVertex(x2, y1m, z1)
154 p22 = geompy.MakeVertex(x2, y1m, z2)
155 p23 = geompy.MakeVertex(x2, y1m, z3)
156 p24 = geompy.MakeVertex(x2, y1m, z4)
157 pcf = geompy.MakeVertex(xc, y2p, zc)
159 arc2 = geompy.MakeArc(p12,pc2,p22)
160 arc3 = geompy.MakeArc(p13,pc3,p23)
162 segz1 = geompy.MakeVector(p11,p21)
163 segz41 = geompy.MakeVector(p14,pc4)
164 segz42 = geompy.MakeVector(pc4,p24)
165 segx11 = geompy.MakeVector(p11,p12)
166 segx12 = geompy.MakeVector(p12,p13)
167 segx13 = geompy.MakeVector(p13,p14)
168 segxc2 = geompy.MakeVector(pc1,pc2)
169 segxc3 = geompy.MakeVector(pc2,pc3)
170 segxc4 = geompy.MakeVector(pcc,pc4)
171 segx21 = geompy.MakeVector(p21,p22)
172 segx22 = geompy.MakeVector(p22,p23)
173 segx23 = geompy.MakeVector(p23,p24)
174 segx1c1 = geompy.MakeVector(p13,pcc)
175 segx1c2 = geompy.MakeVector(p14,pcc)
176 segx2c1 = geompy.MakeVector(p23,pcc)
177 segx2c2 = geompy.MakeVector(p24,pcc)
180 facef.append(MakeFace([segx13,segx1c2,segx1c1]))
181 facef.append(MakeFace([segx23,segx2c2,segx2c1]))
182 facef.append(MakeFace([segx2c2,segxc4,segz42]))
183 facef.append(MakeFace([segx1c2,segz41,segxc4]))
184 facef.append(MakeFace([segx1c1,arc3,segx2c1]))
185 facef.append(MakeFace([segx12,arc2,segx22,arc3]))
186 facef.append(MakeFace([segx11,segz1,segx21,arc2]))
188 vcccf = geompy.MakeVector(pcc, pcf)
192 decf.append(geompy.MakePrismVecH(face,vcccf,hcccf))
194 pc = geompy.MakeVertex(xc, 0., zc)
195 py2 = geompy.MakeVertex(xc, y2, zc)
196 axeCyl = geompy.MakeVector(pc, py2)
198 cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq)
199 cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi)
203 fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2))
204 fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2))
206 fondec.append(decf[id])
208 p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p)
209 p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p)
210 pxc = geompy.MakeVertex(xc,y0,z0)
211 bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p)
212 bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p)
216 fondec2.append(fondec[id])
218 fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1))
219 fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1))
221 # ----- autres blocs de decoupe
223 bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2)
224 bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2)
225 bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2)
226 bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2)
228 pcylx0 = geompy.MakeVertex(0., -marge, z2)
229 pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2)
230 pcyly0 = geompy.MakeVertex(-marge, 0., z2)
232 cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge)
233 cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge)
234 cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge)
236 bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2)
237 bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2)
238 bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2)
239 #NRI : inverse order of BOP
240 bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2)
241 bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2)
242 bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2)
244 pf1 = geompy.MakeVertex(0., y0h, z3)
245 pf2 = geompy.MakeVertex(0., y1, z3)
246 pf3 = geompy.MakeVertex(0., y1, z4)
247 pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4)
249 vf1 = geompy.MakeEdge(pf1, pf2)
250 vf2 = geompy.MakeEdge(pf2, pf3)
251 vf3 = geompy.MakeEdge(pf3, pf4)
253 faceFlanc = MakeFace([vf1,vf2,vf3,aShape])
255 flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc)
256 flanc2 = geompy.MakeCopy(flanc1)
257 flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.)
258 flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.)
260 # ---- constitution et decoupe des blocs
261 boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p)
265 blocs.append(geompy.MakeBoolean(boxfond2, dec, 1))
267 blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1))
268 blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1))
269 blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1))
270 blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1))
271 blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1))
272 blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1))
273 blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1))
274 blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1))
279 blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3))
280 blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3))
281 blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3))
282 blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3))
283 blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4))
284 blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4))
288 compbloc = geompy.MakeCompound(blocs)
289 idcomp = geompy.addToStudy(compbloc, "compbloc")
291 # ---- eliminer les faces en double, solid-->shell
293 compshell = geompy.MakeGlueFaces(compbloc,tol3d)
294 idcomp = geompy.addToStudy(compshell, "compshell")