示例#1
0
        /// <summary>
        /// <see cref="BufferSubgraphs"/> are compared on the x-value of their
        /// rightmost Coordinate. This defines a partial ordering on the graphs such that:
        /// <para>
        /// g1 >= g2 &lt;==&gt; Ring(g2) does not contain Ring(g1)
        /// </para>
        /// <para>
        /// where Polygon(g) is the buffer polygon that is built from g.
        /// </para>
        /// This relationship is used to sort the BufferSubgraphs so that shells
        /// are guaranteed to be built before holes.
        /// </summary>
        public int CompareTo(object o)
        {
            BufferSubgraph graph = (BufferSubgraph)o;

            if (this.rightMostCoord.X < graph.rightMostCoord.X)
            {
                return(-1);
            }
            if (this.rightMostCoord.X > graph.rightMostCoord.X)
            {
                return(1);
            }
            return(0);
        }
示例#2
0
		/// <summary> 
		/// 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.
		/// </summary>
		/// <param name="subgraphList">the subgraphs to build
		/// </param>
		/// <param name="polyBuilder">the PolygonBuilder which will build the final polygons
		/// </param>
		private void BuildSubgraphs(IList subgraphList, PolygonBuilder polyBuilder)
		{
			ArrayList processedGraphs = new ArrayList();

            int nCount = subgraphList.Count;

            for (int i = 0; i < nCount; i++)
			{
				BufferSubgraph subgraph = (BufferSubgraph)subgraphList[i];
				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);
			}
		}
        /// <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 {@link DepthSegments} intersecting the stabbing line
        /// </returns>
        private ArrayList FindStabbedSegments(Coordinate stabbingRayLeftPt)
        {
            ArrayList stabbedSegments = new ArrayList();

            for (IEnumerator i = subgraphs.GetEnumerator(); i.MoveNext();)
            {
                BufferSubgraph bsg = (BufferSubgraph)i.Current;

                // optimization - don't bother checking subgraphs which the ray does not intersect
                Envelope env = bsg.Envelope;
                if (stabbingRayLeftPt.Y < env.MinY ||
                    stabbingRayLeftPt.Y > env.MaxY)
                {
                    continue;
                }

                FindStabbedSegments(stabbingRayLeftPt,
                                    bsg.DirectedEdges, stabbedSegments);
            }

            return(stabbedSegments);
        }
示例#4
0
		private IList CreateSubgraphs(PlanarGraph graph)
		{
			ArrayList subgraphList = new ArrayList();

            for (IEnumerator i = graph.Nodes.GetEnumerator(); i.MoveNext(); )
			{
				Node node = (Node) i.Current;
				if (!node.Visited)
				{
					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(new ReverseComparator());

			return subgraphList;
		}