private ChunkedLodTreeNode[] GetLeafs(Bounds2D bounds, ChunkedLodTreeNode parent, int depth)
        {
            if (depth == 0)
            {
                return new ChunkedLodTreeNode[0];
            }

            var min = bounds.Min;
            var max = bounds.Max;
            var center = bounds.Center;

            var first = new Bounds2D(min, new Vector2d(center.X, center.Y));
            var second = new Bounds2D(new Vector2d(center.X, min.Y), new Vector2d(max.X, center.Y));
            var third = new Bounds2D(new Vector2d(min.X, center.Y), new Vector2d(center.X, max.Y));
            var fourth = new Bounds2D(new Vector2d(center.X, center.Y), max);
            var nextDepth = depth - 1;
            var geometricError = CalculateGeometricError(depth - 1);
            return new[]
            {
                CreateChunkedLodTreeNode(first, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(second, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(third, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(fourth, parent, nextDepth, geometricError)
            };
        }
        private ChunkedLodTreeNode[] GetLeafs(Bounds2D bounds, ChunkedLodTreeNode parent, int depth)
        {
            if (depth == 0)
            {
                return(new ChunkedLodTreeNode[0]);
            }

            var min    = bounds.Min;
            var max    = bounds.Max;
            var center = bounds.Center;

            var first          = new Bounds2D(min, new Vector2d(center.X, center.Y));
            var second         = new Bounds2D(new Vector2d(center.X, min.Y), new Vector2d(max.X, center.Y));
            var third          = new Bounds2D(new Vector2d(min.X, center.Y), new Vector2d(center.X, max.Y));
            var fourth         = new Bounds2D(new Vector2d(center.X, center.Y), max);
            var nextDepth      = depth - 1;
            var geometricError = CalculateGeometricError(depth - 1);

            return(new[]
            {
                CreateChunkedLodTreeNode(first, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(second, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(third, parent, nextDepth, geometricError),
                CreateChunkedLodTreeNode(fourth, parent, nextDepth, geometricError)
            });
        }
        private ChunkedLodTreeNode CreateChunkedLodTreeNode(Bounds2D first, ChunkedLodTreeNode parent, int nextDepth, double geometricError)
        {
            var chunkedLodTreeNode = new ChunkedLodTreeNode(first, parent, geometricError);

            chunkedLodTreeNode.SetNodes(GetLeafs(first, chunkedLodTreeNode, nextDepth));
            return(chunkedLodTreeNode);
        }
 public ChunkedLodTreeNode(Bounds2D bounds, ChunkedLodTreeNode parent, double geometricError)
 {
     Bounds = bounds;
     Parent = parent;
     Nodes = new ChunkedLodTreeNode[0];
     GeometricError = geometricError;
     if (Parent == null)
     {
         Level = 0;
     }
     else
     {
         Level = parent.Level + 1;
     }
 }
 public ChunkedLodTreeNode(Bounds2D bounds, ChunkedLodTreeNode parent, double geometricError)
 {
     Bounds         = bounds;
     Parent         = parent;
     Nodes          = new ChunkedLodTreeNode[0];
     GeometricError = geometricError;
     if (Parent == null)
     {
         Level = 0;
     }
     else
     {
         Level = parent.Level + 1;
     }
 }
 private ChunkedLodTreeNode CreateChunkedLodTreeNode(Bounds2D first, ChunkedLodTreeNode parent, int nextDepth, double geometricError)
 {
     var chunkedLodTreeNode = new ChunkedLodTreeNode(first, parent, geometricError);
     chunkedLodTreeNode.SetNodes(GetLeafs(first, chunkedLodTreeNode, nextDepth));
     return chunkedLodTreeNode;
 }
 public void SetNodes(ChunkedLodTreeNode[] nodes)
 {
     Nodes = nodes;
 }