Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
80 lines (72 sloc) 2.4 KB
public class Face {
HalfEdge outerComponent;
ArrayList<HalfEdge> innerComponents;
public Face(HalfEdge ref, PointList points) {
if (CompGeo.signedAreaHE(ref) < 0) { outerComponent = ref; }
else { outerComponent = CompGeo.findTightOuterBoundary(ref, points); }
innerComponents = CompGeo.findFriends(outerComponent, points);
}
public void daColoring(int r, int g, int b, PointList pl, float x, float y) {
Point p = null;
stroke(r,g,b);
float minX = 0;
float maxX = x;
float minY = 0;
float maxY = y;
if (outerComponent != null) {
minX = outerComponent.getOrigin().getX();
maxX = outerComponent.getOrigin().getX();
minY = outerComponent.getOrigin().getY();
maxY = outerComponent.getOrigin().getY();
HalfEdge temp = outerComponent.getnext();
while (temp != outerComponent) {
p = temp.getOrigin();
if (p.getX() < minX) { minX = p.getX(); }
if (p.getX() > maxX) { maxX = p.getX(); }
if (p.getY() < minY) { minY = p.getY(); }
if (p.getY() > maxY) { maxY = p.getY(); }
temp = temp.getnext();
}
}
for (int i = (int) minX; i < (int)maxX; i++) {
for (int j = (int) minY; j < (int)maxY; j++) {
p = new Point(i, j);
if (inSpecificFace(p, pl)) {
point(i,j);
//System.out.println(p);
}
}
}
stroke(0);
}
public boolean inSpecificFace(Point a, PointList pl) {
if ((outerComponent == null) || (CompGeo.inside(outerComponent, a, pl.getFar()))) {
//System.out.println(a);
int num = innerComponents.size();
for (int i = 0; i < num; i++) {
if (inAnInner(innerComponents.get(i), a, pl)) {
return false;
}
}
return true;
}
return false;
}
public boolean inAnInner(HalfEdge inner, Point a, PointList pl) {
if (CompGeo.signedAreaHE(inner) == 0) { return false; }
if (CompGeo.inside(inner, a, pl.getFar())) { return true; }
return false;
}
public void printFace() {
//System.out.println("Outer Face:");
if (outerComponent != null) { outerComponent.printRNext(); }
//System.out.println();
//System.out.println("Inner Components:");
int num = innerComponents.size();
for (int i = 0; i < num; i++) {
//System.out.println("COMPONENT[" + i + "]");
innerComponents.get(i).printRNext();
}
//System.out.println();
}
}
You can’t perform that action at this time.