Skip to content
Permalink
a88442ab48
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
84 lines (71 sloc) 1.85 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 getHalfEdge(Point p, Point q) {
int num = points.size();
int id = -1;
for (int i = 0; i < num; i++) {
if (p.equals(points.get(i))) {
id = i;
}
}
HalfEdge first = p.getRef();
if (first == null) { return null; }
HalfEdge temp = first.gettwin().getnext();
while (temp != first) {
if (temp.gettwin().getOrigin().equals(q)) {
return temp;
}
}
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;
}
}