3 \page tui_creating_meshes_page Creating Meshes
5 \n First of all see \ref tui_creating_meshes_page "Example of 3d mesh generation",
6 which is an example of good python script style for Mesh module.
7 \n Other examples of python scripts will be also updated soon to use
8 smesh package instead of direct usage of idl interface.
11 <h2>Construction of a Mesh</h2>
18 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
19 idbox = geompy.addToStudy(box, "box")
22 tetra = smesh.Mesh(box, "MeshBox")
24 algo1D = tetra.Segment()
25 algo1D.NumberOfSegments(7)
27 algo2D = tetra.Triangle()
28 algo2D.MaxElementArea(800.)
30 algo3D = tetra.Tetrahedron(smesh.NETGEN)
31 algo3D.MaxElementVolume(900.)
36 print "problem when computing the mesh"
43 \anchor tui_construction_submesh
44 <h2>Construction of a Submesh</h2>
51 box = MakeBoxDXDYDZ(10., 10., 10.)
52 addToStudy(box, "Box")
54 # select one edge of the box for definition of a local hypothesis
55 p5 = MakeVertex(5., 0., 0.)
56 EdgeX = GetEdgeNearPoint(box, p5)
57 addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
59 # create a hexahedral mesh on the box
60 quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
62 # create a regular 1D algorithm for the faces
63 algo1D = quadra.Segment()
65 # define "NumberOfSegments" hypothesis to cut
66 # all the edges in a fixed number of segments
67 algo1D.NumberOfSegments(4)
69 # create a quadrangle 2D algorithm for the faces
72 # construct a submesh on the edge with a local hypothesis
73 algo_local = quadra.Segment(EdgeX)
75 # define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length
76 algo_local.Arithmetic1D(1, 4)
78 # define "Propagation" hypothesis that propagates all other hypotheses
79 # on all edges of the opposite side in case of quadrangular faces
80 algo_local.Propagation()
88 \anchor tui_editing_mesh
89 <h2>Editing of a mesh</h2>
95 def PrintMeshInfo(theMesh):
96 aMesh = theMesh.GetMesh()
97 print "Information about mesh:"
98 print "Number of nodes : ", aMesh.NbNodes()
99 print "Number of edges : ", aMesh.NbEdges()
100 print "Number of faces : ", aMesh.NbFaces()
101 print "Number of volumes : ", aMesh.NbVolumes()
105 box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
106 geompy.addToStudy(box, "box")
108 # select one edge of the box for definition of a local hypothesis
109 subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
110 edge = subShapeList[0]
111 name = geompy.SubShapeName(edge, box)
112 geompy.addToStudyInFather(box, edge, name)
115 tria = smesh.Mesh(box, "Mesh 2D")
116 algo1D = tria.Segment()
117 hyp1 = algo1D.NumberOfSegments(3)
118 algo2D = tria.Triangle()
119 hyp2 = algo2D.MaxElementArea(10.)
122 algo_local = tria.Segment(edge)
123 hyp3 = algo_local.Arithmetic1D(1, 6)
124 hyp4 = algo_local.Propagation()
130 # remove a local hypothesis
131 mesh = tria.GetMesh()
132 mesh.RemoveHypothesis(edge, hyp4)
138 # change the value of the 2D hypothesis
139 hyp2.SetMaxElementArea(2.)
147 \anchor tui_export_mesh
148 <h2>Export of a Mesh</h2>
155 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
156 idbox = geompy.addToStudy(box, "box")
159 tetra = smesh.Mesh(box, "MeshBox")
161 algo1D = tetra.Segment()
162 algo1D.NumberOfSegments(7)
164 algo2D = tetra.Triangle()
165 algo2D.MaxElementArea(800.)
167 algo3D = tetra.Tetrahedron(smesh.NETGEN)
168 algo3D.MaxElementVolume(900.)
173 # export the mesh in a MED file
174 tetra.ExportMED("/tmp/meshMED.med", 0)