D2.3 Boundary Features

Find boundaries to install hooks

First, we need to find all the boundaries where the hook should be installed. The boundary information is saved as edge_attributes. However, if we use the attributes to search these boundaries, the topological information in the mesh is lost. Thus, we need to combine the mesh topology and boundary attributes to find the corresponding edge loops.

corner = list(mesh.vertices_where({'vertex_degree': 2}))[0]
nbrs = mesh.vertex_neighbors(corner)

loop1 = mesh.edge_loop((corner, nbrs[0]))
loop2 = mesh.edge_loop((corner, nbrs[1]))

if len(loop1) > len(loop2):
    start = loop1[0]
else:
    start = loop2[0]

strip = mesh.edge_strip(start)

boundary1 = mesh.edge_loop(strip[0])
boundary2 = mesh.edge_loop(strip[-1])
seam = mesh.edge_loop(strip[len(strip) // 2])

Add hooks

Since we have a uniform quad mesh, we can add the hooks using the topology. We can enumerate through the edge_loop and add hooks based on an estimation of the length. An ideal distance between two hooks is about 25 cm.

mesh.update_default_edge_attributes({'hook': False})

for i, edge in enumerate(boundary1):
    if i % 4 == 1 or i == 0 or i == len(boundary1) - 1:
        mesh.edge_attribute(edge, 'hook', True)

for i, edge in enumerate(boundary2):
    if i % 4 == 1 or i == 0 or i == len(boundary2) - 1:
        mesh.edge_attribute(edge, 'hook', True)

for i, edge in enumerate(seam):
    if i % 4 == 1 or i == 0 or i == len(boundary2) - 1:
        mesh.edge_attribute(edge, 'hook', True)

Save the location of the hooks as an edge attribute. You can rewrite the json file.

mesh.to_json(FILE_I)

Do the same for the other patch.

Last updated