/// <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 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);
        }
Exemplo n.º 2
0
        private static IEnumerable <BufferSubgraph> CreateSubgraphs(PlanarGraph graph)
        {
            var subgraphList = new List <BufferSubgraph>();

            foreach (Node node in graph.Nodes)
            {
                if (!node.IsVisited)
                {
                    var 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);
        }
Exemplo n.º 3
0
 private static IEnumerable<BufferSubgraph> CreateSubgraphs(PlanarGraph graph)
 {
     var subgraphList = new List<BufferSubgraph>();
     foreach (Node node in graph.Nodes)
     {
         if (!node.IsVisited)
         {
             var 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;
 }