1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2021 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, or (at your option) any later version.
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
32 from salome.geom import geomBuilder
33 geompy = geomBuilder.New()
37 # -----------------------------------------------------------------------------
39 def MakeFace(lstEdges) :
41 Create a planar face from 4 edges
43 wire = geompy.MakeWire(lstEdges)
44 face = geompy.MakeFace(wire, 1)
47 # -----------------------------------------------------------------------------
53 ##epaisseurPlq = 0.150
55 ##hauteurFlanc = 0.380
56 ##epaisseurFlanc = 0.112
57 ##rayonConge = 0.150 - epaisseurFlanc
59 ##epaisseurFond = 0.162
61 ##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou)
71 rayonConge = 150 - epaisseurFlanc
75 posAxeTrou = hauteurFlanc - (180 + rayonTrou)
79 # ---- points, directions de base
81 p0 = geompy.MakeVertex(0., 0., 0.)
83 vx = geompy.MakeVectorDXDYDZ(100., 0., 0.)
84 vy = geompy.MakeVectorDXDYDZ(0., 100., 0.)
85 vz = geompy.MakeVectorDXDYDZ(0., 0., 100.)
87 # ---- ellipse du flanc
89 he = hauteurFlanc - 2*rayonConge
90 re = 0.5*(largeurPlq - epaisseurFond) - rayonConge
92 cose = math.sqrt(1. - sine*sine)
94 ve = geompy.MakeVectorDXDYDZ(sine, 0., cose)
95 cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he)
96 cyl1 = geompy.MakeRotation(cyl0, ve, 0.5)
97 cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose)
99 pbe = geompy.MakeVertex(3*he, -2*re, 3*he)
100 boxe = geompy.MakeBoxTwoPnt(p0, pbe)
102 cylcoup = geompy.MakeBoolean(cyle, boxe, 2)
105 aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"])
107 shape = geompy.MakeCopy(aretes[0])
108 aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge)
111 # -----------------------------------------------------------------------------
112 # ---- decoupage de la piece en volumes a 6 faces de 4 cotes
113 # -----------------------------------------------------------------------------
119 x1 = rayonConge + epaisseurFlanc
121 x2 = longueurPlq - rayonConge - epaisseurFlanc
122 x3h = longueurPlq - rayonConge
129 y1 = largeurPlq - epaisseurFond
132 y2p = largeurPlq + marge
137 z1m = epaisseurPlq - marge
139 z2 = epaisseurPlq + rayonConge
140 z3 = epaisseurPlq + 2*rayonConge
141 z4 = epaisseurPlq + hauteurFlanc
142 z4p = epaisseurPlq + hauteurFlanc + marge
144 zc = epaisseurPlq + posAxeTrou
145 zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3
146 zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3
148 # ---- decoupe du fond
150 p11 = geompy.MakeVertex(x1, y1m, z1)
151 p12 = geompy.MakeVertex(x1, y1m, z2)
152 p13 = geompy.MakeVertex(x1, y1m, z3)
153 p14 = geompy.MakeVertex(x1, y1m, z4)
154 pc1 = geompy.MakeVertex(xc, y1m, z1)
155 pc2 = geompy.MakeVertex(xc, y1m, zc2)
156 pc3 = geompy.MakeVertex(xc, y1m, zc3)
157 pcc = geompy.MakeVertex(xc, y1m, zc)
158 pc4 = geompy.MakeVertex(xc, y1m, z4)
159 p21 = geompy.MakeVertex(x2, y1m, z1)
160 p22 = geompy.MakeVertex(x2, y1m, z2)
161 p23 = geompy.MakeVertex(x2, y1m, z3)
162 p24 = geompy.MakeVertex(x2, y1m, z4)
163 pcf = geompy.MakeVertex(xc, y2p, zc)
165 arc2 = geompy.MakeArc(p12,pc2,p22)
166 arc3 = geompy.MakeArc(p13,pc3,p23)
168 segz1 = geompy.MakeVector(p11,p21)
169 segz41 = geompy.MakeVector(p14,pc4)
170 segz42 = geompy.MakeVector(pc4,p24)
171 segx11 = geompy.MakeVector(p11,p12)
172 segx12 = geompy.MakeVector(p12,p13)
173 segx13 = geompy.MakeVector(p13,p14)
174 segxc2 = geompy.MakeVector(pc1,pc2)
175 segxc3 = geompy.MakeVector(pc2,pc3)
176 segxc4 = geompy.MakeVector(pcc,pc4)
177 segx21 = geompy.MakeVector(p21,p22)
178 segx22 = geompy.MakeVector(p22,p23)
179 segx23 = geompy.MakeVector(p23,p24)
180 segx1c1 = geompy.MakeVector(p13,pcc)
181 segx1c2 = geompy.MakeVector(p14,pcc)
182 segx2c1 = geompy.MakeVector(p23,pcc)
183 segx2c2 = geompy.MakeVector(p24,pcc)
186 facef.append(MakeFace([segx13,segx1c2,segx1c1]))
187 facef.append(MakeFace([segx23,segx2c2,segx2c1]))
188 facef.append(MakeFace([segx2c2,segxc4,segz42]))
189 facef.append(MakeFace([segx1c2,segz41,segxc4]))
190 facef.append(MakeFace([segx1c1,arc3,segx2c1]))
191 facef.append(MakeFace([segx12,arc2,segx22,arc3]))
192 facef.append(MakeFace([segx11,segz1,segx21,arc2]))
194 vcccf = geompy.MakeVector(pcc, pcf)
198 decf.append(geompy.MakePrismVecH(face,vcccf,hcccf))
200 pc = geompy.MakeVertex(xc, 0., zc)
201 py2 = geompy.MakeVertex(xc, y2, zc)
202 axeCyl = geompy.MakeVector(pc, py2)
204 cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq)
205 cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi)
209 fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2))
210 fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2))
212 fondec.append(decf[id])
214 p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p)
215 p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p)
216 pxc = geompy.MakeVertex(xc,y0,z0)
217 bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p)
218 bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p)
222 fondec2.append(fondec[id])
224 fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1))
225 fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1))
227 # ----- autres blocs de decoupe
229 bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2)
230 bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2)
231 bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2)
232 bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2)
234 pcylx0 = geompy.MakeVertex(0., -marge, z2)
235 pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2)
236 pcyly0 = geompy.MakeVertex(-marge, 0., z2)
238 cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge)
239 cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge)
240 cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge)
242 bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2)
243 bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2)
244 bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2)
245 #NRI : inverse order of BOP
246 bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2)
247 bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2)
248 bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2)
250 pf1 = geompy.MakeVertex(0., y0h, z3)
251 pf2 = geompy.MakeVertex(0., y1, z3)
252 pf3 = geompy.MakeVertex(0., y1, z4)
253 pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4)
255 vf1 = geompy.MakeEdge(pf1, pf2)
256 vf2 = geompy.MakeEdge(pf2, pf3)
257 vf3 = geompy.MakeEdge(pf3, pf4)
259 faceFlanc = MakeFace([vf1,vf2,vf3,aShape])
261 flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc)
262 flanc2 = geompy.MakeCopy(flanc1)
263 flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.)
264 flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.)
266 # ---- constitution et decoupe des blocs
267 boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p)
271 blocs.append(geompy.MakeBoolean(boxfond2, dec, 1))
273 blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1))
274 blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1))
275 blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1))
276 blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1))
277 blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1))
278 blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1))
279 blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1))
280 blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1))
285 blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3))
286 blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3))
287 blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3))
288 blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3))
289 blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4))
290 blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4))
294 compbloc = geompy.MakeCompound(blocs)
295 idcomp = geompy.addToStudy(compbloc, "compbloc")
297 # ---- eliminer les faces en double, solid-->shell
299 compshell = geompy.MakeGlueFaces(compbloc,tol3d)
300 idcomp = geompy.addToStudy(compshell, "compshell")