From 5b9634a5855e7bf39ebff60c0c0f48308efef3ef Mon Sep 17 00:00:00 2001 From: JimmyBoivie Date: Sat, 5 Dec 2015 02:29:28 -0500 Subject: [PATCH] Add effects --- main/HalfEdge.pde | 49 +++++++++++++++++++++++++++++++++++++---------- main/Point.pde | 5 +++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/main/HalfEdge.pde b/main/HalfEdge.pde index 821c4b4..bbbd1d0 100644 --- a/main/HalfEdge.pde +++ b/main/HalfEdge.pde @@ -20,10 +20,34 @@ public class HalfEdge { // SETS THE COUNTED setCounted(false); twin.setCounted(false); - - // MAGIC METHOD + int state = -1; + if ((p.count() == 0) && (q.count() == 0)) { + // this new structure was created not connected to anything + // watchout inside a face!!!!! + state = 0; + } + else if ((p.count() == 0) || (q.count() == 0)) { + // this means that this edge was addeded such that only one point is already a connected graph + // easy fix + state = 1; + } + else { + // this means both things are connected graph if here that means + // risk of new face or connected two unconnected components; + state = -1; + } + int expected = p.count() + q.count() + 2; connect(); twin.connect(); + if (state == -1) { + if (p.count() == expected) { + // two disconnected graphs are now one! + state = 2; + } else { + state = 3; + // a face is divided in 2. + } + } @@ -37,25 +61,26 @@ public class HalfEdge { public int connect() { ArrayList others = origin.getEntering(); + int result = -1; if (others == null) { this.setprevious(gettwin()); gettwin().setnext(this); // update vertex makeVertexReference(); - return 0; + result = 0; } - if (others.size() == 1) { + else if (others.size() == 1) { HalfEdge other = others.get(0); this.setprevious(other); other.setnext(this); gettwin().setnext(other.gettwin()); other.gettwin().setprevious(gettwin()); - - - // no update vertex - return 1; + result = 1; } - return complex(this, others); + else if (others.size() > 1) { + result = complex(this, others); + } + return result; } @@ -88,7 +113,11 @@ public class HalfEdge { - + public int countReset() { + int c = count(); + reset(); + return c; + } public int count() { if (counted == false) { diff --git a/main/Point.pde b/main/Point.pde index 4f564a2..60ca3df 100644 --- a/main/Point.pde +++ b/main/Point.pde @@ -47,4 +47,9 @@ public class Point { return "(x,y) = " + x + "," + y; } + public int count() { + if (ref == null) { return 0; } + return ref.countReset(); + } + } \ No newline at end of file