private List createSubgraphs(PlanarGraph graph) { List subgraphList = new ArrayList(); for (Iterator i = graph.getNodes().iterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (! node.isVisited()) { BufferSubgraph subgraph = new BufferSubgraph(); subgraph.create(node); subgraphList.add(subgraph); } } /** * Sort the subgraphs in descending order of their rightmost coordinate. * This ensures that when the Polygons for the subgraphs are built, * subgraphs for shells will have been built before the subgraphs for * any holes they contain. */ Collections.sort(subgraphList, Collections.reverseOrder()); return subgraphList; }
/** * Adds all nodes and edges reachable from this node to the subgraph. * Uses an explicit stack to avoid a large depth of recursion. * * @param node a node known to be in the subgraph */ private void addReachable(Node startNode) { Stack nodeStack = new Stack(); nodeStack.add(startNode); while (! nodeStack.empty()) { Node node = (Node) nodeStack.pop(); add(node, nodeStack); } }
/** * Creates the subgraph consisting of all edges reachable from this node. * Finds the edges in the graph and the rightmost coordinate. * * @param node a node to start the graph traversal from */ public void create(Node node) { addReachable(node); finder.findEdge(dirEdgeList); rightMostCoord = finder.getCoordinate(); }
public void computeDepth(int outsideDepth) { clearVisitedEdges(); // find an outside edge to assign depth to DirectedEdge de = finder.getEdge(); Node n = de.getNode(); Label label = de.getLabel(); // right side of line returned by finder is on the outside de.setEdgeDepths(Position.RIGHT, outsideDepth); copySymDepths(de); //computeNodeDepth(n, de); computeDepths(de); }
for (Iterator i = subgraphList.iterator(); i.hasNext(); ) { BufferSubgraph subgraph = (BufferSubgraph) i.next(); Coordinate p = subgraph.getRightmostCoordinate(); int outsideDepth = locater.getDepth(p); subgraph.computeDepth(outsideDepth); subgraph.findResultEdges(); processedGraphs.add(subgraph); polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
private void computeNodeDepth(Node n) { // find a visited dirEdge to start at DirectedEdge startEdge = null; for (Iterator i = ((DirectedEdgeStar) n.getEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); if (de.isVisited() || de.getSym().isVisited()) { startEdge = de; break; } } // MD - testing Result: breaks algorithm //if (startEdge == null) return; // only compute string append if assertion would fail if (startEdge == null) throw new TopologyException("unable to find edge to compute depths at " + n.getCoordinate()); ((DirectedEdgeStar) n.getEdges()).computeDepths(startEdge); // copy depths to sym edges for (Iterator i = ((DirectedEdgeStar) n.getEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); de.setVisited(true); copySymDepths(de); } }
nodesVisited.add(n); computeNodeDepth(n);
for (Iterator i = subgraphList.iterator(); i.hasNext(); ) { BufferSubgraph subgraph = (BufferSubgraph) i.next(); Coordinate p = subgraph.getRightmostCoordinate(); int outsideDepth = locater.getDepth(p); subgraph.computeDepth(outsideDepth); subgraph.findResultEdges(); processedGraphs.add(subgraph); polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
public void computeDepth(int outsideDepth) { clearVisitedEdges(); // find an outside edge to assign depth to DirectedEdge de = finder.getEdge(); Node n = de.getNode(); Label label = de.getLabel(); // right side of line returned by finder is on the outside de.setEdgeDepths(Position.RIGHT, outsideDepth); copySymDepths(de); //computeNodeDepth(n, de); computeDepths(de); }
private void computeNodeDepth(Node n) { // find a visited dirEdge to start at DirectedEdge startEdge = null; for (Iterator i = ((DirectedEdgeStar) n.getEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); if (de.isVisited() || de.getSym().isVisited()) { startEdge = de; break; } } // MD - testing Result: breaks algorithm //if (startEdge == null) return; // only compute string append if assertion would fail if (startEdge == null) throw new TopologyException("unable to find edge to compute depths at " + n.getCoordinate()); ((DirectedEdgeStar) n.getEdges()).computeDepths(startEdge); // copy depths to sym edges for (Iterator i = ((DirectedEdgeStar) n.getEdges()).iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); de.setVisited(true); copySymDepths(de); } }
nodesVisited.add(n); computeNodeDepth(n);
private List createSubgraphs(PlanarGraph graph) { List subgraphList = new ArrayList(); for (Iterator i = graph.getNodes().iterator(); i.hasNext(); ) { Node node = (Node) i.next(); if (! node.isVisited()) { BufferSubgraph subgraph = new BufferSubgraph(); subgraph.create(node); subgraphList.add(subgraph); } } /** * Sort the subgraphs in descending order of their rightmost coordinate. * This ensures that when the Polygons for the subgraphs are built, * subgraphs for shells will have been built before the subgraphs for * any holes they contain. */ Collections.sort(subgraphList, Collections.reverseOrder()); return subgraphList; }
/** * Creates the subgraph consisting of all edges reachable from this node. * Finds the edges in the graph and the rightmost coordinate. * * @param node a node to start the graph traversal from */ public void create(Node node) { addReachable(node); finder.findEdge(dirEdgeList); rightMostCoord = finder.getCoordinate(); }
/** * Adds all nodes and edges reachable from this node to the subgraph. * Uses an explicit stack to avoid a large depth of recursion. * * @param node a node known to be in the subgraph */ private void addReachable(Node startNode) { Stack nodeStack = new Stack(); nodeStack.add(startNode); while (! nodeStack.empty()) { Node node = (Node) nodeStack.pop(); add(node, nodeStack); } }