use of com.revolsys.geometry.planargraph.Node in project com.revolsys.open by revolsys.
the class PolygonizeGraph method convertMaximalToMinimalEdgeRings.
/**
* Convert the maximal edge rings found by the initial graph traversal
* into the minimal edge rings required by JTS polygon topology rules.
*
* @param ringEdges the list of start edges for the edgeRings to convert.
*/
private void convertMaximalToMinimalEdgeRings(final List ringEdges) {
for (final Iterator i = ringEdges.iterator(); i.hasNext(); ) {
final PolygonizeDirectedEdge de = (PolygonizeDirectedEdge) i.next();
final long label = de.getLabel();
final List intNodes = findIntersectionNodes(de, label);
if (intNodes == null) {
continue;
}
// rings
for (final Iterator iNode = intNodes.iterator(); iNode.hasNext(); ) {
final Node node = (Node) iNode.next();
computeNextCCWEdges(node, label);
}
}
}
use of com.revolsys.geometry.planargraph.Node in project com.revolsys.open by revolsys.
the class PolygonizeGraph method computeNextCWEdges.
private void computeNextCWEdges() {
// set the next pointers for the edges around each node
for (final Iterator iNode = nodeIterator(); iNode.hasNext(); ) {
final Node node = (Node) iNode.next();
computeNextCWEdges(node);
}
}
use of com.revolsys.geometry.planargraph.Node in project com.revolsys.open by revolsys.
the class PolygonizeGraph method deleteDangles.
/**
* Marks all edges from the graph which are "dangles".
* Dangles are which are incident on a node with degree 1.
* This process is recursive, since removing a dangling edge
* may result in another edge becoming a dangle.
* In order to handle large recursion depths efficiently,
* an explicit recursion stack is used
*
* @return a List containing the {@link LineString}s that formed dangles
*/
public Collection<LineString> deleteDangles() {
final List nodesToRemove = findNodesOfDegree(1);
final Set<LineString> dangleLines = new HashSet<>();
final Stack nodeStack = new Stack();
for (final Iterator i = nodesToRemove.iterator(); i.hasNext(); ) {
nodeStack.push(i.next());
}
while (!nodeStack.isEmpty()) {
final Node node = (Node) nodeStack.pop();
deleteAllEdges(node);
final List nodeOutEdges = node.getOutEdges().getEdges();
for (final Iterator i = nodeOutEdges.iterator(); i.hasNext(); ) {
final PolygonizeDirectedEdge de = (PolygonizeDirectedEdge) i.next();
// delete this edge and its sym
de.setMarked(true);
final PolygonizeDirectedEdge sym = (PolygonizeDirectedEdge) de.getSym();
if (sym != null) {
sym.setMarked(true);
}
// save the line as a dangle
final PolygonizeEdge e = (PolygonizeEdge) de.getEdge();
dangleLines.add(e.getLine());
final Node toNode = de.getToNode();
// add the toNode to the list to be processed, if it is now a dangle
if (getDegreeNonDeleted(toNode) == 1) {
nodeStack.push(toNode);
}
}
}
return dangleLines;
}
Aggregations