summaryrefslogtreecommitdiff
path: root/src/ini_network.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ini_network.c')
-rw-r--r--src/ini_network.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ini_network.c b/src/ini_network.c
index 0434d98..f1dbe70 100644
--- a/src/ini_network.c
+++ b/src/ini_network.c
@@ -300,7 +300,7 @@ unsigned int *get_voro_dual_edges(unsigned int num_edges,
return dual_edges;
}
-fnet *ini_voronoi_network(unsigned int L, boundary_type boundary,
+fnet *ini_voronoi_network(unsigned int L, boundary_type boundary, bool use_dual,
double *(*genfunc)(unsigned int, gsl_rng *, unsigned int *),
cholmod_common *c) {
fnet *network = (fnet *)calloc(1, sizeof(fnet));
@@ -337,6 +337,24 @@ fnet *ini_voronoi_network(unsigned int L, boundary_type boundary,
unsigned int *tmp_dual_edges =
get_voro_dual_edges(tmp_num_edges, tmp_num_verts, tmp_edges, tmp_tris);
+ // when use_dual is specificed, the edge and vertex sets are swapped with the
+ // dual edge and dual vertex sets. once formally relabelled, everything
+ // works the same way
+ if (use_dual) {
+ unsigned int *tmp_tmp_dual_edges = tmp_edges;
+ double *tmp_lattice = tmp_vert_coords;
+ unsigned int tmp_num = tmp_num_verts;
+
+ tmp_edges = tmp_dual_edges;
+ tmp_dual_edges = tmp_tmp_dual_edges;
+
+ tmp_vert_coords = lattice;
+ lattice = tmp_lattice;
+
+ tmp_num_verts = num;
+ num = tmp_num;
+ }
+
// prune the edges of the lattice and assign boundary vertices based on the
// desired boundary conditions
unsigned int num_bounds;