checkAreaLabelsConsistent method
bool
checkAreaLabelsConsistent(
- int geomIndex
)
Implementation
bool checkAreaLabelsConsistent(int geomIndex) {
// Since edges are stored in CCW order around the node,
// As we move around the ring we move from the right to the left side of the edge
List edges = getEdges();
// if no edges, trivially consistent
if (edges.length <= 0) return true;
// initialize startLoc to location of last L side (if any)
int lastEdgeIndex = edges.length - 1;
Label startLabel = (edges[lastEdgeIndex] as EdgeEnd).getLabel()!;
int startLoc = startLabel.getLocationWithPosIndex(geomIndex, Position.LEFT);
// TODO Assert.isTrue(startLoc != Location.NONE, "Found unlabelled area edge");
int currLoc = startLoc;
for (Iterator it = iterator(); it.moveNext();) {
EdgeEnd e = it.current;
Label label = e.getLabel()!;
// we assume that we are only checking a area
// TODO Assert.isTrue(label.isArea(geomIndex), "Found non-area edge");
int leftLoc = label.getLocationWithPosIndex(geomIndex, Position.LEFT);
int rightLoc = label.getLocationWithPosIndex(geomIndex, Position.RIGHT);
//System.out.println(leftLoc + " " + rightLoc);
//Debug.print(this);
// check that edge is really a boundary between inside and outside!
if (leftLoc == rightLoc) {
return false;
}
// check side location conflict
//Assert.isTrue(rightLoc == currLoc, "side location conflict " + locStr);
if (rightLoc != currLoc) {
//Debug.print(this);
return false;
}
currLoc = leftLoc;
}
return true;
}