* @return The correct direction to form the new ring.
*/
private int testDirection(final DirectedEdge startEdge,
final int direction) {
DirectedEdge currentDirectedEdge = startEdge;
DirectedEdge nextDirectedEdge = null;
int finalDirection = direction;
while (!edgesAreEqual((SplitEdge) startEdge.getEdge(),
nextDirectedEdge)) {
SplitEdge currentEdge = (SplitEdge) currentDirectedEdge
.getEdge();
// if thats true, it means that ring already exist, so return
// the opposite direction.
if (currentEdge.isTwiceVisited()) {
finalDirection = (direction == CGAlgorithms.CLOCKWISE) ? CGAlgorithms.COUNTERCLOCKWISE
: CGAlgorithms.CLOCKWISE;
break;
}
DirectedEdge sym = currentDirectedEdge.getSym();
SplitGraphNode endNode = (SplitGraphNode) sym.getNode();
SplitEdgeStar nodeEdges = (SplitEdgeStar) endNode.getEdges();
nextDirectedEdge = nodeEdges.findClosestEdgeInDirection(sym,
direction);