Salome HOME
Merge from V6_main 28/02/2013
[modules/smesh.git] / doc / salome / examples / viewing_meshes_ex01.py
1 # Viewing Mesh Infos
2
3 import geompy
4 import smesh
5 import SMESH
6
7 # create a box
8 box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
9 geompy.addToStudy(box, "box")
10 [Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
11
12 # create a mesh
13 tetra = smesh.Mesh(box, "MeshBox")
14
15 algo1D = tetra.Segment()
16 algo1D.NumberOfSegments(3)
17
18 algo2D = tetra.Triangle()
19 algo2D.MaxElementArea(10.)
20
21 algo3D = tetra.Tetrahedron()
22 algo3D.MaxElementVolume(900.)
23
24 # Creation of SubMesh
25 Regular_1D_1_1 = tetra.Segment(geom=Face_1)
26 Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5)
27 Nb_Segments_1.SetDistrType( 0 )
28 Quadrangle_2D = tetra.Quadrangle(geom=Face_1)
29 isDone = tetra.Compute()
30 submesh = Regular_1D_1_1.GetSubMesh()
31
32 # compute the mesh
33 tetra.Compute()
34
35 # Creation of group
36 group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' )
37 nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] )
38
39 # Print information about the mesh
40 print "Information about mesh:" 
41 print "Number of nodes       : ", tetra.NbNodes()
42 print "Number of edges       : ", tetra.NbEdges()
43 print "Number of faces       : ", tetra.NbFaces()
44 print "          triangles   : ", tetra.NbTriangles()
45 print "          quadrangles : ", tetra.NbQuadrangles()
46 print "          polygons    : ", tetra.NbPolygons()
47 print "Number of volumes     : ", tetra.NbVolumes()
48 print "          tetrahedrons: ", tetra.NbTetras()
49 print "          hexahedrons : ", tetra.NbHexas()
50 print "          prisms      : ", tetra.NbPrisms()
51 print "          pyramids    : ", tetra.NbPyramids()
52 print "          polyhedrons : ", tetra.NbPolyhedrons() 
53
54 # Get Information About Mesh by GetMeshInfo
55 print "\nInformation about mesh by GetMeshInfo:"
56 info = smesh.GetMeshInfo(tetra)
57 keys = info.keys(); keys.sort()
58 for i in keys:
59   print "  %s   :  %d" % ( i, info[i] )
60   pass
61
62 # Get Information About Group by GetMeshInfo
63 print "\nInformation about group by GetMeshInfo:"
64 info = smesh.GetMeshInfo(group)
65 keys = info.keys(); keys.sort()
66 for i in keys:
67   print "  %s  :  %d" % ( i, info[i] )
68   pass
69
70 # Get Information About SubMesh by GetMeshInfo
71 print "\nInformation about Submesh by GetMeshInfo:"
72 info = smesh.GetMeshInfo(submesh)
73 keys = info.keys(); keys.sort()
74 for i in keys:
75   print "  %s  :  %d" % ( i, info[i] )
76   pass