Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
99 lines (85 sloc) 2.34 KB
public class PointList {
private ArrayList<Point> points;
private Point far;
public PointList() {
points = new ArrayList<Point>();
far = new Point(0, 10000);
}
public Point getFar() {
return far;
}
public ArrayList<Point> getPoints() {
return points;
}
public boolean contains(Point p) {
return points.contains(p);
}
public void addPoint(Point p) {
points.add(p);
if (p.getY() > far.getY()) {
far.setY(p.getY() + 1);
}
}
public boolean removePoint(Point p) {
p.deleteEdges();
return points.remove(p);
}
public ArrayList<HalfEdge> getAllStructures() {
int num = points.size();
ArrayList<HalfEdge> struct = new ArrayList<HalfEdge>();
for (int i = 0; i < num; i++) {
if (points.get(i).getRef() == null) { continue; }
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;
}
public HalfEdge getHalfEdgeBySinglePoint(float x, float y, float distance) {
ArrayList<HalfEdge> pieces = getAllStructures();
int num = pieces.size();
HalfEdge temp = null;
for (int i = 0; i < num; i++) {
temp = pieces.get(i).findStart(x,y,distance, far);
if (temp != null) { return temp; }
}
return null;
}
public HalfEdge getHalfEdge(Point p, Point q) {
//System.out.println(p);
//System.out.println(q);
int num = points.size();
int id = -1;
for (int i = 0; i < num; i++) {
if (p == points.get(i)) {
id = i;
}
}
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;
}
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;
}
}
You can’t perform that action at this time.