/// <summary> /// Computes a tight bounding extent around the elevation values stored in the sub grid tree /// </summary> private static BoundingWorldExtent3D DataStoreExtents(ISubGridTree dataStore) { var computedGridExtent = BoundingWorldExtent3D.Inverted(); dataStore.ScanAllSubGrids(subGrid => { var items = ((GenericLeafSubGrid <float>)subGrid).Items; SubGridUtilities.SubGridDimensionalIterator((x, y) => { var elev = items[x, y]; if (elev != Common.Consts.NullHeight) { computedGridExtent.Include(subGrid.OriginX + x, subGrid.OriginY + y, elev); } }); return(true); }); if (computedGridExtent.IsValidPlanExtent) { computedGridExtent.Offset(-SubGridTreeConsts.DefaultIndexOriginOffset, -SubGridTreeConsts.DefaultIndexOriginOffset); } // Convert the grid rectangle to a world rectangle, padding out the 3D bound by a small margin to avoid edge effects in calculations var computedWorldExtent = new BoundingWorldExtent3D ((computedGridExtent.MinX - 1.01) * dataStore.CellSize, (computedGridExtent.MinY - 1.01) * dataStore.CellSize, (computedGridExtent.MaxX + 1.01) * dataStore.CellSize, (computedGridExtent.MaxY + 1.01) * dataStore.CellSize, computedGridExtent.MinZ - 0.01, computedGridExtent.MaxZ + 0.01); return(computedWorldExtent); }
public void ProcessElevationInformationForSubGrid_DefinedBaseWithNullTopHeights() { const double cellSize = SubGridTreeConsts.DefaultCellSize; const double cellArea = cellSize * cellSize; var state = new ProgressiveVolumeAggregationState(cellSize); var baseHeights = NullHeights(); var topHeights = NullHeights(); TRex.SubGridTrees.Core.Utilities.SubGridUtilities.SubGridDimensionalIterator((x, y) => baseHeights[x, y] = 0.0f); state.ProcessElevationInformationForSubGrid(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, baseHeights, topHeights); state.Finalise(); state.CutFillVolume.CutVolume.Should().Be(0.0); state.CutFillVolume.FillVolume.Should().Be(0.0); state.CoverageArea.Should().Be(0.0 * cellArea); state.CutArea.Should().Be(0.0 * cellArea); state.FillArea.Should().Be(0.0 * cellArea); state.TotalArea.Should().Be(SubGridTreeConsts.CellsPerSubGrid * cellArea); state.BoundingExtents.Should().BeEquivalentTo(BoundingWorldExtent3D.Inverted()); }
public void SiteModelStatisticsExecutor_EmptySiteModel() { var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new ProjectStatisticsTRexRequest(siteModel.ID, null); request.Validate(); var executor = RequestExecutorContainer .Build <SiteModelStatisticsExecutor>(DIContext.Obtain <IConfigurationStore>(), DIContext.Obtain <ILoggerFactory>(), DIContext.Obtain <IServiceExceptionHandler>()); var result = executor.Process(request) as ProjectStatisticsResult; result.Code.Should().Be(ContractExecutionStatesEnum.ExecutedSuccessfully); result.cellSize.Should().Be(SubGridTreeConsts.DefaultCellSize); result.startTime.Should().Be(Consts.MAX_DATETIME_AS_UTC); result.endTime.Should().Be(Consts.MIN_DATETIME_AS_UTC); result.extents.MinX.Should().Be(BoundingWorldExtent3D.Inverted().MinX); result.extents.MaxX.Should().Be(BoundingWorldExtent3D.Inverted().MaxX); result.extents.MinY.Should().Be(BoundingWorldExtent3D.Inverted().MinY); result.extents.MaxY.Should().Be(BoundingWorldExtent3D.Inverted().MaxY); result.extents.MinZ.Should().Be(BoundingWorldExtent3D.Inverted().MinZ); result.extents.MaxZ.Should().Be(BoundingWorldExtent3D.Inverted().MaxZ); result.indexOriginOffset.Should().Be((int)SubGridTreeConsts.DefaultIndexOriginOffset); var expectedJson = "{\"startTime\":\"9999-12-31T23:59:59.9999999\",\"endTime\":\"0001-01-01T00:00:00\",\"cellSize\":0.34,\"indexOriginOffset\":536870912,\"extents\":{\"maxX\":-1E+100,\"maxY\":-1E+100,\"maxZ\":-1E+100,\"minX\":1E+100,\"minY\":1E+100,\"minZ\":1E+100},\"Code\":0,\"Message\":\"success\"}"; var json = JsonConvert.SerializeObject(result); json.Should().Be(expectedJson); }
public void Inverted() { var bound = BoundingWorldExtent3D.Inverted(); bound.MinX.Should().Be(1E100); bound.MinY.Should().Be(1E100); bound.MaxX.Should().Be(-1E100); bound.MaxY.Should().Be(-1E100); bound.MinZ.Should().Be(1E100); bound.MaxZ.Should().Be(-1E100); }
public bool GetHeightRange(out double MinZ, out double MaxZ) { var Bound = BoundingWorldExtent3D.Inverted(); for (int I = 0; I < Entities.Count; I++) { Bound.Include(Entities[I].GetStartPoint().Z); Bound.Include(Entities[I].GetEndPoint().Z); } MinZ = Bound.IsValidHeightExtent ? Bound.MinZ : Consts.NullDouble; MaxZ = Bound.IsValidHeightExtent ? Bound.MaxZ : Consts.NullDouble; return(Bound.IsValidHeightExtent); }
public void Include_BoundingRectangle() { var bound = BoundingWorldExtent3D.Inverted(); bound.Include(new BoundingWorldExtent3D(10, 10, 20, 20, 0, 0)); bound.Should().BeEquivalentTo(new BoundingWorldExtent3D(10, 10, 20, 20, 0, 0)); bound.Include(new BoundingWorldExtent3D(10, 10, 20, 20, 10, 20)); bound.Should().BeEquivalentTo(new BoundingWorldExtent3D(10, 10, 20, 20, 0, 20)); bound.Include(new BoundingWorldExtent3D(-100, -100, 200, 200, -10, 0)); bound.Should().BeEquivalentTo(new BoundingWorldExtent3D(-100, -100, 200, 200, -10, 20)); bound.Include(new BoundingWorldExtent3D(-1000, -1000, 2000, 2000, -20, 100), true); bound.Should().BeEquivalentTo(new BoundingWorldExtent3D(-1000, -1000, 2000, 2000, -10, 20)); }
public void Test_TileRenderRequestArgument() { var argument = new TileRenderRequestArgument { ProjectID = Guid.NewGuid(), Filters = new FilterSet(new CombinedFilter(), new CombinedFilter()), ReferenceDesign = new DesignOffset(Guid.NewGuid(), 1.5), Mode = DisplayMode.Height, CoordsAreGrid = true, PixelsX = 100, PixelsY = 200, Extents = BoundingWorldExtent3D.Inverted(), VolumeType = VolumeComputationType.BetweenDesignAndFilter }; SimpleBinarizableInstanceTester.TestClass(argument, "Custom TileRenderRequestArgument not same after round trip serialisation"); }
public void Test_RequestAnalyser_NullOrInvertedSpatialExtents_YieldsNoSubGrids() { var prodDataExistenceMap = new SubGridTreeSubGridExistenceBitMask(); var PipeLine = new SubGridPipelineProgressive <SubGridsRequestArgument, SubGridRequestsResponse>(null) { FilterSet = new FilterSet(new CombinedFilter()), ProdDataExistenceMap = prodDataExistenceMap, OverallExistenceMap = prodDataExistenceMap }; var analyser = new RequestAnalyser(PipeLine, BoundingWorldExtent3D.Null()); Assert.Equal(0, analyser.CountOfSubGridsThatWillBeSubmitted()); analyser = new RequestAnalyser(PipeLine, BoundingWorldExtent3D.Inverted()); Assert.Equal(0, analyser.CountOfSubGridsThatWillBeSubmitted()); }
public void Test_SimpleVolumesRequestArgument() { ICombinedFilter FromFilter = new CombinedFilter { AttributeFilter = new CellPassAttributeFilter { ReturnEarliestFilteredCellPass = true, HasElevationTypeFilter = true, ElevationType = ElevationType.First }, SpatialFilter = new CellSpatialFilter { CoordsAreGrid = true, IsSpatial = true, Fence = new Fence(BoundingWorldExtent3D.Inverted()) } }; CombinedFilter ToFilter = new CombinedFilter() { AttributeFilter = new CellPassAttributeFilter() { ReturnEarliestFilteredCellPass = false, HasElevationTypeFilter = true, ElevationType = ElevationType.Last }, SpatialFilter = FromFilter.SpatialFilter }; var argument = new SimpleVolumesRequestArgument() { ProjectID = Guid.NewGuid(), VolumeType = VolumeComputationType.Between2Filters, BaseFilter = FromFilter, TopFilter = ToFilter, BaseDesign = new DesignOffset(Guid.NewGuid(), 1.5), TopDesign = new DesignOffset(Guid.NewGuid(), -0.5), CutTolerance = CUT_TOLERANCE, FillTolerance = FILL_TOLERANCE }; SimpleBinarizableInstanceTester.TestClass(argument, "Custom SimpleVolumesRequestArgument not same after round trip serialisation"); }
public void ProcessElevationInformationForSubGrid_NullBaseAndTopHeights() { const double cellSize = SubGridTreeConsts.DefaultCellSize; const double cellArea = cellSize * cellSize; var state = new ProgressiveVolumeAggregationState(cellSize); state.ProcessElevationInformationForSubGrid(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, NullHeights(), NullHeights()); state.Finalise(); state.CutFillVolume.CutVolume.Should().Be(0.0); state.CutFillVolume.FillVolume.Should().Be(0.0); state.CoverageArea.Should().Be(0.0 * cellArea); state.CutArea.Should().Be(0.0 * cellArea); state.FillArea.Should().Be(0.0 * cellArea); state.TotalArea.Should().Be(SubGridTreeConsts.CellsPerSubGrid * cellArea); state.BoundingExtents.Should().BeEquivalentTo(BoundingWorldExtent3D.Inverted()); }
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); }
public void Test_SubGridTreeBitMask_ComputeCellsWorldExtents_EmptyMask() { var mask = new SubGridTreeBitMask(); mask.ComputeCellsWorldExtents().Should().BeEquivalentTo(BoundingWorldExtent3D.Inverted()); }