Salome HOME
cd096ca760df759c8a38d2936e9d3e8e34dab4ce
[modules/smesh.git] / doc / salome / examples / viewing_meshes_ex02.py
1 # Find Element by Point
2
3 import geompy
4 import smesh
5 import SMESH
6
7 # Create a geometry to mesh
8 box = geompy.MakeBoxDXDYDZ(100,100,100)
9
10 # Create a mesh
11 mesh = smesh.Mesh(box,"Mesh")
12 mesh.AutomaticHexahedralization()
13 mesh.Compute()
14
15 # Create a point
16 x,y,z = 0, 0, 1
17
18 # Find all elements (except 0D ones) located at the point
19 all_elems_except_0D = mesh.FindElementsByPoint(x,y,z)
20 assert( len(all_elems_except_0D) == 4)
21
22 # Find nodes at the point
23 nodes = mesh.FindElementsByPoint(x,y,z, SMESH.NODE )
24 assert( len(nodes) == 0)
25 assert( len( mesh.FindElementsByPoint(x,y,0, SMESH.NODE)) == 1)
26
27 # Find an edge at the point
28 edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE )
29 assert( len(edges) == 1)
30
31 # Find faces at the point
32 edges = mesh.FindElementsByPoint(x,y,z, SMESH.FACE )
33 assert( len(edges) == 2)
34
35 # Find a volume at the point
36 vols = mesh.FindElementsByPoint(x,y,z, SMESH.VOLUME )
37 assert( len(vols) == 1)
38
39 # Find 0D elements at the point
40 elems0d = mesh.FindElementsByPoint(x,y,z, SMESH.ELEM0D )
41 assert( len(elems0d) == 0)
42
43 # Find edges within a group
44 group1D = mesh.MakeGroupByIds("1D", SMESH.EDGE, [1,2] )
45 edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE, group1D )