Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
half edge removal method
  • Loading branch information
cor11004 committed Dec 7, 2015
1 parent a88442a commit 1445a49
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions main/PointList.pde
Expand Up @@ -61,11 +61,13 @@ public class PointList {
}
HalfEdge first = p.getRef();
if (first == null) { return null; }
if (first.gettwin().getOrigin().equals(q)) { return first; }
HalfEdge temp = first.gettwin().getnext();
while (temp != first) {
if (temp.gettwin().getOrigin().equals(q)) {
return temp;
}
temp = temp.gettwin().getnext();
}
return null;
}
Expand Down
39 changes: 37 additions & 2 deletions main/main.pde
Expand Up @@ -4,6 +4,9 @@ int mode = 0;
Point pointclicked;
PointList list = new PointList();
DrawHalfEdge drawgraph = new DrawHalfEdge();
boolean removeEdge = false;
Point removeEdgePoint;


public void setup() {
size(800, 500);
Expand Down Expand Up @@ -100,7 +103,7 @@ void keyPressed() {
case 'r':
mode = 1;
break;
case 'h':
case 'e':
mode = 2;
break;
case 'p':
Expand All @@ -125,6 +128,9 @@ void mouseReleased() {
case 1:
removePointMode(x,y);
break;
case 2:
removeEdgeMode(x,y);
break;
}
}
public void insertMode(float x, float y) {
Expand Down Expand Up @@ -162,7 +168,6 @@ public void insertMode(float x, float y) {
}

public void removePointMode(float x, float y) {
System.out.println("entered remove point");
boolean removePoint = false;
Point removeThis = null;
for(Point p: list.getPoints()) {
Expand All @@ -178,3 +183,33 @@ public void removePointMode(float x, float y) {
list.removePoint(removeThis);
}
}

public void removeEdgeMode(float x, float y) {
if(removeEdge) {
for(Point p: list.getPoints()) {
if((p.getX() - 10 < x) && (p.getX() + 10 > x)) {
if((p.getY() - 10 < y) && (p.getY() + 10 > y)) {
HalfEdge h = list.getHalfEdge(removeEdgePoint, p);
System.out.println("is halfedge null?");
System.out.println(p);
if(h != null) {
System.out.println("edge should be removed");
h.Remove();
}
removeEdge = false;
}
}
}
} else {
for(Point p: list.getPoints()) {
if((p.getX() - 10 < x) && (p.getX() + 10 > x)) {
if((p.getY() - 10 < y) && (p.getY() + 10 > y)) {
System.out.println("got first point");
System.out.println(p);
removeEdgePoint = p;
removeEdge = true;
}
}
}
}
}

0 comments on commit 1445a49

Please sign in to comment.