/// <summary> /// Calculate DVH estimates for a given plan and structure matches. /// </summary> public static void CalculateDVHEstimates(ExternalPlanSetup plan, Dictionary <string, ModelStructure> structureMatches) { var prescribedDose = plan.TotalPrescribedDose; var matchedStructures = structureMatches.ToDictionary(x => x.Key, x => x.Value.ModelId); var targetStructureDoseLevels = structureMatches.Where(x => x.Value.StructureType == ModelStructureType.Target).ToDictionary(x => x.Key, x => prescribedDose); Trace.WriteLine("\nCalculating DVH estimates...\n"); plan.SetCalculationModel(CalculationType.DVHEstimation, DVHEstimationAlgorithm); var res = plan.CalculateDVHEstimates(DVHEstimationModel, targetStructureDoseLevels, matchedStructures); if (!res.Success) { throw new Exception("DVH estimation failed."); } Trace.WriteLine("\nDVH estimation succeeded!\n"); }