Пример #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);
        }
Пример #2
0
        /// <summary>
        /// runs the volume calculation subroutine on an open point cloud/patient
        /// </summary>
        /// <param name="sender">the object</param>
        /// <param name="e">the routed event</param>

        private void VolumeOption_Click(object sender, RoutedEventArgs e)
        {
            //Static call to volume calculation method, pass persistent point cloud object

            if (windowHistory == null)
            {
                windowHistory       = new HistoryLoader();
                windowHistory.Owner = this;
                windowHistory.history.Visibility = Visibility.Collapsed;
                System.Diagnostics.Debug.WriteLine("History loader was null, now set.");
            }

            windowHistory.limbcircum.Visibility = Visibility.Collapsed;

            Tuple <List <List <Point3D> >, double> T = PlanePuller.pullAll(pcd);

            List <List <Point3D> > planes = T.Item1;
            double increment = T.Item2;

            volume = VolumeCalculator.volume1stApprox(planes, increment);
            volume = Math.Round(volume, 4);

            List <double> areaList = AreaCalculator.getAllAreas(planes);

            windowHistory.areaList = areaList;

            windowHistory.runtimeTab.SelectedIndex = 0;
            windowHistory.visualisePlanes(planes, 1);
            windowHistory.voloutput.Content    = volume + "m\u00B3";
            windowHistory.heightoutput.Content = HeightCalculator.getHeight(pcd) + "m";
            windowHistory.scantime.Content     = "Weight (Est): " + VolumeCalculator.calculateApproxWeight(volume) + "kg";
            windowHistory.scanfileref.Content  = "BMI Measure: " + VolumeCalculator.calculateBMI(HeightCalculator.getHeight(pcd), VolumeCalculator.calculateApproxWeight(volume));
            windowHistory.scanvoxel.Content    = "Siri (%BF): " + VolumeCalculator.calculateSiri(volume, VolumeCalculator.calculateApproxWeight(volume), HeightCalculator.getHeight(pcd)) + "%";

            //show Runtime viewer (aka results,history)

            windowHistory.Show();

            List <Tuple <DateTime, double> > records = this.getTimeStampsAndVals((int)Convert.ToInt64(windowPatient.patientIDExisting.Content));

            int historyLookBack = 5;

            if ((records != null) && (records.Count > 0))
            {
                int size = Math.Min(records.Count, historyLookBack);

                KeyValuePair <DateTime, double>[] records2 = new KeyValuePair <DateTime, double> [size];

                for (int i = 0; i < size; i++)
                {
                    records2[i] = new KeyValuePair <DateTime, double>(records[i].Item1, records[i].Item2);
                }

                //set change in volume... may need refinement
                if (size != 0)
                {
                    double change = 0;
                    change = (volume - records[records.Count - 1].Item2) / records[records.Count - 1].Item2;//may need to become records[records.Count-2].Item2 later
                    windowHistory.volchangeoutput.Content = Math.Round(100 * change, 2) + "%";
                }
                else
                {
                    windowHistory.volchangeoutput.Content = "Not Enough Data";
                    windowHistory.volchart.Visibility     = Visibility.Collapsed;
                }
                //setData
                ((LineSeries)(windowHistory.volchart.Series[0])).ItemsSource = records2;
            }
            else
            {
                windowHistory.volchangeoutput.Content = "Not Enough Data";
                windowHistory.volchart.Visibility     = Visibility.Collapsed;
            }
        }