Пример #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}");
            }
        }
Пример #2
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}");
                }
            }
        }