//------------------------------------------------------------------------------ private void DisposeIntersectNodes() { while ( m_IntersectNodes != null ) { IntersectNode iNode = m_IntersectNodes.next; m_IntersectNodes = null; m_IntersectNodes = iNode; } }
//------------------------------------------------------------------------------ private void AddIntersectNode(TEdge4 e1, TEdge4 e2, IntPoint pt) { IntersectNode newNode = new IntersectNode(); newNode.edge1 = e1; newNode.edge2 = e2; newNode.pt = pt; newNode.next = null; if (m_IntersectNodes == null) m_IntersectNodes = newNode; else if( Process1Before2(newNode, m_IntersectNodes) ) { newNode.next = m_IntersectNodes; m_IntersectNodes = newNode; } else { IntersectNode iNode = m_IntersectNodes; while( iNode.next != null && Process1Before2(iNode.next, newNode) ) iNode = iNode.next; newNode.next = iNode.next; iNode.next = newNode; } }
//------------------------------------------------------------------------------ private void SwapIntersectNodes(IntersectNode int1, IntersectNode int2) { TEdge4 e1 = int1.edge1; TEdge4 e2 = int1.edge2; IntPoint p = int1.pt; int1.edge1 = int2.edge1; int1.edge2 = int2.edge2; int1.pt = int2.pt; int2.edge1 = e1; int2.edge2 = e2; int2.pt = p; }
//------------------------------------------------------------------------------ private void ProcessIntersectList() { while( m_IntersectNodes != null ) { IntersectNode iNode = m_IntersectNodes.next; { IntersectEdges( m_IntersectNodes.edge1 , m_IntersectNodes.edge2 , m_IntersectNodes.pt, Protects.ipBoth ); SwapPositionsInAEL( m_IntersectNodes.edge1 , m_IntersectNodes.edge2 ); } m_IntersectNodes = null; m_IntersectNodes = iNode; } }
//------------------------------------------------------------------------------ private bool Process1Before2(IntersectNode node1, IntersectNode node2) { bool result; if (node1.pt.Y == node2.pt.Y) { if (node1.edge1 == node2.edge1 || node1.edge2 == node2.edge1) { result = node2.pt.X > node1.pt.X; if (node2.edge1.dx > 0) return result; else return !result; } else if (node1.edge1 == node2.edge2 || node1.edge2 == node2.edge2) { result = node2.pt.X > node1.pt.X; if (node2.edge2.dx > 0) return result; else return !result; } else return node2.pt.X > node1.pt.X; } else return node1.pt.Y > node2.pt.Y; }
public Clipper() { m_Scanbeam = null; m_ActiveEdges = null; m_SortedEdges = null; m_IntersectNodes = null; m_ExecuteLocked = false; m_PolyPts = new List<PolyPt>(); m_Joins = new List<JoinRec>(); m_HorizJoins = new List<HorzJoinRec>(); }