Salome HOME
0126b7108390fa00a24e02b080c1671f7b04718c
[modules/smesh.git] / doc / salome / examples / transforming_meshes_ex13.py
1 # Reorient faces by vector
2
3 import smesh, geompy, SMESH
4
5 # create a geometry consisting of two faces
6 box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
7 faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])
8
9 shape = geompy.MakeCompound( faces[:2] )
10 faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] )
11 geompy.addToStudy( shape, "shape")
12 geompy.addToStudyInFather( shape, faces[0], "faces[0]")
13 geompy.addToStudyInFather( shape, faces[1], "faces[1]")
14
15 # create a 2D mesh
16 mesh = smesh.Mesh( shape, "test_Reorient2D")
17 mesh.AutomaticHexahedralization(0.5)
18 localAlgo = mesh.Segment(faces[0])
19 localAlgo.NumberOfSegments( 11 )
20 mesh.Compute()
21 group = mesh.Group( faces[1] )
22
23 vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 )
24
25 # Each of arguments of Reorient2D() function can be of different types:
26 #
27 # 2DObject    - the whole mesh
28 # Direction   - a GEOM object (vector)
29 # FaceOrPoint - an ID of face
30 mesh.Reorient2D( mesh, vec, mesh.NbElements() )
31 #
32 # 2DObject    - a sub-mesh
33 # Direction   - components of a vector
34 # FaceOrPoint - a GEOM object (vertex)
35 mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec ))
36 #
37 # 2DObject    - a group of faces
38 # Direction   - a SMESH.DirStruct structure
39 # FaceOrPoint - coordinates of a point
40 mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0])
41 #
42 # FaceOrPoint - a SMESH.PointStruct structure
43 mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))