Ejemplo n.º 1
0
        public void Test_TerrainSwather_SwathExtentTooLarge()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var fence   = new Fence(new BoundingWorldExtent3D(0, 0, 10000, 2));
            var swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            CreateSwathContext(0, 0, 0,
                               10000, 0, 0,
                               0, 2, 0,
                               10000, 2, 0,
                               out SimpleTriangle HeightInterpolator1,
                               out SimpleTriangle HeightInterpolator2,
                               out SimpleTriangle TimeInterpolator1,
                               out SimpleTriangle TimeInterpolator2);

            bool swathResult = swather.PerformSwathing(HeightInterpolator1, HeightInterpolator2, TimeInterpolator1, TimeInterpolator2, false, PassType.Front, MachineSide.None);

            swathResult.Should().BeTrue();
            processor.ProcessedEpochCount.Should().Be(0);
            processor.ProcessedCellPassesCount.Should().Be(0);
        }
Ejemplo n.º 2
0
        public void Test_TerrainSwather_Creation()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var fence     = new Fence();
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            Assert.True(swather != null, "TerrainSwather not created as expected");
        }
Ejemplo n.º 3
0
        public void Test_TerrainSwather_PerformSwathing()
        {
            var siteModel = new SiteModel(StorageMutability.Immutable);
            var machine   = new VSS.TRex.Machines.Machine();
            var grid      = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var SiteModelGridAggregator             = new ServerSubGridTree(siteModel.ID, StorageMutability.Mutable);
            var MachineTargetValueChangesAggregator = new ProductionEventLists(siteModel, MachineConsts.kNullInternalSiteModelMachineIndex);
            var processor = new TAGProcessor(siteModel, machine, SiteModelGridAggregator, MachineTargetValueChangesAggregator);

            var fence = new Fence();

            fence.SetRectangleFence(0, 0, 10, 2);

            TerrainSwather swather = new TerrainSwather(processor, MachineTargetValueChangesAggregator, siteModel, grid, fence);

            CreateSwathContext(0, 0, 0,
                               10, 0, 0,
                               0, 2, 0,
                               10, 2, 0,
                               out SimpleTriangle HeightInterpolator1,
                               out SimpleTriangle HeightInterpolator2,
                               out SimpleTriangle TimeInterpolator1,
                               out SimpleTriangle TimeInterpolator2);

            // Compute swath with full cell pass on the front (blade) measurement location
            bool swathResult = swather.PerformSwathing(HeightInterpolator1, HeightInterpolator2, TimeInterpolator1, TimeInterpolator2, false, PassType.Front, MachineSide.None);

            // Did the swathing operation succeed?
            Assert.True(swathResult, "Perform swathing failed");

            // Did it produce the expected set of swathed cells?
            Assert.Equal(1, grid.Root.CountChildren());

            // Computation of the latest pass information which aids locating cells with non-null values
            try
            {
                IStorageProxy storageProxy = StorageProxy.Instance(StorageMutability.Mutable);
                grid.Root.ScanSubGrids(grid.FullCellExtent(), x =>
                {
                    ((IServerLeafSubGrid)x).ComputeLatestPassInformation(true, storageProxy);
                    return(true);
                });
            }
            catch (Exception E)
            {
                Assert.False(true, $"Exception {E} occured computing latest cell information");
            }

            grid.CalculateIndexOfCellContainingPosition(grid.CellSize / 2, grid.CellSize / 2, out int _, out int _);

            int nonNullCellCount = 0;

            try
            {
                grid.Root.ScanSubGrids(grid.FullCellExtent(), x =>
                {
                    nonNullCellCount += ((IServerLeafSubGrid)x).CountNonNullCells();
                    return(true);
                });
            }
            catch (Exception e)
            {
                Assert.False(true, $"Exception {e} occured counting non-null cells");
            }

            Assert.Equal(174, nonNullCellCount);

            // Todo: Iterate over the cells and confirm their content is as expected
        }