/// <summary> /// calculates volume, only works on an amorphus blob. Returns a double in real world space. /// </summary> /// <param name="planes">List(List(Point3D))</param> /// <param name="increment">double</param> /// <returns>double</returns> public static double volume1stApprox(List <List <Point3D> > planes, double increment) { double volume = 0; for (int i = 0; i < planes.Count; i++) { List <Point3D> plane = planes[i]; if (plane.Count != 0) { plane.Add(plane[0]); //a list eating its own head, steve matthews would be proud double area = 0; area = AreaCalculator.calculateArea(plane); volume = volume + (area * increment); } else { Console.WriteLine("Plane EMPTY!!! BAD THINGS WILL HAPPEN"); } } volume = UnitConvertor.convertPCM(volume, 3); return(volume); }
/// <summary> /// returns one area for every plane fed. returns real world areas not point cloud areas /// </summary> /// <param name="planes">List(List(Point3D))</param> /// <returns>List(double)</returns> public static List <double> getAllAreas(List <List <Point3D> > planes) { List <double> output = new List <double>(); for (int i = 0; i < planes.Count; i++) { output.Add(UnitConvertor.convertPCM(AreaCalculator.calculateArea(planes[i]), 2)); } return(output); }
/// <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; } }