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