Skip to content

Commit

Permalink
added test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cor11004 committed Dec 3, 2015
1 parent 29c0acf commit d4a77b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
12 changes: 9 additions & 3 deletions main/DrawHalfEdge.pde
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class DrawHalfEdge {
line(v1.getX(), v1.getY(), v2.getX(), v2.getY());
}
public void drawpoint(Vertex v) {
point(v.getX(), v.getY());
ellipse(v.getX(), v.getY(),25,25);
}

public void drawGraph(ArrayList<Vertex> vlist) {
Expand All @@ -17,13 +17,19 @@ public class DrawHalfEdge {
public void drawConnectedGraph(Vertex vertex) {
ArrayList<HalfEdge> edges = vertex.getAllLeavingEdges();
drawpoint(vertex);
for(HalfEdge edge: edges) {
drawConnection(edge, vertex);
if(edges != null) {
System.out.println("edges are not null");
for(HalfEdge edge: edges) {
drawConnection(edge, vertex);
}
}
}

public void drawConnection(HalfEdge edge, Vertex v1) {
System.out.println("drawing connection");
Vertex v2 = edge.getOrigin();
System.out.println(v1);
System.out.println(v2);
drawpoint(v2);
drawline(v1, v2);
}
Expand Down
7 changes: 7 additions & 0 deletions main/Vertex.pde
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class Vertex {
return halfedge;
}
public ArrayList<HalfEdge> getAllLeavingEdges() {
if(halfedge == null) {
return null;
}
return halfedge.getHalfEdgesAlsoLeaving();
}
public void setIncidentEdge(HalfEdge e) {
Expand Down Expand Up @@ -125,4 +128,8 @@ public class Vertex {

}

public String toString() {
return "x: " + x + "\n" + "y: " + y;
}

}
19 changes: 16 additions & 3 deletions main/main.pde
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@ public void settings() {
public void setup() {
background(255);
fill(0,0);
translate(width/2, height/2);
VertexList list = new VertexList();
Vertex v = new Vertex(0,0);
Vertex v1 = new Vertex(0,200);
Vertex v2 = new Vertex(100,100);
Vertex v3 = new Vertex(200,0);
list.addVertex(v);
list.addVertex(v1);
list.addVertex(v2);
list.addVertex(v3);
DrawHalfEdge draw = new DrawHalfEdge();
HalfEdge h1 = new HalfEdge(v, v1);
draw.drawGraph(list.getVertexList());
}
public void draw() {
/*public void draw() {
fill(0,0,255,40);
noStroke();
pushMatrix(); // store the default translation matrix
translate(width/2, height/2); // alter the current translation
ellipse(0,0,100,100); //place the sphere in center of current translation
//ellipse(0,0,100,100); //place the sphere in center of current translation
popMatrix(); // return to default translation
}
}*/

0 comments on commit d4a77b2

Please sign in to comment.