Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
intsersect check for drawing
  • Loading branch information
JimmyBoivie authored and JimmyBoivie committed Dec 7, 2015
1 parent 712639b commit 14fdd38
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
22 changes: 21 additions & 1 deletion main/HalfEdge.pde
Expand Up @@ -261,6 +261,26 @@ public class HalfEdge {
}
return false;
}

public boolean intersectsStructure(Point p, Point q) {
boolean out = intersectsEventually(p, q);
reset();
return out;
}

private boolean intersectsEventually(Point p, Point q) {
if (this.getOrigin().equals(p)) { return false; }
if (this.getOrigin().equals(q)) { return false; }
if (CompGeo.intersect(p, q, this.getOrigin(), this.gettwin().getOrigin()) {
return true;
}
if (counted == false) {
counted = true;
return (twin.intersectsEventually(p, q) || next.intersectsEventually(p,q) || previous.intersectsEventually(p,q));
}
return false;
}

private boolean isReachableNext(HalfEdge h) {
if (this == h) { return true; }
if (counted == false) {
Expand Down Expand Up @@ -346,4 +366,4 @@ public class HalfEdge {
}
}

}
}
13 changes: 12 additions & 1 deletion main/PointList.pde
Expand Up @@ -49,5 +49,16 @@ public class PointList {
}
return struct;
}

public boolean intersectsSomething(Point p, Point q) {
ArrayList<HalfEdge> structures = getAllStructures();
int num = structures.size();
for (int i = 0; i < num; i++) {
if (structures.get(i).intersectsStructure(p,q) == true) {
return true;
}
}
return false;
}

}
}
36 changes: 18 additions & 18 deletions main/main.pde
Expand Up @@ -9,39 +9,39 @@ public void setup() {
background(255);
fill(0,0);
translate(width/2, height/2);
Point p1 = new Point(0, 0);
Point p1 = new Point(300, 300);
list.addPoint(p1);
Point p2 = new Point(100, 50);
Point p2 = new Point(400, 350);
list.addPoint(p2);
Point p3 = new Point(-200, -50);
Point p3 = new Point(100, 250);
list.addPoint(p3);
Point p4 = new Point(0, 150);
Point p4 = new Point(300, 450);
list.addPoint(p4);
Point p5 = new Point(200, 0);
Point p5 = new Point(500, 300);
list.addPoint(p5);
Point p6 = new Point (-20, -40);
Point p6 = new Point (280, 260);
list.addPoint(p6);
Point p7 = new Point(-50, 0);
Point p7 = new Point(250, 300);
list.addPoint(p7);
Point p8 = new Point(-100, 0);
Point p8 = new Point(200, 300);
list.addPoint(p8);
Point p9 = new Point(-100, 35);
Point p9 = new Point(200, 335);
list.addPoint(p9);
Point p10 = new Point(-50, 35);
Point p10 = new Point(250, 335);
list.addPoint(p10);
Point p11 = new Point(-80, 15);
Point p11 = new Point(200, 315);
list.addPoint(p11);
Point p12 = new Point(-60, 25);
Point p12 = new Point(240, 325);
list.addPoint(p12);
Point p13 = new Point (-25, 25);
Point p13 = new Point (275, 325);
list.addPoint(p13);
Point p14 = new Point (-25, 100);
Point p14 = new Point (275, 400);
list.addPoint(p14);
Point p15 = new Point(-150, -20);
Point p15 = new Point(150, 280);
list.addPoint(p15);
Point p16 = new Point (20, 50);
Point p16 = new Point (320, 350);
list.addPoint(p16);
Point p17 = new Point (20, 100);
Point p17 = new Point (320, 400);
list.addPoint(p17);
HalfEdge h1 = new HalfEdge(p1, p2);
HalfEdge h2 = new HalfEdge(p1, p4);
Expand Down Expand Up @@ -85,7 +85,7 @@ public void setup() {
//h1.facePrint();
//drawgraph.drawGraph(list.getPoints());
//(new Face(h4, list)).printFace();
//(new Face(h12, list)).printFace();
(new Face(h12, list)).printFace();
}
void draw() {
drawgraph.drawGraph(list.getPoints());
Expand Down

0 comments on commit 14fdd38

Please sign in to comment.