Exemplo n.º 1
0
 public EdgeNode this[int i]
 {
     get
     {
         if (i >= EdgeCount)
         {
             return(null);
         }
         EdgeNode tmp = Head;
         for (int j = 0; j < i; j++)
         {
             tmp = tmp.NextEdge;
         }
         return(tmp);
     }
     set
     {
         if (i >= EdgeCount)
         {
             return;
         }
         EdgeNode tmp = Head;
         for (int j = 0; j < i; j++)
         {
             tmp = tmp.NextEdge;
         }
         tmp = value;
     }
 }
Exemplo n.º 2
0
 public void AddAtIndex(int index, EdgeNode node)
 {
     if (edgeTable[index] == null)
     {
         edgeTable[index] = new EdgeList();
     }
     edgeTable[index].Add(node);
     EdgeCount++;
 }
Exemplo n.º 3
0
 public void Add(EdgeNode e)
 {
     if (Head == null)
     {
         Head = Tail = e;
     }
     else
     {
         Tail.NextEdge = e;
     }
     Tail          = e;
     Tail.NextEdge = null;
     EdgeCount++;
     return;
 }
Exemplo n.º 4
0
        private static EdgeTable PrepareEdgeTable(Polygon polygon)
        {
            EdgeTable edgeTable = new EdgeTable((int)polygon.GetMaxY() + 1);

            foreach (Edge e in polygon.Edges)
            {
                if (e.Vertices[0].GetY() == e.Vertices[1].GetY())
                {
                    continue;
                }
                EdgeNode node  = new EdgeNode(e);
                int      index = (int)e.GetMinY();
                edgeTable.AddAtIndex(index, node);
            }
            return(edgeTable);
        }
Exemplo n.º 5
0
        public void Delete(EdgeNode e)
        {
            EdgeList deleted = new EdgeList();
            EdgeNode tmp     = Head;

            while (tmp != null)
            {
                if (tmp != e)
                {
                    deleted.Add(tmp);
                }
                tmp = tmp.NextEdge;
            }
            EdgeCount = deleted.EdgeCount;
            Head      = deleted.Head;
            Tail      = deleted.Tail;
        }
Exemplo n.º 6
0
        public void SortByX()
        {
            List <EdgeNode> list = new List <EdgeNode>(EdgeCount);
            EdgeNode        p    = Head;

            while (p != null)
            {
                list.Add(p);
                p = p.NextEdge;
            }
            list.Sort();
            Head      = Tail = null;
            EdgeCount = 0;
            foreach (var item in list)
            {
                Add(item);
            }
        }
Exemplo n.º 7
0
        private void DeleteAtIndex(int index)
        {
            if (index >= EdgeCount)
            {
                return;
            }
            if (index == 0)
            {
                Head = Head.NextEdge;
            }
            EdgeNode tmp      = Head;
            EdgeNode previous = tmp;

            for (int i = 0; i <= index; i++)
            {
                previous = tmp;
                tmp      = tmp.NextEdge;
            }
            previous.NextEdge = tmp.NextEdge;
            tmp.NextEdge      = null;
            EdgeCount--;
        }
Exemplo n.º 8
0
        public void DeleteFinishedLines(int y)
        {
            List <EdgeNode> list = new List <EdgeNode>(EdgeCount);
            EdgeNode        p    = Head;

            while (p != null)
            {
                list.Add(p);
                p = p.NextEdge;
            }
            List <EdgeNode> del = list.FindAll(x => ((int)Math.Floor(x.Ymax)) <= y);

            foreach (var item in del)
            {
                list.Remove(item);
            }
            Head      = Tail = null;
            EdgeCount = 0;
            foreach (var item in list)
            {
                Add(item);
            }
        }