コード例 #1
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //------------------------------------------------------------------------------

        protected virtual void Reset()
        {
            m_CurrentLM = m_MinimaList;

            //reset all edges ...
            LocalMinima lm = m_MinimaList;
            while (lm != null)
            {
                TEdge e = lm.leftBound;
                while (e != null)
                {
                    e.xcurr = e.xbot;
                    e.ycurr = e.ybot;
                    e.side = EdgeSide.esLeft;
                    e.outIdx = -1;
                    e = e.nextInLML;
                }
                e = lm.rightBound;
                while (e != null)
                {
                    e.xcurr = e.xbot;
                    e.ycurr = e.ybot;
                    e.side = EdgeSide.esRight;
                    e.outIdx = -1;
                    e = e.nextInLML;
                }
                lm = lm.next;
            }
            return;
        }
コード例 #2
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //------------------------------------------------------------------------------

        protected void PopLocalMinima()
        {
            if (m_CurrentLM == null) return;
            m_CurrentLM = m_CurrentLM.next;
        }
コード例 #3
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //------------------------------------------------------------------------------

        private void InsertLocalMinima(LocalMinima newLm)
        {
            if (m_MinimaList == null)
            {
                m_MinimaList = newLm;
            }
            else if (newLm.Y >= m_MinimaList.Y)
            {
                newLm.next = m_MinimaList;
                m_MinimaList = newLm;
            }
            else
            {
                LocalMinima tmpLm = m_MinimaList;
                while (tmpLm.next != null && (newLm.Y < tmpLm.next.Y))
                    tmpLm = tmpLm.next;
                newLm.next = tmpLm.next;
                tmpLm.next = newLm;
            }
        }
コード例 #4
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //---------------------------------------------------------------------------

        TEdge AddBoundsToLML(TEdge e)
        {
            //Starting at the top of one bound we progress to the bottom where there's
            //a local minima. We then go to the top of the next bound. These two bounds
            //form the left and right (or right and left) bounds of the local minima.
            e.nextInLML = null;
            e = e.next;
            for (; ; )
            {
                if (e.dx == horizontal)
                {
                    //nb: proceed through horizontals when approaching from their right,
                    //    but break on horizontal minima if approaching from their left.
                    //    This ensures 'local minima' are always on the left of horizontals.
                    if (e.next.ytop < e.ytop && e.next.xbot > e.prev.xbot) break;
                    if (e.xtop != e.prev.xbot) SwapX(e);
                    e.nextInLML = e.prev;
                }
                else if (e.ycurr == e.prev.ycurr) break;
                else e.nextInLML = e.prev;
                e = e.next;
            }

            //e and e.prev are now at a local minima ...
            LocalMinima newLm = new LocalMinima();
            newLm.next = null;
            newLm.Y = e.prev.ybot;

            if (e.dx == horizontal) //horizontal edges never start a left bound
            {
                if (e.xbot != e.prev.xbot) SwapX(e);
                newLm.leftBound = e.prev;
                newLm.rightBound = e;
            }
            else if (e.dx < e.prev.dx)
            {
                newLm.leftBound = e.prev;
                newLm.rightBound = e;
            }
            else
            {
                newLm.leftBound = e;
                newLm.rightBound = e.prev;
            }
            newLm.leftBound.side = EdgeSide.esLeft;
            newLm.rightBound.side = EdgeSide.esRight;
            InsertLocalMinima(newLm);

            for (; ; )
            {
                if (e.next.ytop == e.ytop && e.next.dx != horizontal) break;
                e.nextInLML = e.next;
                e = e.next;
                if (e.dx == horizontal && e.xbot != e.prev.xtop) SwapX(e);
            }
            return e.next;
        }
コード例 #5
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //------------------------------------------------------------------------------

        private void DisposeLocalMinimaList()
        {
            while (m_MinimaList != null)
            {
                LocalMinima tmpLm = m_MinimaList.next;
                m_MinimaList = null;
                m_MinimaList = tmpLm;
            }
            m_CurrentLM = null;
        }
コード例 #6
0
ファイル: Clipper.cs プロジェクト: charlierix/AsteroidMiner
        //------------------------------------------------------------------------------

        internal ClipperBase() //constructor (nb: no external instantiation)
        {
            m_MinimaList = null;
            m_CurrentLM = null;
            m_UseFullRange = false;
        }