Exemplo n.º 1
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}");
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
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}");
                }
            }
        }