Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
 /// <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);
 }
Пример #5
0
 public override void Add(ISpatialQueryable item)
 {
     currentItem = item;
     ContainerTraverser.Traverse(item, traverser);
     currentItem = null;
 }