Пример #1
0
        private void ReadBulkData
        (
            DicomTag tag,
            DicomVR vr,
            JsonTextReader reader,
            DicomDataset dataset,
            int level
        )
        {
            Dicom.IO.Buffer.BulkDataUriByteBuffer data = null;


            if (reader.Read( ))
            {
                string uri = (string)reader.Value;


                if (!string.IsNullOrEmpty(uri))
                {
                    data = new Dicom.IO.Buffer.BulkDataUriByteBuffer(uri);
                }

                if (tag == DicomTag.PixelData && level == 0)
                {
                    var pixelData = DicomPixelData.Create(dataset, true); //2nd parameter is true since we are adding new data here
                    pixelData.AddFrame(data);
                }
                else
                {
                    dataset.AddOrUpdate <Dicom.IO.Buffer.IByteBuffer> (vr, tag, data);
                }
            }
        }
Пример #2
0
        private void ReadBulkData
        (
            fo.DicomTag tag,
            fo.DicomVR vr,
            JsonTextReader reader,
            fo.DicomDataset dataset,
            int level
        )
        {
            fo.IO.Buffer.BulkDataUriByteBuffer data = null;


            if (reader.Read( ))
            {
                string uri = (string)reader.Value;


                if (!string.IsNullOrEmpty(uri))
                {
                    data = new fo.IO.Buffer.BulkDataUriByteBuffer(uri);
                }

                if (tag == fo.DicomTag.PixelData && level == 0)
                {
                    dataset.AddOrUpdatePixelData(vr, data, fo.DicomTransferSyntax.Parse(TransferSyntaxUID));
                }
                else
                {
                    dataset.AddOrUpdate <fo.IO.Buffer.IByteBuffer> (vr, tag, data);
                }
            }
        }
Пример #3
0
        private void ReadElement
        (
            fo.DicomDataset ds,
            XElement element,
            fo.DicomTag tag,
            fo.DicomVR dicomVr,
            int level
        )
        {
            if (dicomVr == fo.DicomVR.PN)
            {
                string personNameValue = "";

                foreach (var personNameElementValue in element.Elements( ).OrderBy(n => n.Attribute(Constants.ATTRIBUTE_NUMBER)))
                {
                    foreach (var personNameComponent in personNameElementValue.Elements( ))
                    {
                        if (personNameComponent.Name == Utilities.PersonNameComponents.PN_COMP_ALPHABETIC ||
                            personNameComponent.Name == Utilities.PersonNameComponents.PN_COMP_IDEOGRAPHIC ||
                            personNameComponent.Name == Utilities.PersonNameComponents.PN_COMP_PHONETIC)
                        {
                            personNameValue = UpdatePersonName(personNameValue, personNameComponent, Utilities.PersonNameParts.PN_Family);
                            personNameValue = UpdatePersonName(personNameValue, personNameComponent, Utilities.PersonNameParts.PN_Given);
                            personNameValue = UpdatePersonName(personNameValue, personNameComponent, Utilities.PersonNameParts.PN_Midlle);
                            personNameValue = UpdatePersonName(personNameValue, personNameComponent, Utilities.PersonNameParts.PN_Prefix);
                            personNameValue = UpdatePersonName(personNameValue, personNameComponent, Utilities.PersonNameParts.PN_Suffix, true);

                            personNameValue = personNameValue.TrimEnd('^');    // extra cleanup

                            personNameValue += "=";
                        }
                    }

                    personNameValue = personNameValue.TrimEnd('=');

                    personNameValue += "\\";
                }

                personNameValue = personNameValue.TrimEnd('\\');
                ds.AddOrUpdate <string> (dicomVr, tag, personNameValue);
            }
            else if (Utilities.IsBinaryVR(dicomVr))
            {
                var dataElement = element.Elements( ).OfType <XElement> ( ).FirstOrDefault( );

                if (null != dataElement)
                {
                    fo.IO.Buffer.IByteBuffer data;


                    if (dataElement.Name == Constants.ELEMENT_BULKDATA)
                    {
                        string uri = dataElement.Attribute(Constants.ATTRIBUTE_BULKDATAURI).Value;


                        data = new fo.IO.Buffer.BulkDataUriByteBuffer(uri);
                    }
                    else
                    {
                        var base64 = System.Convert.FromBase64String(dataElement.Value);


                        data = new fo.IO.Buffer.MemoryByteBuffer(base64);
                    }

                    if (tag == fo.DicomTag.PixelData && level == 0)
                    {
                        ds.AddOrUpdatePixelData(dicomVr, data, TransferSyntax);
                    }
                    else
                    {
                        ds.AddOrUpdate <fo.IO.Buffer.IByteBuffer> (dicomVr, tag, data);
                    }
                }
            }
            else
            {
                var values = ReadValue(element);

                if (tag == fo.DicomTag.TransferSyntaxUID)
                {
                    TransferSyntax = fo.DicomTransferSyntax.Parse(values.FirstOrDefault( ));
                }

                ds.AddOrUpdate <string> (dicomVr, tag, values.ToArray( ));
            }
        }