diff options
author | pants <jaron@kent-dobias.com> | 2016-09-07 14:55:30 -0400 |
---|---|---|
committer | pants <jaron@kent-dobias.com> | 2016-09-07 14:55:30 -0400 |
commit | 873a9f9bedbbfb07d475e271923a7b86464e515f (patch) | |
tree | 8c8b8e2ebcd45a9bf9174a7e22153e8c3261f419 /src/net_notch.c | |
parent | 805794c6e8b7c16e6219f75076fcbc76221d551d (diff) | |
download | fuse_networks-873a9f9bedbbfb07d475e271923a7b86464e515f.tar.gz fuse_networks-873a9f9bedbbfb07d475e271923a7b86464e515f.tar.bz2 fuse_networks-873a9f9bedbbfb07d475e271923a7b86464e515f.zip |
more major refactoring
Diffstat (limited to 'src/net_notch.c')
-rw-r--r-- | src/net_notch.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/net_notch.c b/src/net_notch.c new file mode 100644 index 0000000..608d0b5 --- /dev/null +++ b/src/net_notch.c @@ -0,0 +1,29 @@ + +#include "fracture.h" + +void net_notch(net_t *net, double notch_len, cholmod_common *c) { + for (uint_t i = 0; i < net->graph->ne; i++) { + uint_t v1, v2; + double v1x, v1y, v2x, v2y, dx, dy; + bool crosses_center, not_wrapping, correct_length; + + v1 = net->graph->ev[2 * i]; + v2 = net->graph->ev[2 * i + 1]; + + v1x = net->graph->vx[2 * v1]; + v1y = net->graph->vx[2 * v1 + 1]; + v2x = net->graph->vx[2 * v2]; + v2y = net->graph->vx[2 * v2 + 1]; + + dx = v1x - v2x; + dy = v1y - v2y; + + crosses_center = (v1y >= 0.5 && v2y <= 0.5) || (v1y <= 0.5 && v2y >= 0.5); + not_wrapping = fabs(dy) < 0.5; + correct_length = v1x + dx / dy * (v1y - 0.5) <= notch_len; + + if (crosses_center && not_wrapping && correct_length) { + break_edge(net, i, c); + } + } +} |