Version: 8.3.0
 All Classes Namespaces Files Functions Variables Groups Pages
Measurements

Minimum Distance

1 # Minimum Distance
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
12 import salome_notebook
13 
14 from SMESH_mechanic import mesh as mesh1
15 from SMESH_test1 import mesh as mesh2
16 
17 mesh1.Compute()
18 mesh2.Compute()
19 
20 # compute min distance from mesh1 to the origin (not available yet)
21 smesh.MinDistance(mesh1)
22 
23 # compute min distance from node 10 of mesh1 to the origin
24 smesh.MinDistance(mesh1, id1=10)
25 # ... or
26 mesh1.MinDistance(10)
27 
28 # compute min distance between nodes 10 and 20 of mesh1
29 smesh.MinDistance(mesh1, id1=10, id2=20)
30 # ... or
31 mesh1.MinDistance(10, 20)
32 
33 # compute min distance from element 100 of mesh1 to the origin (not available yet)
34 smesh.MinDistance(mesh1, id1=100, isElem1=True)
35 # ... or
36 mesh1.MinDistance(100, isElem1=True)
37 
38 # compute min distance between elements 100 and 200 of mesh1 (not available yet)
39 smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True)
40 # ... or
41 mesh1.MinDistance(100, 200, True, True)
42 
43 # compute min distance from element 100 to node 20 of mesh1 (not available yet)
44 smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True)
45 # ... or
46 mesh1.MinDistance(100, 20, True)
47 
48 # compute min distance from mesh1 to mesh2 (not available yet)
49 smesh.MinDistance(mesh1, mesh2)
50 
51 # compute min distance from node 10 of mesh1 to node 20 of mesh2
52 smesh.MinDistance(mesh1, mesh2, 10, 20)
53 
54 # compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet)
55 smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True)
56 
57 # etc...
58 

Download this script

Basic Properties

1 # Bounding Box
2 
3 
4 import salome
5 salome.salome_init()
6 import GEOM
7 from salome.geom import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
9 
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
14 
15 from SMESH_mechanic import mesh as mesh1
16 from SMESH_test1 import mesh as mesh2
17 
18 mesh1.Compute()
19 mesh2.Compute()
20 
21 # compute bounding box for mesh1
22 mesh1.BoundingBox()
23 
24 # compute bounding box for list of nodes of mesh1
25 mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381])
26 
27 # compute bounding box for list of elements of mesh1
28 mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True)
29 
30 # compute common bounding box of mesh1 and mesh2
31 smesh.BoundingBox([mesh1, mesh2])
32 
33 # etc...

Download this script

Basic Properties

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(salome.myStudy)
9 
10 import SMESH, SALOMEDS
11 from salome.smesh import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
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"

Download this script