linkMinimalDirectedEdges method
void
linkMinimalDirectedEdges(
- EdgeRing er
)
Implementation
void linkMinimalDirectedEdges(EdgeRing er) {
// find first area edge (if any) to start linking at
DirectedEdge? firstOut = null;
DirectedEdge? incoming = null;
int state = SCANNING_FOR_INCOMING;
// link edges in CW order
for (int i = resultAreaEdgeList!.length - 1; i >= 0; i--) {
DirectedEdge nextOut = resultAreaEdgeList![i] as DirectedEdge;
DirectedEdge nextIn = nextOut.getSym();
// record first outgoing edge, in order to link the last incoming edge
if (firstOut == null && nextOut.getEdgeRing() == er) firstOut = nextOut;
switch (state) {
case SCANNING_FOR_INCOMING:
if (nextIn.getEdgeRing() != er) continue;
incoming = nextIn;
state = LINKING_TO_OUTGOING;
break;
case LINKING_TO_OUTGOING:
if (nextOut.getEdgeRing() != er) continue;
incoming!.setNextMin(nextOut);
state = SCANNING_FOR_INCOMING;
break;
}
}
//print(System.out);
if (state == LINKING_TO_OUTGOING) {
assert(firstOut != null, "found null for first outgoing dirEdge");
assert(firstOut!.getEdgeRing() == er,
"unable to link last incoming dirEdge");
incoming!.setNextMin(firstOut!);
}
}