1 # Copyright (C) 2005 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #==============================================================================
22 # Bug (from script, bug) : SMESH_demo_hexa2_upd.py, PAL6781
23 # Modified : 25/11/2004
24 # Author : Kovaltchuk Alexey
25 # Project : PAL/SALOME
26 #==============================================================================
27 # Tetrahedrization of a geometry (box minus a inner cylinder).
28 # Hypothesis and algorithms for the mesh generation are not global:
29 # the mesh of some edges is thinner
39 # -----------------------------------------------------------------------------
52 Orig = geompy.MakeVertex(zero,zero,zero)
53 P0 = geompy.MakeVertex(a,a,zero)
54 P1 = geompy.MakeVertex(zero,demi,zero)
55 P2 = geompy.MakeVertex(ma,a,zero)
56 P3 = geompy.MakeVertex(mun,un,zero)
57 P4 = geompy.MakeVertex(un,un,zero)
58 P5 = geompy.MakeVertex(zero,zero,un)
60 arc = geompy.MakeArc(P0,P1,P2)
61 e1 = geompy.MakeEdge(P2,P3)
62 e2 = geompy.MakeEdge(P3,P4)
63 e3 = geompy.MakeEdge(P4,P0)
71 wire = geompy.MakeWire(list)
72 face = geompy.MakeFace(wire,1)
74 dir = geompy.MakeVector(Orig,P5)
75 vol1 = geompy.MakePipe(face,dir)
78 #dir = geom.MakeVector(Orig,P5)
79 vol2 = geompy.MakeRotation(vol1,dir,angle)
81 vol3 = geompy.MakeRotation(vol2,dir,angle)
83 vol4 = geompy.MakeRotation(vol3,dir,angle)
91 volComp = geompy.MakeCompound(list)
94 vol = geompy.MakeGlueFaces(volComp,tol3d)
95 idVol = geompy.addToStudy(vol,"volume")
97 print "Analysis of the final volume:"
98 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
99 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
100 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
102 print "number of Shells in the volume : ",len(subShellList)
103 print "number of Faces in the volume : ",len(subFaceList)
104 print "number of Edges in the volume : ",len(subEdgeList)
107 for k in range(len(subEdgeList)):
108 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
111 edgeZ.append(subEdgeList[0])
112 edgeZ.append(subEdgeList[3])
113 edgeZ.append(subEdgeList[10])
114 edgeZ.append(subEdgeList[11])
115 edgeZ.append(subEdgeList[20])
116 edgeZ.append(subEdgeList[21])
117 edgeZ.append(subEdgeList[28])
118 edgeZ.append(subEdgeList[31])
122 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
124 ### ---------------------------- SMESH --------------------------------------
126 # ---- init a Mesh with the volume
128 mesh = smesh.Mesh(vol, "meshVolume")
130 # ---- set Hypothesis and Algorithm to main shape
132 print "-------------------------- NumberOfSegments the global one"
134 numberOfSegments = 10
136 regular1D = mesh.Segment()
137 regular1D.SetName("Wire Discretisation")
138 hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
139 print hypNbSeg.GetName()
140 print hypNbSeg.GetId()
141 print hypNbSeg.GetNumberOfSegments()
142 smesh.SetName(hypNbSeg, "NumberOfSegments")
145 print "-------------------------- Quadrangle_2D"
147 quad2D=mesh.Quadrangle()
148 quad2D.SetName("Quadrangle_2D")
150 print "-------------------------- Hexa_3D"
152 hexa3D=mesh.Hexahedron()
153 hexa3D.SetName("Hexa_3D")
156 print "-------------------------- NumberOfSegments in the Z direction"
158 numberOfSegmentsZ = 40
161 print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
163 algo = mesh.Segment(edgeZ[i])
164 hyp = algo.NumberOfSegments(numberOfSegmentsZ)
165 smesh.SetName(hyp, "NumberOfSegmentsZ")
166 smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
169 salome.sg.updateObjBrowser(1)
171 print "-------------------------- compute the mesh of the volume"
177 ## log=mesh.GetLog(0) # no erase trace
178 ## for linelog in log:
180 print "Information about the MeshBox :"
181 print "Number of nodes : ", mesh.NbNodes()
182 print "Number of edges : ", mesh.NbEdges()
183 print "Number of faces : ", mesh.NbFaces()
184 print "Number of triangles : ", mesh.NbTriangles()
185 print "Number of volumes : ", mesh.NbVolumes()
186 print "Number of tetrahedrons: ", mesh.NbTetras()
188 print "problem when Computing the mesh"
190 salome.sg.updateObjBrowser(1)