private static void CollectLeaf(
            PointRegionQuadTreeNodeLeaf<object> node, 
            double x, 
            double y, 
            double width,
            double height, 
            EventBean eventBean, 
            TT target, 
            QuadTreeCollector<TL, TT> collector)
        {
            var points = node.Points;
            if (points == null) return;
            if (points is XYPointWValue<TL> point)
            {
                if (BoundingBox.ContainsPoint(x, y, width, height, point.X, point.Y))
                    collector.CollectInto(eventBean, point.Value, target);
                return;
            }

            var collection = (ICollection<XYPointWValue<TL>>) points;
            foreach(var pointX in collection)
            {
                if (BoundingBox.ContainsPoint(x, y, width, height, pointX.X, pointX.Y))
                    collector.CollectInto(eventBean, pointX.Value, target);
            }
        }
        private static void CollectRange(
            PointRegionQuadTreeNode node,
            double x,
            double y,
            double width,
            double height,
            EventBean eventBean,
            TT target,
            QuadTreeCollector<TT> collector,
            ExprEvaluatorContext ctx)
        {
            if (!node.Bb.IntersectsBoxIncludingEnd(x, y, width, height)) {
                return;
            }

            if (node is PointRegionQuadTreeNodeLeaf<object>) {
                var leaf = (PointRegionQuadTreeNodeLeaf<object>) node;
                CollectLeaf(leaf, x, y, width, height, eventBean, target, collector, ctx);
                return;
            }

            var branch = (PointRegionQuadTreeNodeBranch) node;
            CollectRange(branch.Nw, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Ne, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Sw, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Se, x, y, width, height, eventBean, target, collector, ctx);
        }
 public static void CollectRange(
     MXCIFQuadTree <object> quadTree,
     double x, double y,
     double width, double height,
     EventBean eventBean, TT target,
     QuadTreeCollector <TL, TT> collector)
 {
     CollectRange(quadTree.Root, x, y, width, height, eventBean, target, collector);
 }
        private static void CollectLeaf(
            PointRegionQuadTreeNodeLeaf<object> node,
            double x,
            double y,
            double width,
            double height,
            EventBean eventBean,
            TT target,
            QuadTreeCollector<TT> collector,
            ExprEvaluatorContext ctx)
        {
            var points = node.Points;
            if (points == null) {
                return;
            }

            if (points is XYPointWValue<TL> pointWValueWithType) {
                if (BoundingBox.ContainsPoint(x, y, width, height, pointWValueWithType.X, pointWValueWithType.Y)) {
                    collector.CollectInto(eventBean, pointWValueWithType.Value, target, ctx);
                }

                return;
            }
            else if (points is XYPointWValue<object> pointWValueWithoutType) {
                if (BoundingBox.ContainsPoint(
                    x,
                    y,
                    width,
                    height,
                    pointWValueWithoutType.X,
                    pointWValueWithoutType.Y)) {
                    collector.CollectInto(eventBean, (TL) pointWValueWithoutType.Value, target, ctx);
                }

                return;
            }
            else if (points is IEnumerable<XYPointWValue<TL>> enumerableWithType) {
                foreach (var point in enumerableWithType) {
                    if (BoundingBox.ContainsPoint(x, y, width, height, point.X, point.Y)) {
                        collector.CollectInto(eventBean, point.Value, target, ctx);
                    }
                }
            }
            else if (points is IEnumerable<XYPointWValue<object>> enumerableWithoutType) {
                foreach (var point in enumerableWithoutType) {
                    if (BoundingBox.ContainsPoint(x, y, width, height, point.X, point.Y)) {
                        collector.CollectInto(eventBean, (TL) point.Value, target, ctx);
                    }
                }
            }
            else {
                throw new IllegalStateException("unknown type for points");
            }
        }
 public static void CollectRange(
     PointRegionQuadTree<object> quadTree,
     double x,
     double y,
     double width,
     double height,
     EventBean eventBean,
     TT target,
     QuadTreeCollector<TT> collector,
     ExprEvaluatorContext ctx)
 {
     CollectRange(quadTree.Root, x, y, width, height, eventBean, target, collector, ctx);
 }
        private static void CollectNode(
            MXCIFQuadTreeNode <object> node,
            double x, double y,
            double width, double height,
            EventBean eventBean, TT target,
            QuadTreeCollector <TL, TT> collector)
        {
            var rectangles = node.Data;

            if (rectangles == null)
            {
                return;
            }

            if (rectangles is XYWHRectangleWValue <TL> rectangleX)
            {
                if (BoundingBox.IntersectsBoxIncludingEnd(
                        x,
                        y,
                        x + width,
                        y + height,
                        rectangleX.X,
                        rectangleX.Y,
                        rectangleX.W,
                        rectangleX.H))
                {
                    collector.CollectInto(eventBean, rectangleX.Value, target);
                }

                return;
            }

            var collection = (ICollection <XYWHRectangleWValue <TL> >)rectangles;

            foreach (XYWHRectangleWValue <TL> rectangle in collection)
            {
                if (BoundingBox.IntersectsBoxIncludingEnd(
                        x, y, x + width, y + height,
                        rectangle.X,
                        rectangle.Y,
                        rectangle.W,
                        rectangle.H))
                {
                    collector.CollectInto(eventBean, rectangle.Value, target);
                }
            }
        }
        private static void CollectRange(
            MXCIFQuadTreeNode <object> node,
            double x, double y,
            double width, double height,
            EventBean eventBean, TT target,
            QuadTreeCollector <TL, TT> collector)
        {
            if (node is MXCIFQuadTreeNodeLeaf <object> leaf)
            {
                CollectNode(leaf, x, y, width, height, eventBean, target, collector);
                return;
            }

            var branch = (MXCIFQuadTreeNodeBranch <object>)node;

            CollectNode(branch, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Nw, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Ne, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Sw, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Se, x, y, width, height, eventBean, target, collector);
        }
        private static void CollectRange(
            PointRegionQuadTreeNode node, 
            double x, 
            double y, 
            double width,
            double height, 
            EventBean eventBean, 
            TT target, 
            QuadTreeCollector<TL, TT> collector)
        {
            if (!node.Bb.IntersectsBoxIncludingEnd(x, y, width, height)) return;
            if (node is PointRegionQuadTreeNodeLeaf<object> leaf)
            {
                CollectLeaf(leaf, x, y, width, height, eventBean, target, collector);
                return;
            }

            PointRegionQuadTreeNodeBranch branch = (PointRegionQuadTreeNodeBranch) node;
            CollectRange(branch.Nw, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Ne, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Sw, x, y, width, height, eventBean, target, collector);
            CollectRange(branch.Se, x, y, width, height, eventBean, target, collector);
        }
Example #9
0
        private static void CollectRange(
            MXCIFQuadTreeNode node,
            double x,
            double y,
            double width,
            double height,
            EventBean eventBean,
            TT target,
            QuadTreeCollector<TT> collector,
            ExprEvaluatorContext ctx)
        {
            if (node is MXCIFQuadTreeNodeLeaf leaf)
            {
                CollectNode(leaf, x, y, width, height, eventBean, target, collector, ctx);
                return;
            }

            MXCIFQuadTreeNodeBranch branch = (MXCIFQuadTreeNodeBranch) node;
            CollectNode(branch, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Nw, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Ne, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Sw, x, y, width, height, eventBean, target, collector, ctx);
            CollectRange(branch.Se, x, y, width, height, eventBean, target, collector, ctx);
        }
Example #10
0
        private static void CollectNode(
            MXCIFQuadTreeNode node,
            double x,
            double y,
            double width,
            double height,
            EventBean eventBean,
            TT target,
            QuadTreeCollector<TT> collector,
            ExprEvaluatorContext ctx)
        {
            object rectangles = node.Data;
            if (rectangles == null) {
                return;
            }

            if (rectangles is XYWHRectangleWValue rectangleWValue) {
                if (BoundingBox.IntersectsBoxIncludingEnd(
                    x,
                    y,
                    x + width,
                    y + height,
                    rectangleWValue.X,
                    rectangleWValue.Y,
                    rectangleWValue.W,
                    rectangleWValue.H)) {
                    collector.CollectInto(eventBean, rectangleWValue.Value, target, ctx);
                }
            }
            else if (rectangles is List<XYWHRectangleWValue> listWithType) {
                // Using the enumerable structure has some overhead when called a lot.  So, when
                // we know the value is a list (which it should be), then we attempt to use a
                // traditional loop to avoid the overhead.  Need to measure this against the time
                // cost for List.ForEach()

                var listWithTypeCount = listWithType.Count;
                for (var ii = 0; ii < listWithTypeCount; ii++) {
                    var rectangle = listWithType[ii];
                    if (BoundingBox.IntersectsBoxIncludingEnd(
                        x,
                        y,
                        x + width,
                        y + height,
                        rectangle.X,
                        rectangle.Y,
                        rectangle.W,
                        rectangle.H)) {
                        collector.CollectInto(eventBean, rectangle.Value, target, ctx);
                    }
                }
            }
            else if (rectangles is IEnumerable<XYWHRectangleWValue> enumerableWithType) {
                foreach (var rectangle in enumerableWithType) {
                    if (BoundingBox.IntersectsBoxIncludingEnd(
                        x,
                        y,
                        x + width,
                        y + height,
                        rectangle.X,
                        rectangle.Y,
                        rectangle.W,
                        rectangle.H)) {
                        collector.CollectInto(eventBean, rectangle.Value, target, ctx);
                    }
                }
            }
            else {
                throw new IllegalStateException("unknown type for rectangles");
            }
            }