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
38 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
39 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
41 smeshgui = salome.ImportComponentGUI("SMESH")
42 smeshgui.Init(salome.myStudyId);
46 # -----------------------------------------------------------------------------
59 Orig = geompy.MakeVertex(zero,zero,zero)
60 P0 = geompy.MakeVertex(a,a,zero)
61 P1 = geompy.MakeVertex(zero,demi,zero)
62 P2 = geompy.MakeVertex(ma,a,zero)
63 P3 = geompy.MakeVertex(mun,un,zero)
64 P4 = geompy.MakeVertex(un,un,zero)
65 P5 = geompy.MakeVertex(zero,zero,un)
67 arc = geompy.MakeArc(P0,P1,P2)
68 e1 = geompy.MakeEdge(P2,P3)
69 e2 = geompy.MakeEdge(P3,P4)
70 e3 = geompy.MakeEdge(P4,P0)
78 wire = geompy.MakeWire(list)
79 face = geompy.MakeFace(wire,1)
81 dir = geompy.MakeVector(Orig,P5)
82 vol1 = geompy.MakePipe(face,dir)
85 #dir = geom.MakeVector(Orig,P5)
86 vol2 = geompy.MakeRotation(vol1,dir,angle)
88 vol3 = geompy.MakeRotation(vol2,dir,angle)
90 vol4 = geompy.MakeRotation(vol3,dir,angle)
98 volComp = geompy.MakeCompound(list)
101 vol = geompy.MakeGlueFaces(volComp,tol3d)
102 idVol = geompy.addToStudy(vol,"volume")
104 print "Analysis of the final volume:"
105 subShellList = geompy.SubShapeAllSorted(vol,ShapeTypeShell)
106 subFaceList = geompy.SubShapeAllSorted(vol,ShapeTypeFace)
107 subEdgeList = geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
109 print "number of Shells in the volume : ",len(subShellList)
110 print "number of Faces in the volume : ",len(subFaceList)
111 print "number of Edges in the volume : ",len(subEdgeList)
114 for k in range(len(subEdgeList)):
115 idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
118 edgeZ.append(subEdgeList[0])
119 edgeZ.append(subEdgeList[3])
120 edgeZ.append(subEdgeList[10])
121 edgeZ.append(subEdgeList[11])
122 edgeZ.append(subEdgeList[20])
123 edgeZ.append(subEdgeList[21])
124 edgeZ.append(subEdgeList[28])
125 edgeZ.append(subEdgeList[31])
129 idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
131 ### ---------------------------- SMESH --------------------------------------
133 # ---- create Hypothesis
135 print "-------------------------- create Hypothesis"
137 print "-------------------------- NumberOfSegments the global one"
139 numberOfSegments = 10
141 hypNbSeg=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
142 hypNbSeg.SetNumberOfSegments(numberOfSegments)
143 hypNbSegID = hypNbSeg.GetId()
144 print hypNbSeg.GetName()
146 print hypNbSeg.GetNumberOfSegments()
148 smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments")
150 print "-------------------------- NumberOfSegments in the Z direction"
152 numberOfSegmentsZ = 40
154 hypNbSegZ=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
155 hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
156 hypNbSegZID = hypNbSegZ.GetId()
157 print hypNbSegZ.GetName()
159 print hypNbSegZ.GetNumberOfSegments()
161 smeshgui.SetName(salome.ObjectToID(hypNbSegZ), "NumberOfSegmentsZ")
163 # ---- create Algorithms
165 print "-------------------------- create Algorithms"
167 print "-------------------------- Regular_1D"
169 regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
170 smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
172 print "-------------------------- Quadrangle_2D"
174 quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
175 smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
177 print "-------------------------- Hexa_3D"
179 hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
180 smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
182 # ---- init a Mesh with the volume
184 mesh = smesh.CreateMesh(vol)
185 smeshgui.SetName(salome.ObjectToID(mesh), "meshVolume")
187 # ---- add hypothesis to the volume
189 print "-------------------------- add hypothesis to the volume"
191 ret=mesh.AddHypothesis(vol,regular1D)
193 ret=mesh.AddHypothesis(vol,hypNbSeg)
195 ret=mesh.AddHypothesis(vol,quad2D)
197 ret=mesh.AddHypothesis(vol,hexa3D)
201 print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
203 subMeshEdgeZ = mesh.GetSubMesh(edgeZ[i],"SubMeshEdgeZ_"+str(i+1))
205 retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
206 print " add hyp Z ", retZ
208 salome.sg.updateObjBrowser(1)
210 print "-------------------------- compute the mesh of the volume"
212 ret=smesh.Compute(mesh,vol)
216 ## log=mesh.GetLog(0) # no erase trace
217 ## for linelog in log:
219 print "Information about the MeshBox :"
220 print "Number of nodes : ", mesh.NbNodes()
221 print "Number of edges : ", mesh.NbEdges()
222 print "Number of faces : ", mesh.NbFaces()
223 print "Number of triangles : ", mesh.NbTriangles()
224 print "Number of volumes : ", mesh.NbVolumes()
225 print "Number of tetrahedrons: ", mesh.NbTetras()
227 print "problem when Computing the mesh"
229 salome.sg.updateObjBrowser(1)