11import compas
22import compas_libigl as igl
3+ import numpy as np
34from compas .datastructures import Mesh
4- from tessagon .adaptors .list_adaptor import ListAdaptor
5- from tessagon .types .hex_tessagon import HexTessagon
65
76
87def test_map_mesh ():
@@ -11,21 +10,34 @@ def test_map_mesh():
1110 mesh .quads_to_triangles () # Ensure we have a triangle mesh
1211 v , f = mesh .to_vertices_and_faces ()
1312
14- # Create simple pattern mesh
15- options = {
16- "function" : lambda u , v : [u , v , 0 ],
17- "u_range" : [0 , 1.0 ],
18- "v_range" : [0 , 1.0 ],
19- "u_num" : 4 , # Small number for fast test
20- "v_num" : 3 , # Small number for fast test
21- "u_cyclic" : False ,
22- "v_cyclic" : False ,
23- "adaptor_class" : ListAdaptor ,
24- }
25- tessagon = HexTessagon (** options )
26- tessagon_mesh = tessagon .create_mesh ()
27- pv = tessagon_mesh ["vert_list" ]
28- pf = tessagon_mesh ["face_list" ]
13+ # Create simple pattern mesh manually (grid pattern)
14+ # Use a smaller UV range to ensure pattern falls within target's parameterization
15+ u_num , v_num = 5 , 5
16+ # Use a smaller central region of the UV space
17+ u_range = [0.2 , 0.8 ] # Avoid edges of UV space
18+ v_range = [0.2 , 0.8 ] # Avoid edges of UV space
19+
20+ # Generate grid vertices
21+ pv = []
22+ for j in range (v_num + 1 ):
23+ v_param = v_range [0 ] + j * (v_range [1 ] - v_range [0 ]) / v_num
24+ for i in range (u_num + 1 ):
25+ u_param = u_range [0 ] + i * (u_range [1 ] - u_range [0 ]) / u_num
26+ pv .append ([u_param , v_param , 0 ])
27+
28+ # Create faces (triangulated quads)
29+ pf = []
30+ for j in range (v_num ):
31+ for i in range (u_num ):
32+ # Calculate vertex indices for this quad
33+ v0 = j * (u_num + 1 ) + i
34+ v1 = j * (u_num + 1 ) + i + 1
35+ v2 = (j + 1 ) * (u_num + 1 ) + i + 1
36+ v3 = (j + 1 ) * (u_num + 1 ) + i
37+
38+ # Split quad into two triangles
39+ pf .append ([v0 , v1 , v2 ])
40+ pf .append ([v0 , v2 , v3 ])
2941
3042 # Map pattern onto target mesh
3143 mv , mf = igl .map_mesh ((v , f ), (pv , pf ))
0 commit comments