From a2ef9918ca3c3c0d92eea1ac55771263dadee3f6 Mon Sep 17 00:00:00 2001 From: JimmyBoivie Date: Sat, 5 Dec 2015 03:05:43 -0500 Subject: [PATCH] Remove added (not tested) --- main/HalfEdge.pde | 56 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/main/HalfEdge.pde b/main/HalfEdge.pde index bbbd1d0..cb7940d 100644 --- a/main/HalfEdge.pde +++ b/main/HalfEdge.pde @@ -8,8 +8,48 @@ public class HalfEdge { // MAKE SURE ALL HALF EDGES ARE INITIALIZED TO FALSE - public HalfEdge(){} + public void Remove() { + Point p = getOrigin(); + Point q = twin.getOrigin(); + int state = -1; + if ((p.count() == 1) && (q.count() == 1)) { + // STRUCTURE IS DISSAPREAING WHAT SHOULD I DO + p.setRef(null); + q.setRef(null); + state = 0; + } else if (p.count() == 1) { + p.setRef(null); + q.setRef(twin.getAnotherLeaving()); + this.getnext().setprevious(twin.getprevious()); + twin.getprevious().setnext(this.getnext()); + // NOTHING SPECIAL MUST BE DONE + state = 1; + } else if (q.count() == 1) { + p.setRef(this.getAnotherLeaving()); + q.setRef(null); + this.getprevious().setnext(twin.getnext()); + twin.getnext().setprevious(this.getprevious()); + // NOTHING SPECIAL MUST BE DONE + state = 1; + } else { + int expected = p.count() - 2; + p.setRef(this.getAnotherLeaving()); + q.setRef(twin.getAnotherLeaving()); + this.getnext().setprevious(twin.getprevious()); + twin.getprevious().setnext(this.getnext()); + this.getprevious().setnext(twin.getnext()); + twin.getnext().setprevious(this.getprevious()); + if (p.count() == expected) { + // was not broken faces merge! + state = 2; + } else { + // structure broken + state = 3; + } + } + } + public HalfEdge(){} public HalfEdge(Point p, Point q) { // SETS THE TWIN settwin(new HalfEdge()); @@ -35,6 +75,7 @@ public class HalfEdge { // this means both things are connected graph if here that means // risk of new face or connected two unconnected components; state = -1; + // we don't know state yet :( } int expected = p.count() + q.count() + 2; connect(); @@ -44,15 +85,10 @@ public class HalfEdge { // two disconnected graphs are now one! state = 2; } else { - state = 3; // a face is divided in 2. + state = 3; } - } - - - - - + } } public void makeVertexReference() { origin.setRef(this); @@ -169,6 +205,10 @@ public class HalfEdge { } return result; } + public HalfEdge getAnotherLeaving() { + return getprevious().gettwin(); + } + public ArrayList getAllLeaving() { ArrayList others = getOtherLeaving(); others.add(this);