1 # Projection Algorithms
3 # Project prisms from one meshed box to another mesh on the same box
9 # Create a parallelepiped
10 box = geompy.MakeBoxDXDYDZ(200, 100, 70)
11 geompy.addToStudy( box, "box" )
13 # Get geom faces to mesh with triangles in the 1ts and 2nd meshes
14 faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
15 # 2 adjacent faces of the box
21 # Get vertices used to specify how to associate sides of faces at projection
22 [v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2]
23 [v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2]
24 geompy.addToStudyInFather( box, v1F1, "v1F1" )
25 geompy.addToStudyInFather( box, v2F1, "v2F1" )
26 geompy.addToStudyInFather( box, v1F2, "v1F2" )
27 geompy.addToStudyInFather( box, v2F2, "v2F2" )
29 # Make group of 3 edges of f1 and f2
30 edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"])
31 geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3])
32 edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"])
33 geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3])
34 geompy.addToStudyInFather( box, edgesF1, "edgesF1" )
35 geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
38 # Make the source mesh with prisms
39 src_mesh = Mesh(box, "Source mesh")
40 src_mesh.Segment().NumberOfSegments(9,10)
43 src_mesh.Triangle(f1) # triangular sumbesh
47 # Mesh the box using projection algoritms
49 # Define the same global 1D and 2D hypotheses
50 tgt_mesh = Mesh(box, "Target mesh")
51 tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
54 # Define Projection 1D algorithm to project 1d mesh elements from group edgesF2 to edgesF1
55 # It is actually not needed, just a demonstration
56 proj1D = tgt_mesh.Projection1D( edgesF1 )
57 # each vertex must be at the end of a connected group of edges (or a sole edge)
58 proj1D.SourceEdge( edgesF2, src_mesh, v2F1, v2F2 )
60 # Define 2D hypotheses to project triangles from f1 face of the source mesh to
61 # f2 face in the target mesh. Vertices specify how to associate sides of faces
62 proj2D = tgt_mesh.Projection2D( f2 )
63 proj2D.SourceFace( f1, src_mesh, v1F1, v1F2, v2F1, v2F2 )
65 # 2D hypotheses to project triangles from f2 of target mesh to the face opposite to f2.
66 # Association of face sides is default
67 proj2D = tgt_mesh.Projection2D( f2opp )
68 proj2D.SourceFace( f2 )
70 # 3D hypotheses to project prisms from the source to the target mesh
71 proj3D = tgt_mesh.Projection3D()
72 proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
75 # Move the source mesh to visualy compare the two meshes
76 src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False)