1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #==============================================================================
24 # Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781
25 # Modified : 25/11/2004
26 # Author : Kovaltchuk Alexey
27 # Project : PAL/SALOME
28 #==============================================================================
29 # Tetrahedrization of a geometry (box minus a inner cylinder).
30 # Hypothesis and algorithms for the mesh generation are not global:
31 # the mesh of some edges is thinner
40 # -----------------------------------------------------------------------------
53 Orig = geompy.MakeVertex(zero,zero,zero)
54 P0 = geompy.MakeVertex(a,a,zero)
55 P1 = geompy.MakeVertex(zero,demi,zero)
56 P2 = geompy.MakeVertex(ma,a,zero)
57 P3 = geompy.MakeVertex(mun,un,zero)
58 P4 = geompy.MakeVertex(un,un,zero)
59 P5 = geompy.MakeVertex(zero,zero,un)
61 arc = geompy.MakeArc(P0,P1,P2)
62 e1 = geompy.MakeEdge(P2,P3)
63 e2 = geompy.MakeEdge(P3,P4)
64 e3 = geompy.MakeEdge(P4,P0)
72 wire = geompy.MakeWire(list)
73 face = geompy.MakeFace(wire,1)
75 dir = geompy.MakeVector(Orig,P5)
76 vol1 = geompy.MakePipe(face,dir)
79 #dir = geom.MakeVector(Orig,P5)
80 vol2 = geompy.MakeRotation(vol1,dir,angle)
82 vol3 = geompy.MakeRotation(vol2,dir,angle)
84 vol4 = geompy.MakeRotation(vol3,dir,angle)
92 volComp = geompy.MakeCompound(list)
95 vol = geompy.MakeGlueFaces(volComp,tol3d)
96 idVol = geompy.addToStudy(vol,"volume")
98 print "Analysis of the final volume:"
99 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
100 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
101 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
103 print "number of Shells in the volume : ",len(subShellList)
104 print "number of Faces in the volume : ",len(subFaceList)
105 print "number of Edges in the volume : ",len(subEdgeList)
108 for k in range(len(subEdgeList)):
109 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
112 edgeZ.append(subEdgeList[0])
113 edgeZ.append(subEdgeList[3])
114 edgeZ.append(subEdgeList[10])
115 edgeZ.append(subEdgeList[11])
116 edgeZ.append(subEdgeList[20])
117 edgeZ.append(subEdgeList[21])
118 edgeZ.append(subEdgeList[28])
119 edgeZ.append(subEdgeList[31])
123 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
125 ### ---------------------------- SMESH --------------------------------------
127 # ---- init a Mesh with the volume
129 mesh = smesh.Mesh(vol, "meshVolume")
131 # ---- set Hypothesis and Algorithm to main shape
133 print "-------------------------- NumberOfSegments the global one"
135 numberOfSegments = 10
137 regular1D = mesh.Segment()
138 regular1D.SetName("Wire Discretisation")
139 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
140 print hypNbSeg.GetName()
141 print hypNbSeg.GetId()
142 print hypNbSeg.GetNumberOfSegments()
143 smesh.SetName(hypNbSeg, "NumberOfSegments")
146 print "-------------------------- Quadrangle_2D"
148 quad2D=mesh.Quadrangle()
149 quad2D.SetName("Quadrangle_2D")
151 print "-------------------------- Hexa_3D"
153 hexa3D=mesh.Hexahedron()
154 hexa3D.SetName("Hexa_3D")
157 print "-------------------------- NumberOfSegments in the Z direction"
159 numberOfSegmentsZ = 40
162 print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
164 algo = mesh.Segment(edgeZ[i])
165 hyp = algo.NumberOfSegments(numberOfSegmentsZ)
166 smesh.SetName(hyp, "NumberOfSegmentsZ")
167 smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
170 salome.sg.updateObjBrowser(1)
172 print "-------------------------- compute the mesh of the volume"
178 ## log=mesh.GetLog(0) # no erase trace
179 ## for linelog in log:
181 print "Information about the MeshBox :"
182 print "Number of nodes : ", mesh.NbNodes()
183 print "Number of edges : ", mesh.NbEdges()
184 print "Number of faces : ", mesh.NbFaces()
185 print "Number of triangles : ", mesh.NbTriangles()
186 print "Number of volumes : ", mesh.NbVolumes()
187 print "Number of tetrahedrons: ", mesh.NbTetras()
189 print "problem when Computing the mesh"
191 salome.sg.updateObjBrowser(1)