improve connection deletion
Browse files- handcrafted_solution.py +7 -5
handcrafted_solution.py
CHANGED
@@ -509,16 +509,18 @@ def delete_one_vert(vertices, vertices_3d, connections, vert_to_del):
|
|
509 |
vertices = np.delete(vertices, idx)
|
510 |
vertices_3d = np.delete(vertices_3d, idx, axis=0)
|
511 |
conn_to_del = []
|
512 |
-
for
|
513 |
if c[0] == idx or c[1] == idx:
|
514 |
-
conn_to_del.append(
|
|
|
|
|
515 |
if c[0] >= idx:
|
516 |
-
connections[
|
517 |
if c[1] >= idx:
|
518 |
-
connections[
|
519 |
|
520 |
#print(f'del {len(conn_to_del)} connections')
|
521 |
-
|
522 |
connections = connections.tolist()
|
523 |
#print(vertices, vertices_3d, connections)
|
524 |
if vertices:
|
|
|
509 |
vertices = np.delete(vertices, idx)
|
510 |
vertices_3d = np.delete(vertices_3d, idx, axis=0)
|
511 |
conn_to_del = []
|
512 |
+
for ic, c in enumerate(connections):
|
513 |
if c[0] == idx or c[1] == idx:
|
514 |
+
conn_to_del.append(ic)
|
515 |
+
connections = np.delete(connections, (conn_to_del), axis=0)
|
516 |
+
for ic, c in enumerate(connections):
|
517 |
if c[0] >= idx:
|
518 |
+
connections[ic] = (connections[ic][0]-1, connections[ic][1])
|
519 |
if c[1] >= idx:
|
520 |
+
connections[ic] = (connections[ic][0], connections[ic][1]-1)
|
521 |
|
522 |
#print(f'del {len(conn_to_del)} connections')
|
523 |
+
|
524 |
connections = connections.tolist()
|
525 |
#print(vertices, vertices_3d, connections)
|
526 |
if vertices:
|