protected virtual void Reset() { this.m_CurrentLM = this.m_MinimaList; if (this.m_CurrentLM == null) { return; } for (LocalMinima localMinima = this.m_MinimaList; localMinima != null; localMinima = localMinima.Next) { TEdge tEdge = localMinima.LeftBound; if (tEdge != null) { tEdge.Curr = tEdge.Bot; tEdge.Side = EdgeSide.esLeft; if (tEdge.OutIdx != -2) { tEdge.OutIdx = -1; } } tEdge = localMinima.RightBound; tEdge.Curr = tEdge.Bot; tEdge.Side = EdgeSide.esRight; if (tEdge.OutIdx != -2) { tEdge.OutIdx = -1; } } }
internal ClipperBase() { this.m_MinimaList = null; this.m_CurrentLM = null; this.m_UseFullRange = false; this.m_HasOpenPaths = false; }
protected void PopLocalMinima() { if (this.m_CurrentLM != null) { this.m_CurrentLM = this.m_CurrentLM.Next; } }
protected virtual void Reset() { this.m_CurrentLM = this.m_MinimaList; if (this.m_CurrentLM != null) { for (LocalMinima minima = this.m_MinimaList; minima != null; minima = minima.Next) { TEdge leftBound = minima.LeftBound; if (leftBound != null) { leftBound.Curr = leftBound.Bot; leftBound.Side = EdgeSide.esLeft; if (leftBound.OutIdx != -2) { leftBound.OutIdx = -1; } } leftBound = minima.RightBound; leftBound.Curr = leftBound.Bot; leftBound.Side = EdgeSide.esRight; if (leftBound.OutIdx != -2) { leftBound.OutIdx = -1; } } } }
private void DoMinimaLML(TEdge E1, TEdge E2, bool IsClosed) { if (E1 == null) { if (E2 != null) { LocalMinima newLm = new LocalMinima { Next = null, Y = E2.Bot.Y, LeftBound = null }; E2.WindDelta = 0; newLm.RightBound = E2; this.InsertLocalMinima(newLm); } } else { LocalMinima minima2 = new LocalMinima { Y = E1.Bot.Y, Next = null }; if (IsHorizontal(E2)) { if (E2.Bot.X != E1.Bot.X) { this.ReverseHorizontal(E2); } minima2.LeftBound = E1; minima2.RightBound = E2; } else if (E2.Dx < E1.Dx) { minima2.LeftBound = E1; minima2.RightBound = E2; } else { minima2.LeftBound = E2; minima2.RightBound = E1; } minima2.LeftBound.Side = EdgeSide.esLeft; minima2.RightBound.Side = EdgeSide.esRight; if (!IsClosed) { minima2.LeftBound.WindDelta = 0; } else if (minima2.LeftBound.Next == minima2.RightBound) { minima2.LeftBound.WindDelta = -1; } else { minima2.LeftBound.WindDelta = 1; } minima2.RightBound.WindDelta = -minima2.LeftBound.WindDelta; this.InsertLocalMinima(minima2); } }
protected void PopLocalMinima() { if (this.m_CurrentLM == null) { return; } this.m_CurrentLM = this.m_CurrentLM.Next; }
private void DoMinimaLML(TEdge E1, TEdge E2, bool IsClosed) { if (E1 == null) { if (E2 == null) { return; } LocalMinima localMinima = new LocalMinima(); localMinima.Next = null; localMinima.Y = E2.Bot.Y; localMinima.LeftBound = null; E2.WindDelta = 0; localMinima.RightBound = E2; this.InsertLocalMinima(localMinima); } else { LocalMinima localMinima2 = new LocalMinima(); localMinima2.Y = E1.Bot.Y; localMinima2.Next = null; if (ClipperBase.IsHorizontal(E2)) { if (E2.Bot.X != E1.Bot.X) { this.ReverseHorizontal(E2); } localMinima2.LeftBound = E1; localMinima2.RightBound = E2; } else if (E2.Dx < E1.Dx) { localMinima2.LeftBound = E1; localMinima2.RightBound = E2; } else { localMinima2.LeftBound = E2; localMinima2.RightBound = E1; } localMinima2.LeftBound.Side = EdgeSide.esLeft; localMinima2.RightBound.Side = EdgeSide.esRight; if (!IsClosed) { localMinima2.LeftBound.WindDelta = 0; } else if (localMinima2.LeftBound.Next == localMinima2.RightBound) { localMinima2.LeftBound.WindDelta = -1; } else { localMinima2.LeftBound.WindDelta = 1; } localMinima2.RightBound.WindDelta = -localMinima2.LeftBound.WindDelta; this.InsertLocalMinima(localMinima2); } }
private void DisposeLocalMinimaList() { while (this.m_MinimaList != null) { LocalMinima next = this.m_MinimaList.Next; this.m_MinimaList = null; this.m_MinimaList = next; } this.m_CurrentLM = null; }
private void InsertLocalMinima(LocalMinima newLm) { if (this.m_MinimaList == null) { this.m_MinimaList = newLm; } else if (newLm.Y >= this.m_MinimaList.Y) { newLm.Next = this.m_MinimaList; this.m_MinimaList = newLm; } else { LocalMinima localMinima = this.m_MinimaList; while (localMinima.Next != null && newLm.Y < localMinima.Next.Y) { localMinima = localMinima.Next; } newLm.Next = localMinima.Next; localMinima.Next = newLm; } }
private void InsertLocalMinima(LocalMinima newLm) { if (this.m_MinimaList == null) { this.m_MinimaList = newLm; } else if (newLm.Y >= this.m_MinimaList.Y) { newLm.Next = this.m_MinimaList; this.m_MinimaList = newLm; } else { LocalMinima minimaList = this.m_MinimaList; while ((minimaList.Next != null) && (newLm.Y < minimaList.Next.Y)) { minimaList = minimaList.Next; } newLm.Next = minimaList.Next; minimaList.Next = newLm; } }
//--------------------------------------------------------------------------- void DoMinimaLML(TEdge E1, TEdge E2, bool IsClosed) { if (E1 == null) { if (E2 == null) return; LocalMinima NewLm = new LocalMinima(); NewLm.Next = null; NewLm.Y = E2.Bot.Y; NewLm.LeftBound = null; E2.WindDelta = 0; NewLm.RightBound = E2; InsertLocalMinima(NewLm); } else { //E and E.Prev are now at a local minima ... LocalMinima NewLm = new LocalMinima(); NewLm.Y = E1.Bot.Y; NewLm.Next = null; if (IsHorizontal(E2)) //Horz. edges never start a Left bound { if (E2.Bot.X != E1.Bot.X) ReverseHorizontal(E2); NewLm.LeftBound = E1; NewLm.RightBound = E2; } else if (E2.Dx < E1.Dx) { NewLm.LeftBound = E1; NewLm.RightBound = E2; } else { NewLm.LeftBound = E2; NewLm.RightBound = E1; } NewLm.LeftBound.Side = EdgeSide.esLeft; NewLm.RightBound.Side = EdgeSide.esRight; //set the winding state of the first edge in each bound //(it'll be copied to subsequent edges in the bound) ... if (!IsClosed) NewLm.LeftBound.WindDelta = 0; else if (NewLm.LeftBound.Next == NewLm.RightBound) NewLm.LeftBound.WindDelta = -1; else NewLm.LeftBound.WindDelta = 1; NewLm.RightBound.WindDelta = -NewLm.LeftBound.WindDelta; InsertLocalMinima(NewLm); } }
//------------------------------------------------------------------------------ protected void PopLocalMinima() { if (m_CurrentLM == null) return; m_CurrentLM = m_CurrentLM.Next; }
//------------------------------------------------------------------------------ protected virtual void Reset() { m_CurrentLM = m_MinimaList; if (m_CurrentLM == null) return; //ie nothing to process //reset all edges ... LocalMinima lm = m_MinimaList; while (lm != null) { TEdge e = lm.LeftBound; if (e != null) { e.Curr = e.Bot; e.Side = EdgeSide.esLeft; if (e.OutIdx != Skip) e.OutIdx = Unassigned; } e = lm.RightBound; e.Curr = e.Bot; e.Side = EdgeSide.esRight; if (e.OutIdx != Skip) e.OutIdx = Unassigned; lm = lm.Next; } }
//------------------------------------------------------------------------------ internal ClipperBase() //constructor (nb: no external instantiation) { m_MinimaList = null; m_CurrentLM = null; m_UseFullRange = false; m_HasOpenPaths = false; }
public IntRect GetBounds() { IntRect result = default(IntRect); LocalMinima localMinima = this.m_MinimaList; if (localMinima == null) { return(result); } result.left = localMinima.LeftBound.Bot.X; result.top = localMinima.LeftBound.Bot.Y; result.right = localMinima.LeftBound.Bot.X; result.bottom = localMinima.LeftBound.Bot.Y; while (localMinima != null) { if (localMinima.LeftBound.Bot.Y > result.bottom) { result.bottom = localMinima.LeftBound.Bot.Y; } TEdge tEdge = localMinima.LeftBound; while (true) { TEdge tEdge2 = tEdge; while (tEdge.NextInLML != null) { if (tEdge.Bot.X < result.left) { result.left = tEdge.Bot.X; } if (tEdge.Bot.X > result.right) { result.right = tEdge.Bot.X; } tEdge = tEdge.NextInLML; } if (tEdge.Bot.X < result.left) { result.left = tEdge.Bot.X; } if (tEdge.Bot.X > result.right) { result.right = tEdge.Bot.X; } if (tEdge.Top.X < result.left) { result.left = tEdge.Top.X; } if (tEdge.Top.X > result.right) { result.right = tEdge.Top.X; } if (tEdge.Top.Y < result.top) { result.top = tEdge.Top.Y; } if (tEdge2 != localMinima.LeftBound) { break; } tEdge = localMinima.RightBound; } localMinima = localMinima.Next; } return(result); }
//------------------------------------------------------------------------------ private void DisposeLocalMinimaList() { while( m_MinimaList != null ) { LocalMinima tmpLm = m_MinimaList.Next; m_MinimaList = null; m_MinimaList = tmpLm; } m_CurrentLM = null; }
//------------------------------------------------------------------------------ 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; } }