1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # File : SMESH_fix_volute.py
25 # Author : Paul RASCLE, EDF
33 # -----------------------------------------------------------------------------
35 def MakeFace(lstEdges) :
37 Creates a planar face from 4 edges
39 wire = geompy.MakeWire(lstEdges)
40 face = geompy.MakeFace(wire, 1)
43 # -----------------------------------------------------------------------------
49 ##epaisseurPlq = 0.150
51 ##hauteurFlanc = 0.380
52 ##epaisseurFlanc = 0.112
53 ##rayonConge = 0.150 - epaisseurFlanc
55 ##epaisseurFond = 0.162
57 ##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou)
67 rayonConge = 150 - epaisseurFlanc
71 posAxeTrou = hauteurFlanc - (180 + rayonTrou)
75 # ---- points, directions de base
77 p0 = geompy.MakeVertex(0., 0., 0.)
79 vx = geompy.MakeVectorDXDYDZ(100., 0., 0.)
80 vy = geompy.MakeVectorDXDYDZ(0., 100., 0.)
81 vz = geompy.MakeVectorDXDYDZ(0., 0., 100.)
83 # ---- ellipse du flanc
85 he = hauteurFlanc - 2*rayonConge
86 re = 0.5*(largeurPlq - epaisseurFond) - rayonConge
88 cose = math.sqrt(1. - sine*sine)
90 ve = geompy.MakeVectorDXDYDZ(sine, 0., cose)
91 cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he)
92 cyl1 = geompy.MakeRotation(cyl0, ve, 0.5)
93 cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose)
95 pbe = geompy.MakeVertex(3*he, -2*re, 3*he)
96 boxe = geompy.MakeBoxTwoPnt(p0, pbe)
98 cylcoup = geompy.MakeBoolean(cyle, boxe, 2)
101 aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"])
103 shape = geompy.MakeCopy(aretes[0])
104 aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge)
107 # -----------------------------------------------------------------------------
108 # ---- decoupage de la piece en volumes a 6 faces de 4 cotes
109 # -----------------------------------------------------------------------------
115 x1 = rayonConge + epaisseurFlanc
117 x2 = longueurPlq - rayonConge - epaisseurFlanc
118 x3h = longueurPlq - rayonConge
125 y1 = largeurPlq - epaisseurFond
128 y2p = largeurPlq + marge
133 z1m = epaisseurPlq - marge
135 z2 = epaisseurPlq + rayonConge
136 z3 = epaisseurPlq + 2*rayonConge
137 z4 = epaisseurPlq + hauteurFlanc
138 z4p = epaisseurPlq + hauteurFlanc + marge
140 zc = epaisseurPlq + posAxeTrou
141 zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3
142 zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3
144 # ---- decoupe du fond
146 p11 = geompy.MakeVertex(x1, y1m, z1)
147 p12 = geompy.MakeVertex(x1, y1m, z2)
148 p13 = geompy.MakeVertex(x1, y1m, z3)
149 p14 = geompy.MakeVertex(x1, y1m, z4)
150 pc1 = geompy.MakeVertex(xc, y1m, z1)
151 pc2 = geompy.MakeVertex(xc, y1m, zc2)
152 pc3 = geompy.MakeVertex(xc, y1m, zc3)
153 pcc = geompy.MakeVertex(xc, y1m, zc)
154 pc4 = geompy.MakeVertex(xc, y1m, z4)
155 p21 = geompy.MakeVertex(x2, y1m, z1)
156 p22 = geompy.MakeVertex(x2, y1m, z2)
157 p23 = geompy.MakeVertex(x2, y1m, z3)
158 p24 = geompy.MakeVertex(x2, y1m, z4)
159 pcf = geompy.MakeVertex(xc, y2p, zc)
161 arc2 = geompy.MakeArc(p12,pc2,p22)
162 arc3 = geompy.MakeArc(p13,pc3,p23)
164 segz1 = geompy.MakeVector(p11,p21)
165 segz41 = geompy.MakeVector(p14,pc4)
166 segz42 = geompy.MakeVector(pc4,p24)
167 segx11 = geompy.MakeVector(p11,p12)
168 segx12 = geompy.MakeVector(p12,p13)
169 segx13 = geompy.MakeVector(p13,p14)
170 segxc2 = geompy.MakeVector(pc1,pc2)
171 segxc3 = geompy.MakeVector(pc2,pc3)
172 segxc4 = geompy.MakeVector(pcc,pc4)
173 segx21 = geompy.MakeVector(p21,p22)
174 segx22 = geompy.MakeVector(p22,p23)
175 segx23 = geompy.MakeVector(p23,p24)
176 segx1c1 = geompy.MakeVector(p13,pcc)
177 segx1c2 = geompy.MakeVector(p14,pcc)
178 segx2c1 = geompy.MakeVector(p23,pcc)
179 segx2c2 = geompy.MakeVector(p24,pcc)
182 facef.append(MakeFace([segx13,segx1c2,segx1c1]))
183 facef.append(MakeFace([segx23,segx2c2,segx2c1]))
184 facef.append(MakeFace([segx2c2,segxc4,segz42]))
185 facef.append(MakeFace([segx1c2,segz41,segxc4]))
186 facef.append(MakeFace([segx1c1,arc3,segx2c1]))
187 facef.append(MakeFace([segx12,arc2,segx22,arc3]))
188 facef.append(MakeFace([segx11,segz1,segx21,arc2]))
190 vcccf = geompy.MakeVector(pcc, pcf)
194 decf.append(geompy.MakePrismVecH(face,vcccf,hcccf))
196 pc = geompy.MakeVertex(xc, 0., zc)
197 py2 = geompy.MakeVertex(xc, y2, zc)
198 axeCyl = geompy.MakeVector(pc, py2)
200 cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq)
201 cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi)
205 fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2))
206 fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2))
208 fondec.append(decf[id])
210 p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p)
211 p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p)
212 pxc = geompy.MakeVertex(xc,y0,z0)
213 bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p)
214 bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p)
218 fondec2.append(fondec[id])
220 fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1))
221 fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1))
223 # ----- autres blocs de decoupe
225 bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2)
226 bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2)
227 bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2)
228 bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2)
230 pcylx0 = geompy.MakeVertex(0., -marge, z2)
231 pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2)
232 pcyly0 = geompy.MakeVertex(-marge, 0., z2)
234 cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge)
235 cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge)
236 cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge)
238 bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2)
239 bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2)
240 bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2)
241 #NRI : inverse order of BOP
242 bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2)
243 bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2)
244 bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2)
246 pf1 = geompy.MakeVertex(0., y0h, z3)
247 pf2 = geompy.MakeVertex(0., y1, z3)
248 pf3 = geompy.MakeVertex(0., y1, z4)
249 pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4)
251 vf1 = geompy.MakeEdge(pf1, pf2)
252 vf2 = geompy.MakeEdge(pf2, pf3)
253 vf3 = geompy.MakeEdge(pf3, pf4)
255 faceFlanc = MakeFace([vf1,vf2,vf3,aShape])
257 flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc)
258 flanc2 = geompy.MakeCopy(flanc1)
259 flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.)
260 flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.)
262 # ---- constitution et decoupe des blocs
263 boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p)
267 blocs.append(geompy.MakeBoolean(boxfond2, dec, 1))
269 blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1))
270 blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1))
271 blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1))
272 blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1))
273 blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1))
274 blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1))
275 blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1))
276 blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1))
281 blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3))
282 blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3))
283 blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3))
284 blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3))
285 blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4))
286 blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4))
290 compbloc = geompy.MakeCompound(blocs)
291 idcomp = geompy.addToStudy(compbloc, "compbloc")
293 # ---- eliminer les faces en double, solid-->shell
295 compshell = geompy.MakeGlueFaces(compbloc,tol3d)
296 idcomp = geompy.addToStudy(compshell, "compshell")