private void InvalidateParent() { GTree <Node, Edge, RectGeom <Node, Edge> > p = this.mOwner.Root; while (p != null && !p.GeomData.bBBoxDirty) { p.GeomData.bBBoxDirty = true; p = p.Root; } }
private void AddToTreeSize(int size) { this.mTreeSize += size; GTree <Node, Edge, Geom> p = this.mRoot; while (p != null) { p.mTreeSize += size; p = p.mRoot; } }
public void SetOwner(GTree <Node, Edge, RectGeom <Node, Edge> > owner) { if (owner == null) { throw new ArgumentNullException("owner"); } if (this.mOwner != owner) { if (owner.GeomData != this) { throw new ArgumentException( "Owner must have this instance as its GeomData", "owner"); } this.mOwner = owner; this.mLastBVers = owner.BranchVersion; this.bBBoxDirty = true; this.InvalidateParent(); } }
/*/// <summary> * /// A convenience field used to indicate that something about this * /// graph tree and/or one or more of its branches has been changed, * /// and data calculated based on that property and/or the properties * /// of its <see cref="Branches"/> needs to be recalculated. * /// </summary> * public bool Dirty;/* */ public GTree(int nIndex, Node nData, Edge eData, Geom gData, int branchCapacity) { if (branchCapacity < 0) { throw new ArgumentOutOfRangeException("capacity"); } this.NodeIndex = nIndex; this.NodeData = nData; this.EdgeData = eData; this.GeomData = gData; this.mRoot = null; this.mTreeSize = 1; this.mDepth = 0; this.mIndex = -1; this.mBranches = new GTree <Node, Edge, Geom> [branchCapacity]; this.mBCount = 0; this.mBVersion = 0; //this.Dirty = true; }
/// <summary> /// Sets the <see cref="Root"/> of this graph tree to the given /// <paramref name="root"/> value. If this graph tree's old root /// isn't null, this graph tree is removed from its /// <see cref="Branches"/> and it is invalidated. If the new /// <paramref name="root"/> is not null, this graph tree /// is then added to its <see cref="Branches"/> and it is then /// invalidated as well.</summary> /// <param name="root">The new <see cref="Root"/> /// of this graph tree.</param> public void SetRoot(GTree <Node, Edge, Geom> root) { if (this.mRoot != root) { GTree <Node, Edge, Geom> p; if (this.mRoot != null) { p = this.mRoot; Array.Copy(p.mBranches, this.mIndex + 1, p.mBranches, this.mIndex, p.mBCount - this.mIndex); p.mBCount--; for (int i = this.mIndex; i < p.mBCount; i++) { p.mBranches[i].mIndex--; } p.AddToTreeSize(-this.mTreeSize); this.mIndex = -1; //this.InvalidateParent(); while (p != null) { p.mBVersion++; p = p.mRoot; } } this.mRoot = root; if (this.mRoot != null) { p = this.mRoot; if (p.mBCount == p.mBranches.Length) { if (p.mBCount == 0) { p.mBranches = new GTree <Node, Edge, Geom> [4]; } else { GTree <Node, Edge, Geom>[] branches = new GTree <Node, Edge, Geom> [2 * p.mBCount]; Array.Copy(p.mBranches, 0, branches, 0, p.mBCount); p.mBranches = branches; } } p.AddToTreeSize(this.mTreeSize); this.SetDepth(p.mDepth + 1); this.mIndex = p.mBCount; p.mBranches[p.mBCount++] = this; //this.InvalidateParent(); while (p != null) { p.mBVersion++; p = p.mRoot; } } else { this.SetDepth(0); } } }