Ejemplo n.º 1
0
        public BoundingBox3D CalculateBoundingBox3D()
        {
            var bboxes = NodeRecursive.GetBoundingBoxes3D(this);
            var bbox   = BoundingBoxCalculator.GetBoundingBox(bboxes);

            return(bbox);
        }
Ejemplo n.º 2
0
        public static Node ConstructTree(List <BoundingBox3D> zupboxes)
        {
            // select min and max from zupboxes for x and y
            var bbox3d = BoundingBoxCalculator.GetBoundingBox(zupboxes);
            var bbox   = bbox3d.ToBoundingBox();

            double maxTileSize     = 2000.0;
            var    featuresPerTile = 50;

            var xrange = (int)Math.Ceiling(bbox3d.ExtentX() / maxTileSize);
            var yrange = (int)Math.Ceiling(bbox3d.ExtentY() / maxTileSize);

            var tree = new Node();

            for (var x = 0; x < xrange; x++)
            {
                for (var y = 0; y < yrange; y++)
                {
                    var tileextent = B3dmTile.GetExtent(bbox, maxTileSize, x, y);
                    var features   = new List <Feature>();

                    // loop through all zupboxes
                    for (var t = 0; t < zupboxes.Count; t++)
                    {
                        var isinside = tileextent.Inside(zupboxes[t].GetCenter());
                        if (isinside)
                        {
                            var f = new Feature()
                            {
                                Id = t, BoundingBox3D = zupboxes[t]
                            };
                            features.Add(f);
                        }
                    }

                    if (features.Count == 0)
                    {
                        continue;
                    }
                    var node = new Node();
                    if (features.Count > featuresPerTile)
                    {
                        node.Features = features.Take(featuresPerTile).ToList();
                        var new_features    = features.GetRange(featuresPerTile, features.Count - featuresPerTile).ToList();
                        var new_x           = x * 2;
                        var new_y           = y * 2;
                        var new_maxTileSize = maxTileSize / 2;
                        Divide(tileextent, new_features, new_x, new_y, new_maxTileSize, featuresPerTile, node);
                    }
                    else
                    {
                        node.Features = features;
                    }
                    tree.Children.Add(node);
                }
            }
            return(tree);
        }