Beispiel #1
0
        /// <summary>
        /// Split this leaf node by creating left and right children, then moving all the children of
        /// this node into the respective buckets.
        /// </summary>
        private void SplitLeafNode()
        {
            // Create the new children.
            pRight = new KDNode(iBucketCapacity);
            pLeft  = new KDNode(iBucketCapacity);

            // Move each item in this leaf into the children.
            for (int i = 0; i < Size; ++i)
            {
                // Store.
                Vector3d tOldPoint = tPoints[i];
                Point3D  kOldData  = tData[i];

                // If larger, put it in the right.
                if (tOldPoint[iSplitDimension] > fSplitValue)
                {
                    pRight.AddLeafPoint(tOldPoint, kOldData);
                }

                // If smaller, put it in the left.
                else
                {
                    pLeft.AddLeafPoint(tOldPoint, kOldData);
                }
            }

            // Wipe the data from this KDNode.
            tPoints = null;
            tData   = null;
        }
Beispiel #2
0
        /// <summary>
        /// Insert a new point into this leaf node.
        /// </summary>
        /// <param name="tPoint">The position which represents the data.</param>
        /// <param name="kValue">The value of the data.</param>
        public void AddPoint(Point3D kValue)
        {
            Vector3d tPoint = kValue.Position;
            // Find the correct leaf node.
            KDNode pCursor = this;

            while (!pCursor.IsLeaf)
            {
                // Extend the size of the leaf.
                pCursor.ExtendBounds(tPoint);
                pCursor.Size++;

                // If it is larger select the right, or lower,  select the left.
                if (tPoint[pCursor.iSplitDimension] > pCursor.fSplitValue)
                {
                    pCursor = pCursor.pRight;
                }
                else
                {
                    pCursor = pCursor.pLeft;
                }
            }

            // Insert it into the leaf.
            pCursor.AddLeafPoint(tPoint, kValue);
        }
Beispiel #3
0
		/// <summary> 
		/// Split this leaf node by creating left and right children, then moving all the children of 
		/// this node into the respective buckets. 
		/// </summary> 
		private void SplitLeafNode()
		{
			// Create the new children. 
			pRight = new KDNode(iBucketCapacity);
			pLeft = new KDNode(iBucketCapacity);

			// Move each item in this leaf into the children. 
			for (int i = 0; i < Size; ++i)
			{
				// Store. 
				Vector3d tOldPoint = tPoints[i];
				Point3D kOldData = tData[i];

				// If larger, put it in the right. 
				if (tOldPoint[iSplitDimension] > fSplitValue)
					pRight.AddLeafPoint(tOldPoint, kOldData);

				// If smaller, put it in the left. 
				else
					pLeft.AddLeafPoint(tOldPoint, kOldData);
			}

			// Wipe the data from this KDNode. 
			tPoints = null;
			tData = null;
		}