Beispiel #1
0
 public bool isOverlapWith(Cube cube)
 {
     if (isInside(cube) || Contains(cube) ||
         Contains(cube.left, cube.top, cube.rear) ||
         Contains(cube.right, cube.top, cube.rear) ||
         Contains(cube.left, cube.down, cube.rear) ||
         Contains(cube.right, cube.down, cube.rear) ||
         Contains(cube.left, cube.top, cube.front) ||
         Contains(cube.right, cube.top, cube.front) ||
         Contains(cube.left, cube.down, cube.front) ||
         Contains(cube.right, cube.down, cube.front))
     {
         return true;
     }
     return false;
 }
Beispiel #2
0
        public bool isInside(Cube cube)
        {
            if (cube.Contains(new Cube(offset, 1,1,1)))
                return true;

            return false;
        }
Beispiel #3
0
 public bool Contains(Cube cube)
 {
     if (left <= cube.left && right >= cube.right &&
         down <= cube.down && top >= cube.top &&
         rear <= cube.rear && front >= cube.front)
     {
         return true;
     }
     return false;
 }
Beispiel #4
0
        /// <summary>
        /// Query the Octa-Tree for items that are in the given area
        /// </summary>
        /// <param name="queryArea"></pasram>
        /// <returns></returns>
        public List<IOctTreeElement> Query(Cube queryVolume)
        {
            // create a list of the items that are found
            List<IOctTreeElement> results = new List<IOctTreeElement>();

            // this quad contains items that are not entirely contained by
            // it's four sub-quads. Iterate through the items in this quad
            // to see if they intersect.
            foreach (IOctTreeElement item in this.Items)
            {
                if (item.isOverlapWith(queryVolume))
                    results.Add(item);
            }

            foreach (OctTreeNode node in childNode)
            {
                //if (node.IsEmpty)
                //    continue;

                // Case 1: search area completely contained by sub-quad
                // if a node completely contains the query area, go down that branch
                // and skip the remaining nodes (break this loop)
                if (node.Contains(queryVolume))
                {
                    results.AddRange(node.Query(queryVolume));
                    break;
                }

                // Case 2: Sub-quad completely contained by search area
                // if the query area completely contains a sub-quad,
                // just add all the contents of that quad and it's children
                // to the result set. You need to continue the loop to test
                // the other quads
                if (queryVolume.Contains(node))
                {
                    results.AddRange(node.AllItems);
                    continue;
                }

                // Case 3: search area overlap with sub-octa
                // traverse into this octa-node, continue the loop to search other
                // octa-node
                if (node.isOverlapWith(queryVolume))
                {
                    results.AddRange(node.Query(queryVolume));
                }
            }
            return results;
        }
Beispiel #5
0
        public bool isInside(Cube cube)
        {
            if (cube.Contains(this))
                return true;

            return false;
        }
Beispiel #6
0
 /// <summary>
 /// Query the QuadTree, returning the items that are in the given area
 /// </summary>
 /// <param name="area"></param>
 /// <returns></returns>
 public List<IOctTreeElement> Query(Cube queryVolume)
 {
     return root.Query(queryVolume);
 }