Skip to content

Commit

Permalink
making return_tri optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Sep 15, 2023
1 parent d888ec8 commit 69ecad5
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions openpnm/_skgraph/generators/_voronoi_delaunay_dual.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
from openpnm._skgraph.queries import find_neighbor_nodes


def voronoi_delaunay_dual(points, shape, trim=True, reflect=True, f=1, relaxation=0,
node_prefix='node', edge_prefix='edge'):
def voronoi_delaunay_dual(
points,
shape,
trim=True,
reflect=True,
f=1,
relaxation=0,
node_prefix='node',
edge_prefix='edge',
return_tri=False,
):
r"""
Generate a dual Voronoi-Delaunay network from given base points
Expand Down Expand Up @@ -67,8 +76,6 @@ def voronoi_delaunay_dual(points, shape, trim=True, reflect=True, f=1, relaxatio
for _ in range(relaxation):
points = tools.lloyd_relaxation(vor, mode='fast')
vor = sptl.Voronoi(points=points[:, mask])
# tri = sptl.Delaunay(points=points[:, mask])
tri = None

# Collect delaunay edges
conns_del = vor.ridge_points
Expand Down Expand Up @@ -147,7 +154,11 @@ def voronoi_delaunay_dual(points, shape, trim=True, reflect=True, f=1, relaxatio
inds = np.where(trim)[0]
network = trim_nodes(network=network, inds=inds)

return network, vor, tri
if return_tri:
tri = sptl.Delaunay(points=points[:, mask])
return network, vor, tri
else:
return network, vor


if __name__ == "__main__":
Expand Down

0 comments on commit 69ecad5

Please sign in to comment.