private Tuple <double, double> calculateDose(Dose fielddose, VVector dosepoint2, double dosenorm, double radius) { List <double> doses = new List <double>(); //System.Windows.MessageBox.Show("Dose in point: " + (dosenorm * plansetup.Dose.GetDoseToPoint(dosepoint2).Dose / 100).ToString()); for (double i = -radius * 10.0 + 20.0; i < radius * 10.0 + 20.0; i++) { for (double j = -radius * 10.0 + 20.0; j < radius * 10.0 + 20.0; j++) { if (i * i + j * j <= radius * 10.0 * radius * 10.0) { VVector dosepoint_vector = new VVector { x = dosepoint2.x + i / 10.0, y = dosepoint2.y, z = dosepoint2.z + j / 10.0 }; DoseValue dose = fielddose.GetDoseToPoint(dosepoint_vector); doses.Add(dosenorm * dose.Dose / 100.0); //Gy } } } //System.Windows.MessageBox.Show(doses.Count().ToString()); //System.Windows.MessageBox.Show(doses.Sum().ToString()); double mean = doses.Sum() / (double)doses.Count; double dup = 0; foreach (var dip in doses) { dup += (dip - mean) * (dip - mean); } double std = Math.Sqrt(dup / (doses.Count - 1)); Tuple <double, double> iTuple = new Tuple <double, double>(mean, std); return(iTuple); }
private void Make3DModel(int index) { int n = index; var meshGeometry = ss.Structures.ElementAt(n).MeshGeometry; double val; int npoints = meshGeometry.TriangleIndices.Count; IList <Point3D> positions = new List <Point3D>(); IList <Point> points = new List <Point>(); double zmin = 1000; double zmax = -1000; foreach (var point in meshGeometry.Positions) { if (point.Z < zmin) { zmin = point.Z; } if (point.Z > zmax) { zmax = point.Z; } } bool flag; for (int i = 0; i < npoints / 3; i++) { flag = false; for (int j = 0; j < 3; j++) { int k = meshGeometry.TriangleIndices.ElementAt(i * 3 + j); var point = meshGeometry.Positions.ElementAt(k); if (point.Z > zmin + dz / 2 && point.Z < zmax - dz / 2) { flag = true; } } if (flag || viewMode == 1) { for (int j = 0; j < 3; j++) { int k = meshGeometry.TriangleIndices.ElementAt(i * 3 + j); var point = meshGeometry.Positions.ElementAt(k); positions.Add(point); val = dose.GetDoseToPoint(new VVector(point.X, point.Y, point.Z)).Dose; if (!IsRelativeDoseValue) { val /= totalDose; val *= 100; } if (val > 105) { val = 105; } if (val < 0) { val = 0; } points.Add(new Point(val / (ncolors - 1), val / (ncolors - 1))); } } } for (int i = 0; i < 3; i++) { positions.Add(new Point3D(0, 0, 0)); points.Add(new Point(0, 0)); } for (int i = 0; i < 3; i++) { positions.Add(new Point3D(0, 0, 0)); points.Add(new Point(1.0, 1.0)); } model = new GeometryModel3D() { Geometry = new MeshGeometry3D() { Positions = new Point3DCollection(positions), TextureCoordinates = new PointCollection(points) }, Material = new DiffuseMaterial(imageBrush), }; if (viewMode == 2) { model.BackMaterial = model.Material; } }