Ejemplo n.º 1
0
        /// <summary>
        /// Return all voxels matching the given voxelselector delegate.
        /// </summary>
        /// <param name="VoxelSelector">A delegate selecting which voxels to return.</param>
        public IEnumerable <IVoxel <T> > Get(VoxelSelector <T> VoxelSelector)
        {
            #region Initial Checks

            if (VoxelSelector == null)
            {
                throw new ArgumentNullException("The given VoxelSelector must not be null!");
            }

            #endregion

            #region Check embedded voxels

            foreach (var _Voxel in EmbeddedVoxels)
            {
                if (VoxelSelector(_Voxel))
                {
                    yield return(_Voxel);
                }
            }

            #endregion

            #region Check subtrees

            if (Subtree1 != null)
            {
                foreach (var _Voxel in Subtree1.Get(VoxelSelector))
                {
                    yield return(_Voxel);
                }
            }

            if (Subtree2 != null)
            {
                foreach (var _Voxel in Subtree2.Get(VoxelSelector))
                {
                    yield return(_Voxel);
                }
            }

            if (Subtree3 != null)
            {
                foreach (var _Voxel in Subtree3.Get(VoxelSelector))
                {
                    yield return(_Voxel);
                }
            }

            if (Subtree4 != null)
            {
                foreach (var _Voxel in Subtree4.Get(VoxelSelector))
                {
                    yield return(_Voxel);
                }
            }

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return all voxels within the given cube.
        /// </summary>
        /// <param name="Cube">A cube selecting which voxels to return.</param>
        public IEnumerable <IVoxel <T> > Get(ICube <T> Cube)
        {
            #region Initial Checks

            if (Cube == null)
            {
                throw new ArgumentNullException("The given cube must not be null!");
            }

            #endregion

            #region Check embedded voxels

            foreach (var _Voxel in EmbeddedVoxels)
            {
                if (Cube.Contains(_Voxel))
                {
                    yield return(_Voxel);
                }
            }

            #endregion

            #region Check subtrees

            if (Subtree1 != null)
            {
                if (Subtree1.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree1.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree2 != null)
            {
                if (Subtree2.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree2.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree3 != null)
            {
                if (Subtree3.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree3.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree4 != null)
            {
                if (Subtree4.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree4.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree5 != null)
            {
                if (Subtree5.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree5.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree6 != null)
            {
                if (Subtree6.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree6.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree7 != null)
            {
                if (Subtree7.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree7.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            if (Subtree8 != null)
            {
                if (Subtree8.Overlaps(Cube))
                {
                    foreach (var _Voxel in Subtree8.Get(Cube))
                    {
                        yield return(_Voxel);
                    }
                }
            }

            #endregion
        }