1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 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
23 #==============================================================================
25 # Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781
26 # Modified : 25/11/2004
27 # Author : Kovaltchuk Alexey
28 # Project : PAL/SALOME
29 #==============================================================================
30 # Tetrahedrization of a geometry (box minus a inner cylinder).
31 # Hypothesis and algorithms for the mesh generation are not global:
32 # the mesh of some edges is thinner
41 # -----------------------------------------------------------------------------
54 Orig = geompy.MakeVertex(zero,zero,zero)
55 P0 = geompy.MakeVertex(a,a,zero)
56 P1 = geompy.MakeVertex(zero,demi,zero)
57 P2 = geompy.MakeVertex(ma,a,zero)
58 P3 = geompy.MakeVertex(mun,un,zero)
59 P4 = geompy.MakeVertex(un,un,zero)
60 P5 = geompy.MakeVertex(zero,zero,un)
62 arc = geompy.MakeArc(P0,P1,P2)
63 e1 = geompy.MakeEdge(P2,P3)
64 e2 = geompy.MakeEdge(P3,P4)
65 e3 = geompy.MakeEdge(P4,P0)
73 wire = geompy.MakeWire(list)
74 face = geompy.MakeFace(wire,1)
76 dir = geompy.MakeVector(Orig,P5)
77 vol1 = geompy.MakePipe(face,dir)
80 #dir = geom.MakeVector(Orig,P5)
81 vol2 = geompy.MakeRotation(vol1,dir,angle)
83 vol3 = geompy.MakeRotation(vol2,dir,angle)
85 vol4 = geompy.MakeRotation(vol3,dir,angle)
93 volComp = geompy.MakeCompound(list)
96 vol = geompy.MakeGlueFaces(volComp,tol3d)
97 idVol = geompy.addToStudy(vol,"volume")
99 print "Analysis of the final volume:"
100 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
101 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
102 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
104 print "number of Shells in the volume : ",len(subShellList)
105 print "number of Faces in the volume : ",len(subFaceList)
106 print "number of Edges in the volume : ",len(subEdgeList)
109 for k in range(len(subEdgeList)):
110 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
113 edgeZ.append(subEdgeList[0])
114 edgeZ.append(subEdgeList[3])
115 edgeZ.append(subEdgeList[10])
116 edgeZ.append(subEdgeList[11])
117 edgeZ.append(subEdgeList[20])
118 edgeZ.append(subEdgeList[21])
119 edgeZ.append(subEdgeList[28])
120 edgeZ.append(subEdgeList[31])
124 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
126 ### ---------------------------- SMESH --------------------------------------
127 smesh.SetCurrentStudy(salome.myStudy)
129 # ---- init a Mesh with the volume
131 mesh = smesh.Mesh(vol, "meshVolume")
133 # ---- set Hypothesis and Algorithm to main shape
135 print "-------------------------- NumberOfSegments the global one"
137 numberOfSegments = 10
139 regular1D = mesh.Segment()
140 regular1D.SetName("Wire Discretisation")
141 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
142 print hypNbSeg.GetName()
143 print hypNbSeg.GetId()
144 print hypNbSeg.GetNumberOfSegments()
145 smesh.SetName(hypNbSeg, "NumberOfSegments")
148 print "-------------------------- Quadrangle_2D"
150 quad2D=mesh.Quadrangle()
151 quad2D.SetName("Quadrangle_2D")
153 print "-------------------------- Hexa_3D"
155 hexa3D=mesh.Hexahedron()
156 hexa3D.SetName("Hexa_3D")
159 print "-------------------------- NumberOfSegments in the Z direction"
161 numberOfSegmentsZ = 40
164 print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
166 algo = mesh.Segment(edgeZ[i])
167 hyp = algo.NumberOfSegments(numberOfSegmentsZ)
168 smesh.SetName(hyp, "NumberOfSegmentsZ")
169 smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
172 salome.sg.updateObjBrowser(1)
174 print "-------------------------- compute the mesh of the volume"
180 ## log=mesh.GetLog(0) # no erase trace
181 ## for linelog in log:
183 print "Information about the MeshBox :"
184 print "Number of nodes : ", mesh.NbNodes()
185 print "Number of edges : ", mesh.NbEdges()
186 print "Number of faces : ", mesh.NbFaces()
187 print "Number of triangles : ", mesh.NbTriangles()
188 print "Number of volumes : ", mesh.NbVolumes()
189 print "Number of tetrahedrons: ", mesh.NbTetras()
191 print "problem when Computing the mesh"
193 salome.sg.updateObjBrowser(1)