]> SALOME platform Git repositories - modules/smesh.git/blob - doc/salome/examples/measurements_ex03.py
Salome HOME
[bos #23982] EDF 22984 - aspect ratio of hexa
[modules/smesh.git] / doc / salome / examples / measurements_ex03.py
1 # Basic Properties
2
3
4 import salome
5 salome.salome_init()
6 import GEOM
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New()
9
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh =  smeshBuilder.New()
13
14 # create a box
15 box = geompy.MakeBoxDXDYDZ(100,100,100)
16 face = geompy.SubShapeAllSorted(box, geompy.ShapeType['FACE'])[0]
17
18 # mesh a box
19 mesh = smesh.Mesh(box)
20 submesh_1d = mesh.Segment().NumberOfSegments(5)
21 submesh_2d = mesh.Quadrangle()
22 submesh_3d = mesh.Hexahedron()
23 submesh_2d_face = mesh.Triangle(face)
24 mesh.Compute()
25
26 # create a group
27
28 group_2d = mesh.Group(face)
29
30 # compute basic properties
31
32 print("Get basic properties: approach 1 (via measurements tool) ----")
33
34 measure = smesh.CreateMeasurements()
35
36 print("* for mesh:")
37 print("  length:", measure.Length(mesh.mesh))
38 print("  area:",   measure.Area(mesh.mesh))
39 print("  volume:", measure.Volume(mesh.mesh))
40
41 print("* for group (2d):")
42 print("  length:", measure.Length(group_2d))
43 print("  area:",   measure.Area(group_2d))
44 print("  volume:", measure.Volume(group_2d))
45
46 print("* for submesh (2d):")
47 print("  length:", measure.Length(submesh_2d_face.GetSubMesh()))
48 print("  area:",   measure.Area(submesh_2d_face.GetSubMesh()))
49 print("  volume:", measure.Volume(submesh_2d_face.GetSubMesh()))
50
51 measure.UnRegister()
52
53 print("Get basic properties: approach 2 (via smeshBuilder) ----")
54
55 print("* for mesh:")
56 print("  length:", smesh.GetLength(mesh))
57 print("  area:",   smesh.GetArea(mesh))
58 print("  volume:", smesh.GetVolume(mesh))
59
60 print("* for group (2d):")
61 print("  length:", smesh.GetLength(group_2d))
62 print("  area:",   smesh.GetArea(group_2d))
63 print("  volume:", smesh.GetVolume(group_2d))
64
65 print("* for submesh (2d):")
66 print("  length:", smesh.GetLength(submesh_2d_face))
67 print("  area:",   smesh.GetArea(submesh_2d_face))
68 print("  volume:", smesh.GetVolume(submesh_2d_face))
69
70 print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----")
71
72 print("* for mesh:")
73 print("  length:", mesh.GetLength())
74 print("  area:",   mesh.GetArea())
75 print("  volume:", mesh.GetVolume())
76
77 print("* for group (2d): unsupported")
78
79 print("* for submesh (2d): unsupported")