public static DoseValue GetDoseAtVolume(this PlanningItem pitem, Structure structure, double volume, VolumePresentation volumePresentation, DoseValuePresentation requestedDosePresentation)
 {
     if (pitem is PlanSetup)
     {
         return(((PlanSetup)pitem).GetDoseAtVolume(structure, volume, volumePresentation, requestedDosePresentation));
     }
     else
     {
         if (requestedDosePresentation != DoseValuePresentation.Absolute)
         {
             throw new ApplicationException("Only absolute dose supported for Plan Sums");
         }
         DVHData dvh = pitem.GetDVHCumulativeData(structure, DoseValuePresentation.Absolute, volumePresentation, 0.001);
         return(DvhExtensions.DoseAtVolume(dvh, volume));
     }
 }
Exemple #2
0
        public static DoseValue GetDoseAtVolume(this PlanningItem pitem, Structure structure, double volume, VolumePresentation volumePresentation, DoseValuePresentation requestedDosePresentation, DoseValue?planSumRx = null)
        {
            if (pitem is PlanSetup)
            {
                return(((PlanSetup)pitem).GetDoseAtVolume(structure, volume, volumePresentation, requestedDosePresentation));
            }
            else
            {
                DVHData dvh = pitem.GetDVHCumulativeData(structure, DoseValuePresentation.Absolute, volumePresentation, 0.001);

                if (requestedDosePresentation != DoseValuePresentation.Absolute)
                {
                    //MessageBox.Show(String.Format("Only absolute dose is supported for Plan Sums.  A prescription dose of {1} will be assumed to convert the D{0}% for {2} into a percentage.", volume, planSumRx.ToString(), structure.Id), String.Format("Error during calculation of D{0}%", volume), MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(DvhExtensions.DoseAtVolume(dvh, volume, planSumRx));
                }
                else
                {
                    return(DvhExtensions.DoseAtVolume(dvh, volume));
                }
            }
        }
Exemple #3
0
        //---------------------------------------------------------------------------------------------
        void UpdateDvhLookup()
        {
            if (m_closing || SelectedStructure == null)
            {
                return;
            }

            bool doseAbsolute = m_absDoseCheckbox.IsChecked.Value;
            bool volAbsolute  = m_absVolCheckbox.IsChecked.Value;

            m_volumeAtDoseResultLabel.Content = "";
            m_doseAtVolumeResultLabel.Content = "";

            m_resultVolumeAtDose.Content = "";
            m_resultDoseAtVolume.Content = "";
            m_structureVolume.Text       = "";

            double inputVolume = Double.NaN;

            if (m_volumeTextBox.Text != null)
            {
                Double.TryParse(m_volumeTextBox.Text, out inputVolume);
            }

            double inputDose = Double.NaN;

            if (m_doseTextBox.Text != null)
            {
                Double.TryParse(m_doseTextBox.Text, out inputDose);
            }

            DoseValuePresentation dosePres = doseAbsolute ? DoseValuePresentation.Absolute : DoseValuePresentation.Relative;
            VolumePresentation    volPres  = volAbsolute ? VolumePresentation.AbsoluteCm3 : VolumePresentation.Relative;

            DVHData dvhData = SelectedPlanningItem.GetDVHCumulativeData(SelectedStructure, dosePres, volPres, s_binWidth);

            m_structureVolume.Text = dvhData.Volume.ToString("F5");

            if (SelectedPlanningItem != null && SelectedPlanningItem.Dose != null && SelectedStructure != null)
            {
                if (!Double.IsNaN(inputVolume))
                {
                    DoseValue val        = SelectedPlanningItem.GetDoseAtVolume(SelectedStructure, inputVolume, volPres, dosePres);
                    DoseValue controlVal = DvhExtensions.DoseAtVolume(dvhData, inputVolume);
                    double    err        = Math.Abs((val.Dose - controlVal.Dose) / val.Dose);
                    if (err > 0.001)
                    {
                        MessageBox.Show("Value : " + val.ToString() + " Control Val : " + controlVal.ToString());
                    }
                    m_resultDoseAtVolume.Content = val.ToString();

                    string doseAtVolumeResultType = volAbsolute ? "cm3 D(" : "% D(";
                    doseAtVolumeResultType           += inputVolume.ToString("F1") + (volAbsolute ? "cm3" : "%") + ") =";
                    m_doseAtVolumeResultLabel.Content = doseAtVolumeResultType;
                }
                if (!Double.IsNaN(inputDose))
                {
                    DoseValue.DoseUnit doseUnit = dvhData.MaxDose.Unit;
                    double             vol      = SelectedPlanningItem.GetVolumeAtDose(SelectedStructure, new DoseValue(inputDose, doseUnit), volPres);

                    double controlVal = DvhExtensions.VolumeAtDose(dvhData, inputDose);
                    double err        = Math.Abs((vol - controlVal) / vol);
                    if (err > 0.001)
                    {
                        MessageBox.Show("Value : " + vol.ToString("F3") + " Control Val : " + controlVal.ToString("F3"));
                    }

                    m_resultVolumeAtDose.Content = vol.ToString("F5") + (volAbsolute ? "cm3" : "%");

                    string volumeAtDoseResultType = doseUnit.ToString() + " V(";
                    volumeAtDoseResultType           += inputDose.ToString("F1") + doseUnit.ToString() + " ) =";
                    m_volumeAtDoseResultLabel.Content = volumeAtDoseResultType;
                }
            }
        }