コード例 #1
0
 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;
 }
コード例 #2
0
 /**
  * Completes the building of the input subgraphs by depth-labelling them, and adds them to the
  * PolygonBuilder. The subgraph list must be sorted in rightmost-coordinate order.
  *
  * @param subgraphList the subgraphs to build
  * @param polyBuilder the PolygonBuilder which will build the final polygons
  */
 private void buildSubgraphs(List subgraphList, PolygonBuilder polyBuilder) {
   List processedGraphs = new ArrayList();
   for (Iterator i = subgraphList.iterator(); i.hasNext(); ) {
     BufferSubgraph subgraph = (BufferSubgraph) i.next();
     Coordinate p = subgraph.getRightmostCoordinate();
     //      int outsideDepth = 0;
     //      if (polyBuilder.containsPoint(p))
     //        outsideDepth = 1;
     SubgraphDepthLocater locater = new SubgraphDepthLocater(processedGraphs);
     int outsideDepth = locater.getDepth(p);
     //      try {
     subgraph.computeDepth(outsideDepth);
     //      }
     //      catch (RuntimeException ex) {
     //        // debugging only
     //        //subgraph.saveDirEdges();
     //        throw ex;
     //      }
     subgraph.findResultEdges();
     processedGraphs.add(subgraph);
     polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
   }
 }