Exemple #1
0
        public void Offset()
        {
            var bound = new BoundingWorldExtent3D(0, 0, 100, 100, 0, 0);

            bound.Offset(1, 1);

            bound.MinX.Should().Be(1);
            bound.MinY.Should().Be(1);
            bound.MaxX.Should().Be(101);
            bound.MaxY.Should().Be(101);
            bound.MinZ.Should().Be(0);
            bound.MaxZ.Should().Be(0);

            bound.Offset(1);
            bound.MinZ.Should().Be(1);
            bound.MaxZ.Should().Be(1);

            bound.Offset(-1, -1);

            bound.MinX.Should().Be(0);
            bound.MinY.Should().Be(0);
            bound.MaxX.Should().Be(100);
            bound.MaxY.Should().Be(100);
            bound.MinZ.Should().Be(1);
            bound.MaxZ.Should().Be(1);

            bound.Offset(-1);
            bound.MinZ.Should().Be(0);
            bound.MaxZ.Should().Be(0);
        }
Exemple #2
0
        private BoundingWorldExtent3D DataStoreExtents(DecimationElevationSubGridTree dataStore)
        {
            BoundingWorldExtent3D ComputedGridExtent = BoundingWorldExtent3D.Inverted();

            dataStore.ScanAllSubGrids(subGrid =>
            {
                SubGridUtilities.SubGridDimensionalIterator((x, y) =>
                {
                    float elev = ((GenericLeafSubGrid <float>)subGrid).Items[x, y];
                    if (elev != 0)
                    {
                        ComputedGridExtent.Include((int)(subGrid.OriginX + x), (int)(subGrid.OriginY + y), elev);
                    }
                    else
                    {
                        ((GenericLeafSubGrid <float>)subGrid).Items[x, y] = TRex.Common.Consts.NullHeight;
                    }
                });

                return(true);
            });

            if (ComputedGridExtent.IsValidPlanExtent)
            {
                ComputedGridExtent.Offset(-(int)SubGridTreeConsts.DefaultIndexOriginOffset, -(int)SubGridTreeConsts.DefaultIndexOriginOffset);
            }

            // Convert the grid rectangle to a world rectangle
            BoundingWorldExtent3D ComputedWorldExtent = new BoundingWorldExtent3D
                                                            ((ComputedGridExtent.MinX - 0.01) * dataStore.CellSize,
                                                            (ComputedGridExtent.MinY - 0.01) * dataStore.CellSize,
                                                            (ComputedGridExtent.MaxX + 1 + 0.01) * dataStore.CellSize,
                                                            (ComputedGridExtent.MaxY + 1 + 0.01) * dataStore.CellSize,
                                                            ComputedGridExtent.MinZ, ComputedGridExtent.MaxZ);

            return(ComputedWorldExtent);
        }