public QuadTreeNodeEnum(Node Root) { _RootNode = Root; for (int n = 0; n < _NodeChain.Length; n++) { _NodeChain[n] = new QuadTreeNodeEnumState(); } Reset(); }
public QuadTreeNodeEnum_WithFilter(Node Root, Filter FilterOut) { _FilterOut = FilterOut; if (_FilterOut(Root)) { _RootNode = null; } else { _RootNode = Root; } for (int n = 0; n < _NodeChain.Length; n++) { _NodeChain[n] = new QuadTreeNodeEnumState(); } Reset(); }
public QuadTreeNodeEnum_Box(Node Root, long X, long Y, ulong Width, ulong Height) { _X = X; _Y = Y; if (Width > (ulong)long.MaxValue) { throw new Exception("Box query is too big"); } if (Height > (ulong)long.MaxValue) { throw new Exception("Box query is too big"); } _Width = (long)Width; _Height = (long)Height; _EndX = _X + (long)_Width; _EndY = _Y + (long)_Height; _RootNode = Root; for (int n = 0; n < _NodeChain.Length; n++) { _NodeChain[n] = new QuadTreeNodeEnumState(); } Reset(); }
public bool MoveNext() { // MoveNext is call first so we need a special case for the initialization if (_First) { _First = false; if (_RootNode != null) { return(true); } else { return(false); } } restart: QuadTreeNodeEnumState _Parent = _NodeChain[_NodeChainIndex]; if (_Parent._Node._0_0 != null && (_Parent._Included || Intersect(_Parent._Node))) { _Parent._SubdivisionIndex++; _NodeChainIndex++; _NodeChain[_NodeChainIndex]._SubdivisionIndex = 0; switch (_Parent._SubdivisionIndex) { case 1: _NodeChain[_NodeChainIndex]._Node = _Parent._Node._0_0; if (_Parent._Included) { _NodeChain[_NodeChainIndex]._Included = true; } else { _NodeChain[_NodeChainIndex]._Included = Included(_NodeChain[_NodeChainIndex]._Node); } return(true); case 2: _NodeChain[_NodeChainIndex]._Node = _Parent._Node._0_1; if (_Parent._Included) { _NodeChain[_NodeChainIndex]._Included = true; } else { _NodeChain[_NodeChainIndex]._Included = Included(_NodeChain[_NodeChainIndex]._Node); } return(true); case 3: _NodeChain[_NodeChainIndex]._Node = _Parent._Node._1_0; if (_Parent._Included) { _NodeChain[_NodeChainIndex]._Included = true; } else { _NodeChain[_NodeChainIndex]._Included = Included(_NodeChain[_NodeChainIndex]._Node); } return(true); case 4: _NodeChain[_NodeChainIndex]._Node = _Parent._Node._1_1; if (_Parent._Included) { _NodeChain[_NodeChainIndex]._Included = true; } else { _NodeChain[_NodeChainIndex]._Included = Included(_NodeChain[_NodeChainIndex]._Node); } return(true); default: if (_NodeChainIndex == 1) { return(false); } _NodeChainIndex -= 2; goto restart; } } else { if (_NodeChainIndex == 0) { return(false); } _NodeChainIndex -= 1; goto restart; } }