diff --git a/main/CompGeo.pde b/main/CompGeo.pde index 91eede7..cc8bcf5 100644 --- a/main/CompGeo.pde +++ b/main/CompGeo.pde @@ -50,11 +50,4 @@ public static class CompGeo { if ((nis % 2) == 0) { return false; } else { return true; } } - - // POINT-INSIDE-FACE METHOD SHOULD GOes here! - - // INTERSECTION METHOD - - - } \ No newline at end of file diff --git a/main/Face.pde b/main/Face.pde index 716738d..587084a 100644 --- a/main/Face.pde +++ b/main/Face.pde @@ -21,6 +21,15 @@ public class Face { innerComponents.remove(he); } + public void updateReference(HalfEdge he) { + for (HalfEdge h: innerComponents) { + if (he.isEventuallyNext(h)) { + removeInnerComponent(h); + } + } + addInnerComponent(he); + } + public ArrayList getInnerComponents() { return innerComponents; } @@ -31,4 +40,6 @@ public class Face { // INSIDE: CHECK IF POINT IS INSIDE A FACE???? + // MAYBE ASSUME OUTTER FACE IS IMPLICIT??? + } \ No newline at end of file diff --git a/main/FaceList.pde b/main/FaceList.pde new file mode 100644 index 0000000..e49033e --- /dev/null +++ b/main/FaceList.pde @@ -0,0 +1,29 @@ +public class FaceList { + + private ArrayList faces; + private Face unboundFace; + + public FaceList() { + faces = new ArrayList(); + unboundFace = new Face(); + } + + public ArrayList getFaces() { + return faces; + } + public Face getUnboundFace() { + return unboundFace; + } + + public boolean contains(Face f) { + return faces.contains(f); + } + + public void addFace(Face f) { + faces.add(f); + } + + public boolean removeFace(Point p) { + return faces.remove(p); + } +} \ No newline at end of file diff --git a/main/HalfEdge.pde b/main/HalfEdge.pde index cb7940d..14c545a 100644 --- a/main/HalfEdge.pde +++ b/main/HalfEdge.pde @@ -14,6 +14,7 @@ public class HalfEdge { int state = -1; if ((p.count() == 1) && (q.count() == 1)) { // STRUCTURE IS DISSAPREAING WHAT SHOULD I DO + // MAKE FACE LOSE CORRESPONDING INNER COMPONENT p.setRef(null); q.setRef(null); state = 0; @@ -23,6 +24,7 @@ public class HalfEdge { this.getnext().setprevious(twin.getprevious()); twin.getprevious().setnext(this.getnext()); // NOTHING SPECIAL MUST BE DONE + // Make Sure face is not represented by dissapearing edge state = 1; } else if (q.count() == 1) { p.setRef(this.getAnotherLeaving()); @@ -30,6 +32,7 @@ public class HalfEdge { this.getprevious().setnext(twin.getnext()); twin.getnext().setprevious(this.getprevious()); // NOTHING SPECIAL MUST BE DONE + // Make sure face is not represented by dissapearing edge state = 1; } else { int expected = p.count() - 2; @@ -41,14 +44,26 @@ public class HalfEdge { twin.getnext().setprevious(this.getprevious()); if (p.count() == expected) { // was not broken faces merge! + // state = 2; } else { // structure broken + // face has 1 more inner component reference state = 3; } } } + public boolean isEventuallyNext(HalfEdge h) { + if (this == h) { return true; } + HalfEdge temp = this.getnext(); + while (temp != this) { + if (temp == h) { return true; } + temp = temp.getnext(); + } + return false; + } + public HalfEdge(){} public HalfEdge(Point p, Point q) { // SETS THE TWIN @@ -63,12 +78,14 @@ public class HalfEdge { int state = -1; if ((p.count() == 0) && (q.count() == 0)) { // this new structure was created not connected to anything + // add to a connected componet of some face // 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 + // nothing needs to be done? state = 1; } else { @@ -83,6 +100,7 @@ public class HalfEdge { if (state == -1) { if (p.count() == expected) { // two disconnected graphs are now one! + // remove a reference an inner component of a face state = 2; } else { // a face is divided in 2.