MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / chain_wires

Function chain_wires

scripts/minkowski_sum.py:29–56  ·  view source on GitHub ↗
(wires)

Source from the content-addressed store, hash-verified

27 return np.array(path, dtype=float);
28
29def chain_wires(wires):
30 assert(wires.num_vertices > 0);
31 visited = np.zeros(wires.num_vertices, dtype=bool);
32 path = [0];
33 visited[0] = True;
34 while not np.all(visited):
35 front = path[0];
36 front_neighbors = wires.get_vertex_neighbors(int(front));
37 for v in front_neighbors:
38 if visited[v]: continue;
39 path.insert(0, v);
40 visited[v] = True;
41 break;
42 end = path[-1];
43 end_neighbors = wires.get_vertex_neighbors(int(end));
44 for v in end_neighbors:
45 if visited[v]: continue;
46 visited[v] = True;
47 path.append(v);
48 break;
49
50 first_neighbors = wires.get_vertex_neighbors(int(path[0])).squeeze();
51 if len(path) > 2 and path[-1] in first_neighbors:
52 # Close the loop.
53 path.append(path[0]);
54
55 path = wires.vertices[path];
56 return path;
57
58def main():
59 args = parse_args();

Callers 1

mainFunction · 0.85

Calls 2

get_vertex_neighborsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected