コード例 #1
0
ファイル: Form1.cs プロジェクト: hsshhsxm/course-work
        private void InitET(List <EDGE>[] edges, int minY)
        {
            List <int> tmpList = new List <int>();
            EDGE       e;

            for (int i = 0; i < points.Count; i++)
            {
                Point start     = points[i];
                Point end       = points[(i + 1) % points.Count];
                Point prevStart = points[(i - 1 + points.Count) % points.Count];
                Point afterEnd  = points[(i + 2) % points.Count];
                if (start.Y != end.Y)
                {
                    e = new EDGE();
                    e.SetDx(start, end);
                    if (end.Y > start.Y)
                    {
                        e.SetX((double)start.X);
                        if (afterEnd.Y >= end.Y)
                        {
                            e.SetYmax(end.Y - 1);
                        }
                        else
                        {
                            e.SetYmax(end.Y);
                        }
                        edges[start.Y - minY].Add(e);
                        tmpList.Add(start.Y - minY);
                    }
                    else
                    {
                        e.SetX((double)end.X);
                        if (prevStart.Y >= start.Y)
                        {
                            e.SetYmax(start.Y - 1);
                        }
                        else
                        {
                            e.SetYmax(start.Y);
                        }
                        edges[end.Y - minY].Add(e);
                        tmpList.Add(end.Y - minY);
                    }
                }
            }
            for (int i = 0; i < tmpList.Count; i++)
            {
                My_Sort(ref edges[tmpList[i]]);
            }
        }