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}"); } } }
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)); } } }
private void LoadTheGiantDesign() { lock (this) { if (design == null) { design = new TTMDesign(SubGridTreeConsts.DefaultCellSize); design.LoadFromFile(@"C:\Users\rwilson\Downloads\5644616_oba9c0bd14_FRL.ttm"); } } }
public void TTMDesignTest() { try { TTMDesign localDesign = new TTMDesign(SubGridTreeConsts.DefaultCellSize); Assert.NotNull(localDesign); } catch (Exception) { Assert.False(true); } }
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}"); } } }
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}"); } }
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"); }
public IDesignBase NewInstance(Guid designUid, string fileName, double cellSize, Guid siteModelUid) { IDesignBase result; if (string.Compare(Path.GetExtension(fileName), ".ttm", StringComparison.InvariantCultureIgnoreCase) == 0) { result = new TTMDesign(cellSize); } else if (string.Compare(Path.GetExtension(fileName), ".svl", StringComparison.InvariantCultureIgnoreCase) == 0) { result = new SVLAlignmentDesign(); } else { throw new TRexException($"Unknown design file type in design class factory for design {fileName}"); } result.DesignUid = designUid; result.FileName = fileName; result.ProjectUid = siteModelUid; return(result); }
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); } }
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}"); } } }
public void GlobalCleanup() { DIBuilder.Eject(); design = null; readonly_tin = null; }
/// <summary> /// Add a design or surveyed surface or alignment file to TRex /// </summary> protected async Task AddDesign(DesignRequest request, string executorName) { // load core file from s3 to local var localPath = FilePathHelper.GetTempFolderForProject(request.ProjectUid); var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName }); DesignBase design; if (request.FileType == ImportedFileType.Alignment) { design = new SVLAlignmentDesign(); } else { design = new TTMDesign(SubGridTreeConsts.DefaultCellSize); } var designLoadResult = design.LoadFromStorage(request.ProjectUid, request.FileName, localPath); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToRetrieveFromS3, designLoadResult.ToString()); } if (request.FileType != ImportedFileType.Alignment) { // This generates the 2 index files designLoadResult = design.LoadFromFile(localPathAndFileName); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToCreateDesign, designLoadResult.ToString()); } } var extents = new BoundingWorldExtent3D(); design.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY); design.GetHeightRange(out extents.MinZ, out extents.MaxZ); if (request.FileType == ImportedFileType.DesignSurface) { // Create the new designSurface in our site var tRexRequest = new AddTTMDesignRequest(); var designSurfaceUid = await tRexRequest.ExecuteAsync(new AddTTMDesignArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.SurveyedSurface) { // Create the new SurveyedSurface in our site model var tRexRequest = new AddSurveyedSurfaceRequest(); var surveyedSurfaceUid = await tRexRequest.ExecuteAsync(new AddSurveyedSurfaceArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), AsAtDate = request.SurveyedUtc ?? TRex.Common.Consts.MIN_DATETIME_AS_UTC, // validation will have ensured this exists Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.Alignment) { // Create the new alignment in our site model var tRexRequest = new AddAlignmentRequest(); var alignmentUid = await tRexRequest.ExecuteAsync(new AddAlignmentArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents }); } if (request.FileType != ImportedFileType.Alignment) { // TTM.LoadFromFile() will have created these 3 files. We need to store them on S3 to reload cache when required var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SubGridIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SpatialIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, BoundaryFileName(request.FileName)); } }