Skip to content

Commit

Permalink
Use a FILL_VALUE=-1 everywhere.
Browse files Browse the repository at this point in the history
The external fill value is only used when converting back to dataset.
  • Loading branch information
Huite committed Sep 5, 2024
1 parent b2f9dd6 commit 333419b
Show file tree
Hide file tree
Showing 17 changed files with 228 additions and 277 deletions.
19 changes: 6 additions & 13 deletions examples-dev/voronoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def generate_disk(partitions: int, depth: int):
return np.column_stack((x, y)), triang.triangles


def edge_plot(vertices, edge_nodes, ax, fill_value=-1, **kwargs):
def edge_plot(vertices, edge_nodes, ax, **kwargs):
n_edge = len(edge_nodes)
edge_coords = np.empty((n_edge, 2, 2), dtype=float)
node_0 = edge_nodes[:, 0]
node_1 = edge_nodes[:, 1]
valid = (node_0 != fill_value) & (node_1 != fill_value)
valid = (node_0 != -1) & (node_1 != -1)
node_0 = node_0[valid]
node_1 = node_1[valid]
edge_coords[:, 0, 0] = vertices[node_0, 0]
Expand All @@ -81,10 +81,10 @@ def edge_plot(vertices, edge_nodes, ax, fill_value=-1, **kwargs):
return primitive


def face_plot(vertices, face_nodes, ax, fill_value=-1, **kwargs):
def face_plot(vertices, face_nodes, ax, **kwargs):
vertices = vertices[face_nodes]
# Replace fill value; PolyCollection ignores NaN.
vertices[face_nodes == fill_value] = np.nan
vertices[face_nodes == -1] = np.nan
collection = PolyCollection(vertices, **kwargs)
primitive = ax.add_collection(collection)
ax.autoscale()
Expand Down Expand Up @@ -168,7 +168,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=True,
)
Expand Down Expand Up @@ -201,7 +200,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=True,
)
Expand All @@ -228,7 +226,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=False,
)
Expand All @@ -251,7 +248,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=True,
skip_concave=True,
Expand All @@ -275,7 +271,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=False,
)
Expand All @@ -287,7 +282,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=True,
)
Expand All @@ -299,7 +293,6 @@ def comparison_plot(
centroids,
edge_face_connectivity=edge_face_connectivity,
edge_node_connectivity=edge_node_connectivity,
fill_value=-1,
add_exterior=True,
add_vertices=True,
skip_concave=True,
Expand Down Expand Up @@ -342,10 +335,10 @@ def comparison_plot(
# fourth option, since it includes some vertices of the original mesh, which
# are connected to multiple faces.

triangles0, face_triangles0 = connectivity.triangulate(faces0, -1)
triangles0, face_triangles0 = connectivity.triangulate(faces0)
triangulation0 = mtri.Triangulation(nodes0[:, 0], nodes0[:, 1], triangles0)

triangles1, face_triangles1 = connectivity.triangulate(faces1, -1)
triangles1, face_triangles1 = connectivity.triangulate(faces1)
triangulation1 = mtri.Triangulation(nodes1[:, 0], nodes1[:, 1], triangles1)


Expand Down
Loading

0 comments on commit 333419b

Please sign in to comment.