From 98ddaeec7d883ae378e7f1814de39f6ba4f109b3 Mon Sep 17 00:00:00 2001 From: JimmyBoivie Date: Sat, 5 Dec 2015 21:06:45 -0500 Subject: [PATCH] reachable --- main/CompGeo.pde | 3 +++ main/HalfEdge.pde | 15 +++++++++++++++ main/Point.pde | 2 ++ main/PointList.pde | 17 +++++++++++++++++ main/main.pde | 2 +- 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/main/CompGeo.pde b/main/CompGeo.pde index bb7bef0..96241e1 100644 --- a/main/CompGeo.pde +++ b/main/CompGeo.pde @@ -67,4 +67,7 @@ public static class CompGeo { } return sum; } + + + } \ No newline at end of file diff --git a/main/HalfEdge.pde b/main/HalfEdge.pde index 55982c7..7366b89 100644 --- a/main/HalfEdge.pde +++ b/main/HalfEdge.pde @@ -253,6 +253,21 @@ public class HalfEdge { System.out.println(); } + private boolean isReachable(HalfEdge h) { + if (this == h) { return true; } + if (counted == false) { + counted = true; + return (twin.isReachable(h) || next.isReachable(h) || previous.isReachable(h)); + } + return false; + } + + public boolean canReach(HalfEdge h) { + boolean out = isReachable(h); + reset(); + return out; + } + // may not want getters, but for now they are here. public void setprevious(HalfEdge p) { diff --git a/main/Point.pde b/main/Point.pde index 60ca3df..565a1be 100644 --- a/main/Point.pde +++ b/main/Point.pde @@ -52,4 +52,6 @@ public class Point { return ref.countReset(); } + + } \ No newline at end of file diff --git a/main/PointList.pde b/main/PointList.pde index 588acc4..37d011b 100644 --- a/main/PointList.pde +++ b/main/PointList.pde @@ -23,4 +23,21 @@ public class PointList { public boolean removePoint(Point p) { return points.remove(p); } + + public ArrayList getAllStructures() { + int num = points.size(); + ArrayList struct = new ArrayList(); + for (int i = 0; i < num; i++) { + if (points.get(i).getRef().getCounted() == false) { + points.get(i).getRef().count(); + struct.add(points.get(i).getRef()); + } + } + num = struct.size(); + for (int i = 0; i < num; i++) { + struct.get(i).reset(); + } + return struct; + } + } \ No newline at end of file diff --git a/main/main.pde b/main/main.pde index 22059e5..e4b3485 100644 --- a/main/main.pde +++ b/main/main.pde @@ -24,7 +24,7 @@ public void setup() { HalfEdge h2 = new HalfEdge(p1, p4); HalfEdge h3 = new HalfEdge(p3, p1); HalfEdge h4 = new HalfEdge(p1, p5); - HalfEdge h5 = new HalfEdge(p3, p4); + //HalfEdge h5 = new HalfEdge(p3, p4); float f = CompGeo.signedArea(h2.gettwin()); float f2 = CompGeo.signedArea(h2); System.out.println("Signed Area: " + f);