Ejemplo n.º 1
0
 //------------------------------------------------------------------------------
 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;
       }
 }
Ejemplo n.º 2
0
 //------------------------------------------------------------------------------
 private void DisposeLocalMinimaList()
 {
     while( m_MinimaList != null )
     {
         LocalMinima tmpLm = m_MinimaList.next;
         m_MinimaList = null;
         m_MinimaList = tmpLm;
     }
     m_CurrentLM = null;
 }
Ejemplo n.º 3
0
        //---------------------------------------------------------------------------
        TEdge4 AddBoundsToLML(TEdge4 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;
        }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------
        protected virtual bool Reset()
        {
            m_CurrentLM = m_MinimaList;
            if ( m_CurrentLM == null ) return false; //ie nothing to process

            //reset all edges ...
            LocalMinima lm = m_MinimaList;
            while (lm != null)
            {
                TEdge4 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 true;
        }
Ejemplo n.º 5
0
 //------------------------------------------------------------------------------
 protected void PopLocalMinima()
 {
     if (m_CurrentLM == null) return;
     m_CurrentLM = m_CurrentLM.next;
 }
Ejemplo n.º 6
0
 //constructor (nb: no external instantiation)
 //------------------------------------------------------------------------------
 internal ClipperBase()
 {
     m_MinimaList = null;
     m_CurrentLM = null;
 }