示例#1
0
        public static void ProfileAcrossTheGiantDesign()
        {
            TimeSpan bestTime = TimeSpan.MaxValue;

            Designs.TTM.Optimised.TrimbleTINModel readonly_tin = new Designs.TTM.Optimised.TrimbleTINModel();
            readonly_tin.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");

            TTMDesign design = new TTMDesign(0.34);

            design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");

            for (int i = 0; i < 10; i++)
            {
                DateTime _start = DateTime.Now;

                var profile = design.ComputeProfile(new[]
                {
                    new XYZ(design.Data.Header.MinimumEasting, design.Data.Header.MinimumNorthing, 0),
                    new XYZ(design.Data.Header.MaximumEasting, design.Data.Header.MaximumNorthing, 0)
                }, 0.34);

                var      profileDistance = MathUtilities.Hypot(profile.First().X - profile.Last().X, profile.First().Y - profile.Last().Y);
                DateTime _end            = DateTime.Now;

                if (_end - _start < bestTime)
                {
                    bestTime = _end - _start;
                    Console.WriteLine($"TIN profile (#{i}) with an {profileDistance:F3} meter line with {profile.Count} vertices in best time of {bestTime}");
                }
            }
        }
示例#2
0
 private void LoadTheDesign(string filePath = testFilePath, string fileName = testFileName)
 {
     lock (this)
     {
         if (design == null)
         {
             design = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
             design.LoadFromFile(Path.Combine(filePath, fileName));
         }
     }
 }
示例#3
0
 private void LoadTheGiantDesign()
 {
     lock (this)
     {
         if (design == null)
         {
             design = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
             design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");
         }
     }
 }
示例#4
0
        public static void ScanAllElevationsOverGiantDesign()
        {
            DateTime  _start = DateTime.Now;
            TTMDesign design = new TTMDesign(SubGridTreeConsts.DefaultCellSize);

            //design.LoadFromFile(@"C:\Temp\141020 Finish Surface.ttm"); // 0.5 Mb
            design.LoadFromFile(@"C:\Temp\161006 Stripped less PRB & AS.ttm"); //600Mb
            //design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm"); // 165Mb
            TimeSpan loadTime = DateTime.Now - _start;

            Console.WriteLine($"Perf Test: Duration for file load and index preparation = {loadTime}");

            TimeSpan bestTime = TimeSpan.MaxValue;

            var Patch = new float[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension];

            for (int i = 0; i < 100; i++)
            {
                int numPatches = 0;
                _start = DateTime.Now;

                design.NumTINProbeLookups     = 0;
                design.NumTINHeightRequests   = 0;
                design.NumNonNullProbeResults = 0;
                design.SpatialIndexOptimised.ScanAllSubGrids(leaf =>
                {
                    double cellSize = leaf.Owner.CellSize;
                    leaf.CalculateWorldOrigin(out double originX, out double originY);

                    leaf.ForEach((x, y) =>
                    {
                        if (design.InterpolateHeights(Patch, originX + x * cellSize, originY + y * cellSize, cellSize / SubGridTreeConsts.SubGridTreeDimension, 0))
                        {
                            numPatches++;
                        }
                    });

                    return(true);
                });

                TimeSpan lookupTime = DateTime.Now - _start;

                if (lookupTime < bestTime)
                {
                    bestTime = lookupTime;
                    Console.WriteLine($"Perf Test: Run {i}: Duration for {numPatches} lookups = {lookupTime}, probes = {design.NumTINProbeLookups}, Triangle evaluations = {design.NumTINHeightRequests}, non-null results = {design.NumNonNullProbeResults}");
                }
            }
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Get the site model ID
            if (!Guid.TryParse(txtSiteModelID.Text, out Guid ID))
            {
                MessageBox.Show(@"Invalid Site Model ID");
                return;
            }

            // Get the offset
            if (!double.TryParse(txtOffset.Text, out double offset))
            {
                MessageBox.Show(@"Invalid design offset");
                return;
            }

            // Invoke the service to add the surveyed surface
            try
            {
                // Load the file and extract its extents
                TTMDesign        TTM      = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
                string           fileName = Path.Combine(new [] { txtFilePath.Text, txtFileName.Text });
                DesignLoadResult result   = TTM.LoadFromFile(fileName);
                if (result != DesignLoadResult.Success)
                {
                    MessageBox.Show($@"Unable to load '{fileName}, with error = {result}");
                    return;
                }

                BoundingWorldExtent3D extents = new BoundingWorldExtent3D();
                TTM.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY);
                TTM.GetHeightRange(out extents.MinZ, out extents.MaxZ);

                ISurveyedSurface surveyedSurface =
                    surveyedSurfaceManager.Add(ID,
                                               new DesignDescriptor(Guid.NewGuid(), txtFilePath.Text, txtFileName.Text, offset),
                                               dateTimePicker.Value,
                                               extents);

                // Store the existence map for the surveyed surface for later use
                ExistenceMaps.SetExistenceMap(ID, VSS.TRex.ExistenceMaps.Interfaces.Consts.EXISTENCE_SURVEYED_SURFACE_DESCRIPTOR, surveyedSurface.ID, TTM.SubgridOverlayIndex());
            }
            catch (Exception E)
            {
                MessageBox.Show($@"Exception: {E}");
            }
        }
示例#6
0
        public void GlobalSetup()
        {
            DIBuilder.New()
            .AddLogging()
            .Add(x => x.AddSingleton <IConfigurationStore, GenericConfiguration>())
            .Add(x => x.AddSingleton <IOptimisedTTMProfilerFactory>(new OptimisedTTMProfilerFactory()))
            .Complete();

            design       = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
            readonly_tin = new TrimbleTINModel();

            readonly_tin.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");

            //design.LoadFromFile(@"C:\Temp\141020 Finish Surface.ttm"); // 0.5 Mb
            //design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm"); // 165Mb

            design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm");
        }
示例#7
0
        private void AddTheSurveyedSurfaceToSiteModel(Guid siteModelUid, Guid designUid, string localPath, string localFileName, DateTime surveyedUtc)
        {
            // Invoke the service to add the surveyed surface
            try
            {
                // Load the file and extract its extents
                var TTM = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
                TTM.LoadFromFile(Path.Combine(new[] { localPath, localFileName }));

                var extents = new BoundingWorldExtent3D();
                TTM.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY);
                TTM.GetHeightRange(out extents.MinZ, out extents.MaxZ);

                // TODO: Convert to requet per designs
                // Create the new design for the site model (note that SS and design types are different)
                var design = DIContext.Obtain <ISurveyedSurfaceManager>()
                             .Add(siteModelUid, new DesignDescriptor(designUid, string.Empty, localFileName), surveyedUtc, extents, TTM.SubGridOverlayIndex());
            }
            catch (Exception e)
            {
                throw new TRexException($"Exception writing surveyed surface to siteModel:", e);
            }
        }
示例#8
0
        private void btnAddAsNewDesign_Click(object sender, EventArgs e)
        {
            if (GetSiteModelID(out Guid SiteModelID))
            {
                // Get the offset
                if (!double.TryParse(txtOffset.Text, out double offset))
                {
                    MessageBox.Show(@"Invalid design offset");
                    return;
                }

                // Invoke the service to add the design
                try
                {
                    // Load the file and extract its extents
                    TTMDesign TTM = new TTMDesign(SubGridTreeConsts.DefaultCellSize);
                    TTM.LoadFromFile(Path.Combine(new[] { txtFilePath.Text, txtFileName.Text }));

                    BoundingWorldExtent3D extents = new BoundingWorldExtent3D();
                    TTM.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY);
                    TTM.GetHeightRange(out extents.MinZ, out extents.MaxZ);

                    // Create the new design for the site model
                    IDesign design = designManager.Add(SiteModelID,
                                                       new DesignDescriptor(Guid.NewGuid(), txtFilePath.Text, txtFileName.Text, offset),
                                                       extents);

                    // Store the existence map for the design for later use
                    ExistenceMaps.SetExistenceMap(SiteModelID, Consts.EXISTENCE_MAP_DESIGN_DESCRIPTOR, design.ID, TTM.SubgridOverlayIndex());
                }
                catch (Exception E)
                {
                    MessageBox.Show($@"Exception: {E}");
                }
            }
        }