4 salome.salome_init_without_session()
7 from salome.geom import geomBuilder
8 from salome.smesh import smeshBuilder
10 geom_builder = geomBuilder.New()
11 smesh_builder = smeshBuilder.New()
13 # create a geometry consisting of two faces
14 box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 )
15 faces = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["FACE"])
17 shape = geom_builder.MakeCompound( faces[:2] )
18 faces = geom_builder.SubShapeAll( shape, geom_builder.ShapeType["FACE"] )
19 geom_builder.addToStudy( shape, "shape")
20 geom_builder.addToStudyInFather( shape, faces[0], "faces[0]")
21 geom_builder.addToStudyInFather( shape, faces[1], "faces[1]")
24 mesh = smesh_builder.Mesh( shape, "test_Reorient2D")
25 mesh.AutomaticHexahedralization(0.5)
26 localAlgo = mesh.Segment(faces[0])
27 localAlgo.NumberOfSegments( 11 )
29 group = mesh.Group( faces[1] )
31 vec = geom_builder.MakeVectorDXDYDZ( 1, 1, 1 )
37 # Each of arguments of Reorient2D() function can be of different types:
39 # 2DObject - the whole mesh
40 # Direction - a GEOM object (vector)
41 # FaceOrPoint - an ID of face
42 mesh.Reorient2D( mesh, vec, mesh.NbElements() )
44 # 2DObject - a sub-mesh
45 # Direction - components of a vector
46 # FaceOrPoint - a GEOM object (vertex)
47 mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geom_builder.GetFirstVertex( vec ))
49 # 2DObject - a group of faces
50 # Direction - a SMESH.DirStruct structure
51 # FaceOrPoint - coordinates of a point
52 mesh.Reorient2D( group, smesh_builder.MakeDirStruct( -10, 1, 10 ), [0,0,0])
54 # FaceOrPoint - a SMESH.PointStruct structure
55 mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))
57 # ========================
58 # Reorient2DByNeighbours()
59 # ========================
61 # Use faces of 'group' as a reference to reorient equally all faces
62 mesh.Reorient2DByNeighbours([mesh], [group])
64 # Orient equally face on 'group', but not define which orientation is correct
65 mesh.Reorient2DByNeighbours([group])
71 # Use Reorient2DBy3D() to orient faces of 2 geom faces to have their normal pointing inside volumes
73 mesh3D = smesh_builder.Mesh( box, '3D mesh')
74 mesh3D.AutomaticHexahedralization(0.5)
75 group0 = mesh3D.Group( faces[0] )
76 group1 = mesh3D.Group( faces[1] )
78 # pass group0 and ids of faces of group1 to inverse
79 nbRev = mesh3D.Reorient2DBy3D([ group0, group1.GetIDs() ], mesh3D, theOutsideNormal=False)
80 print("Nb reoriented faces:", nbRev)
82 # orient the reversed faces back
83 nbRev = mesh3D.Reorient2DBy3D( mesh3D, mesh3D, theOutsideNormal=True)
84 print("Nb re-reoriented faces:", nbRev)