Пример #1
0
        /// <summary>
        /// performs scan loading on a thread, child method of load scan.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void loadScanThread(Object sender, DoWorkEventArgs e)
        {
            // Cast object back into BackgroundWorker

            BackgroundWorker B = (BackgroundWorker)sender;

            B.ReportProgress(1, "Background worker running");

            String filename = (string)e.Argument;

            if (filename != null)
            {
                B.ReportProgress(0, "Loading file: " + filename);

                ScanSerializer.deserialize(filename);

                System.Diagnostics.Debug.WriteLine(e.Argument);

                B.ReportProgress(8, "Model deserialised");

                pcdl = ScanSerializer.depthPc;

                System.Diagnostics.Debug.WriteLine(pcdl.Count);

                B.ReportProgress(2, "Model loaded");
            }

            if (pcdl.Count == 0)
            {
                throw new PointCloudException("PCDL is empty");
            }

            /*2)*/
            //instantiate the stitcher
            stitcher = new BoundingBox();
            B.ReportProgress(1);

            //jam points into stitcher
            stitcher.add(pcdl);
            B.ReportProgress(1);

            stitcher.stitch();
            B.ReportProgress(5);

            pcd  = stitcher.getResult();
            pcdl = stitcher.getResultList();
            B.ReportProgress(1, "Point Cloud Stitched (with " + pcdl.Count + " components)");
            if (pcdl.Count == 0)
            {
                throw new PointCloudException("Stitcher returned empty point cloud list");
            }

            // Get the height
            double height = Math.Round(HeightCalculator.getHeight(pcd), 3);

            Dispatcher.BeginInvoke((Action)(() => { int progress = 1; }));
            B.ReportProgress(1);
        }