/// <summary> /// Computes the axis aligned bounding box that exactly contains the bounds of all child node. /// </summary> /// <remarks> /// Any desendant that implements <see cref="ISpatialQueryable"/> will be included in the final bounding box. /// </remarks> public BoundingBox ComputeBounds() { var hasBoundable = false; var bounds = new BoundingBox(); ContainerTraverser.Traverse <ISpatialQueryable>(this, boundable => { if (hasBoundable) { var childBounds = boundable.BoundingBox; BoundingBox.CreateMerged(ref bounds, ref childBounds, out bounds); } else { bounds = boundable.BoundingBox; hasBoundable = true; } return(TraverseOptions.Continue); }); return(bounds); }
/// <summary> /// Performs a depth first search and finds the first descendant object with the specified name. /// </summary> public T FindName <T>(string name) where T : class { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name"); } T result = null; ContainerTraverser.Traverse <Object>(this, desendant => { result = desendant as T; if (result != null) { if (desendant.name == name) { return(TraverseOptions.Stop); } result = null; } return(TraverseOptions.Continue); }); return(result); }
/// <summary> /// Finds all the child objects of the target including the input target. /// </summary> public void Traverse <T>(Func <T, TraverseOptions> result) where T : class { ContainerTraverser.Traverse(this, result); }
/// <summary> /// Finds all the child objects of the target including the input target. /// </summary> public void Traverse <T>(ICollection <T> result) where T : class { ContainerTraverser.Traverse(this, result); }
public override void Add(ISpatialQueryable item) { currentItem = item; ContainerTraverser.Traverse(item, traverser); currentItem = null; }