//------------------------------------------------------------------------------ internal virtual void Reset() { m_CurrentLM = m_MinimaList; if (m_CurrentLM == null) { return; //ie nothing to process } //reset all edges ... m_Scanbeam = null; ClipperLocalMinima lm = m_MinimaList; while (lm != null) { InsertScanbeam(lm.Y); ClipperTEdge e = lm.LeftBound; if (e != null) { e.Curr = e.Bot; e.OutIdx = Unassigned; } e = lm.RightBound; if (e != null) { e.Curr = e.Bot; e.OutIdx = Unassigned; } lm = lm.Next; } m_ActiveEdges = null; }
//------------------------------------------------------------------------------ internal bool PopScanbeam(out long Y) { if (m_Scanbeam == null) { Y = 0; return(false); } Y = m_Scanbeam.Y; m_Scanbeam = m_Scanbeam.Next; return(true); }
//------------------------------------------------------------------------------ internal void InsertScanbeam(long Y) { //single-linked list: sorted descending, ignoring dups. if (m_Scanbeam == null) { m_Scanbeam = new ClipperScanbeam { Next = null, Y = Y }; } else if (Y > m_Scanbeam.Y) { ClipperScanbeam newSb = new ClipperScanbeam { Y = Y, Next = m_Scanbeam }; m_Scanbeam = newSb; } else { ClipperScanbeam sb2 = m_Scanbeam; while (sb2.Next != null && (Y <= sb2.Next.Y)) { sb2 = sb2.Next; } if (Y == sb2.Y) { return; //ie ignores duplicates } ClipperScanbeam newSb = new ClipperScanbeam { Y = Y, Next = sb2.Next }; sb2.Next = newSb; } }