Skip to content

Commit

Permalink
Work on faces
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyBoivie authored and JimmyBoivie committed Dec 5, 2015
1 parent d0604f5 commit 6777d5b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
7 changes: 0 additions & 7 deletions main/CompGeo.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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



}
11 changes: 11 additions & 0 deletions main/Face.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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<HalfEdge> getInnerComponents() {
return innerComponents;
}
Expand All @@ -31,4 +40,6 @@ public class Face {
// INSIDE: CHECK IF POINT IS INSIDE A FACE????


// MAYBE ASSUME OUTTER FACE IS IMPLICIT???

}
29 changes: 29 additions & 0 deletions main/FaceList.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class FaceList {

private ArrayList<Face> faces;
private Face unboundFace;

public FaceList() {
faces = new ArrayList<Face>();
unboundFace = new Face();
}

public ArrayList<Face> 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);
}
}
18 changes: 18 additions & 0 deletions main/HalfEdge.pde
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,13 +24,15 @@ 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());
q.setRef(null);
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;
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit 6777d5b

Please sign in to comment.