private ArrayList CreateSubgraphs() { ArrayList subgraphList = new ArrayList(); //for (Iterator i = graph.getNodes().iterator(); i.hasNext(); ) foreach (DictionaryEntry obj in _graph.Nodes) { Node node = (Node)obj.Value; if (!node.IsVisited) { BufferSubgraph subgraph = new BufferSubgraph(_cga); 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. */ // IComparer reverse = new ReverseOrder(); object[] objarray = subgraphList.ToArray(); Array.Sort(objarray, reverse); return(new ArrayList(objarray)); //Collections.Sort(subgraphList, Collections.reverseOrder()); //return subgraphList; }
/// <summary> /// BufferSubgraphs are compared on the x-value of their rightmost Coordinate. This defines a partial /// ordering on the graphs such that: /// g1 >= g2 <==> Ring(g2) does not contain Ring(g1) /// where Polygon(g) is the buffer polygon that is built from g. /// This relationship is used to sort the BufferSubgraphs so that shells are guaranteed to /// be built before holes. /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo(object obj) { BufferSubgraph graph = (BufferSubgraph)obj; if (this.GetRightmostCoordinate().X < graph.GetRightmostCoordinate().X) { return(-1); } if (this.GetRightmostCoordinate().X > graph.GetRightmostCoordinate().X) { return(1); } return(0); }
private void BuildSubgraphs(ArrayList subgraphList, PolygonBuilder polyBuilder) { //for (Iterator i = subgraphList.iterator(); i.hasNext(); ) foreach (object obj in subgraphList) { BufferSubgraph subgraph = (BufferSubgraph)obj; Coordinate p = subgraph.GetRightmostCoordinate(); int outsideDepth = 0; if (polyBuilder.ContainsPoint(p)) { outsideDepth = 1; } subgraph.ComputeDepth(outsideDepth); subgraph.FindResultEdges(); polyBuilder.Add(subgraph.GetDirectedEdges(), subgraph.GetNodes()); } }