summaryrefslogtreecommitdiff
path: root/src/cracking_ini.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cracking_ini.c')
-rw-r--r--src/cracking_ini.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cracking_ini.c b/src/cracking_ini.c
index 9ab4a9d..988af5b 100644
--- a/src/cracking_ini.c
+++ b/src/cracking_ini.c
@@ -31,6 +31,30 @@ double *gen_fuse_thres(unsigned int num_edges, double *edge_coords, double beta,
return fuse_thres;
}
+void gen_voro_crack(finst *instance, double crack_len, cholmod_common *c) {
+ for (uint_t i = 0; i < instance->network->num_edges; i++) {
+ uint_t v1, v2;
+ double v1x, v1y, v2x, v2y, dx, dy;
+
+ v1 = instance->network->edges_to_verts[2 * i];
+ v2 = instance->network->edges_to_verts[2 * i + 1];
+
+ v1x = instance->network->vert_coords[2 * v1];
+ v1y = instance->network->vert_coords[2 * v1 + 1];
+ v2x = instance->network->vert_coords[2 * v2];
+ v2y = instance->network->vert_coords[2 * v2 + 1];
+
+ dx = v1x - v2x;
+ dy = v1y - v2y;
+
+ if (((v1y > 0.5 && v2y < 0.5) || (v1y < 0.5 && v2y > 0.5)) && fabs(dy) < 0.5) {
+ if (v1x + dx / dy * (v1y - 0.5) <= crack_len) {
+ break_edge(instance, i, c);
+ }
+ }
+ }
+}
+
bool gen_crack(finst *instance, double crack_len, double crack_width,
cholmod_common *c) {
assert(instance != NULL);