示例#1
0
        /// <summary>
        ///     Creates a new DICOM Data object from an array of data
        /// </summary>
        /// <param name="dataArray">the data array from which to initialize the DICOM Data object</param>
        /// <returns></returns>
        public static DICOMData <T> CreateFromArray(T[] dataArray)
        {
            var data = new DICOMData <T>();

            if (dataArray != null)
            {
                data.MultipicityValue = dataArray.ToList();
            }
            return(data);
        }
示例#2
0
        /// <summary>
        ///     Creates a new DICOM Data object from a single data value
        /// </summary>
        /// <param name="dataValue">the data value from which to initialize the DICOM Data object</param>
        /// <returns></returns>
        public static DICOMData <T> CreateFromSingle(T dataValue)
        {
            var data = new DICOMData <T>();

            if (dataValue != null)
            {
                data.SingleValue = dataValue;
            }
            return(data);
        }
示例#3
0
        /// <summary>
        /// Creates a new DICOM Data object from a single data value
        /// </summary>
        /// <param name="dataValue">the data value from which to initialize the DICOM Data object</param>
        /// <returns></returns>
        public static DICOMData <T> CreateFromSingle(T dataValue)
        {
            DICOMData <T> data = new DICOMData <T>();

            if (dataValue != null)
            {
                data.SingleValue = dataValue;
                return(data);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        ///     Wraps a DICOM sequence with a type that inherits from DICOMObjectWrapper
        /// </summary>
        /// <typeparam name="T">the wrapping class for the DICOM objects within the sequence</typeparam>
        /// <param name="tag">the DICOM tag of the sequence which contains the objects to wrap</param>
        /// <returns>a list of wrapped DICOM objects</returns>
        public List <T> GetWrappedSequence <T>(Tag tag) where T : DICOMObjectWrapper, new()
        {
            DICOMData <DICOMObject> seq = _dcm.TryGetDataValue <DICOMObject>(tag, null);

            if (seq != null)
            {
                return(seq.MultipicityValue.Select(si =>
                {
                    var t = new T();
                    t._dcm = si;
                    return t;
                }).ToList());
            }
            return(null);
        }
示例#5
0
        /// <summary>
        ///     Searches for a specific element. If it is found, it returns the data from the element. Otherwise,
        ///     it will return a provided default value for the element.
        /// </summary>
        /// <typeparam name="T">the type of data to return</typeparam>
        /// <param name="tagToFind">the tag of the element containing the data</param>
        /// <param name="defaultValueIfNull">the default value to return if the element is not found</param>
        /// <returns></returns>
        public DICOMData <T> TryGetDataValue <T>(Tag tagToFind, object defaultValueIfNull)
        {
            var found = FindFirst(tagToFind) as AbstractElement <T>;

            if (found != null)
            {
                return(found.DataContainer);
            }
            var data = new DICOMData <T>();

            if (typeof(T).IsArray)
            {
                data.MultipicityValue = ((T[])defaultValueIfNull).ToList();
            }
            else
            {
                data.SingleValue = (T)defaultValueIfNull;
            }
            return(data);
        }