private static IList CreateSubgraphs(PlanarGraph graph) { ArrayList subgraphList = new ArrayList(); foreach (object obj in graph.Nodes) { Node node = (Node)obj; 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. */ subgraphList.Sort(); subgraphList.Reverse(); return(subgraphList); }
/// <summary> /// Finds all non-horizontal segments intersecting the stabbing line. /// The stabbing line is the ray to the right of stabbingRayLeftPt. /// </summary> /// <param name="stabbingRayLeftPt">The left-hand origin of the stabbing line.</param> /// <returns>A List of {DepthSegments} intersecting the stabbing line.</returns> private IList FindStabbedSegments(Coordinate stabbingRayLeftPt) { IList stabbedSegments = new ArrayList(); IEnumerator i = _subgraphs.GetEnumerator(); while (i.MoveNext()) { BufferSubgraph bsg = (BufferSubgraph)i.Current; FindStabbedSegments(stabbingRayLeftPt, bsg.DirectedEdges, stabbedSegments); } return(stabbedSegments); }
/// <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> public virtual int CompareTo(Object o) { BufferSubgraph graph = (BufferSubgraph)o; if (RightMostCoordinate.X < graph.RightMostCoordinate.X) { return(-1); } if (RightMostCoordinate.X > graph.RightMostCoordinate.X) { return(1); } return(0); }
/// <summary> /// Completes the building of the input subgraphs by depth-labelling them, /// and adds them to the <see cref="PolygonBuilder" />. /// The subgraph list must be sorted in rightmost-coordinate order. /// </summary> /// <param name="subgraphList">The subgraphs to build.</param> /// <param name="polyBuilder">The PolygonBuilder which will build the final polygons.</param> private static void BuildSubgraphs(IList subgraphList, PolygonBuilder polyBuilder) { IList processedGraphs = new ArrayList(); foreach (object obj in subgraphList) { BufferSubgraph subgraph = (BufferSubgraph)obj; Coordinate p = subgraph.RightMostCoordinate; SubgraphDepthLocater locater = new SubgraphDepthLocater(processedGraphs); int outsideDepth = locater.GetDepth(p); subgraph.ComputeDepth(outsideDepth); subgraph.FindResultEdges(); processedGraphs.Add(subgraph); polyBuilder.Add(subgraph.DirectedEdges, subgraph.Nodes); } }
private static IList CreateSubgraphs(PlanarGraph graph) { ArrayList subgraphList = new ArrayList(); foreach (object obj in graph.Nodes) { Node node = (Node)obj; 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. */ subgraphList.Sort(); subgraphList.Reverse(); return subgraphList; }