public static DicomDataset Write(DicomRTReferencedSeries series) { var ds = new DicomDataset(); ds.Add(DicomTag.SeriesInstanceUID, series.SeriesInstanceUID); var listOfContour = new List <DicomDataset>(); foreach (var contour in series.ContourImages) { var newDS = DicomRTContourImageItem.Write(contour); listOfContour.Add(newDS); } ds.Add(new DicomSequence(DicomTag.ContourImageSequence, listOfContour.ToArray())); return(ds); }
/// <summary> /// Constructs a new DicomDataSet representing the given DicomRTContourItem /// </summary> /// <param name="contourItem"></param> /// <returns></returns> public static DicomDataset Write(DicomRTContourItem contourItem) { var newDS = new DicomDataset(); // The contour data is in Dicom Patient Coordinates (always mm units) // rounding to 0.001 gives us 1 micron accuracy and should not blow the 16 char limit in DICOM // for DS value representations. var roundedData = contourItem.Data.Select(d => d.ToString("F3", CultureInfo.InvariantCulture)).ToArray(); newDS.Add(DicomTag.ContourData, roundedData); newDS.Add(DicomTag.NumberOfContourPoints, contourItem.NumberOfPoints); newDS.Add(DicomTag.ContourGeometricType, contourItem.GeometricType); var imageDataSets = new List <DicomDataset>(); foreach (var imageSeq in contourItem.ImageSeq) { imageDataSets.Add(DicomRTContourImageItem.Write(imageSeq)); } newDS.Add(new DicomSequence(DicomTag.ContourImageSequence, imageDataSets.ToArray())); return(newDS); }