Exemple #1
0
        public bool InsertPoint(QVector2D point, T pointData)
        {
            if (IsLeaf)
            {
                if (!region.ContainsPoint(point) || data.ContainsKey(point))
                {
                    return(false);
                }

                data.Add(point, pointData);
                if (data.Count == bucketSize && depth != maximumDepth)
                {
                    Subdivide();
                }
                return(true);
            }

            return(InsertInChild(point, pointData));
        }
        public bool InsertPoint(QVector2D point, T pointData)
        {
            if (IsLeaf)
            {
                if (!region.ContainsPoint(point) || data.ContainsKey(point))
                {
                    return(false);
                }

                data.Add(point, pointData);
                lastPointInserted = point;
                if (depth != maximumDepth && !subdividing)
                {
                    Subdivide();
                }
                return(true);
            }

            return(InsertInChild(point, pointData));
        }
Exemple #3
0
        public bool InsertPoint(QVector2D point, T pointData)
        {
            if (IsLeaf)
            {
                if (!region.ContainsPoint(point) || points.Contains(point))
                {
                    return(false);
                }

                if (!data.Equals(pointData) && depth != maximumDepth)
                {
                    subdivisionPoint     = point;
                    subdivisionPointData = pointData;
                    Subdivide();
                }
                else
                {
                    points.Add(point);
                }
                return(true);
            }

            return(InsertInChild(point, pointData));
        }
Exemple #4
0
 private T CalculateChildData(QRegion childRegion)
 {
     return((childRegion.ContainsPoint(subdivisionPoint)) ? subdivisionPointData : data);
 }