Exemple #1
0
 public string[] GetStringArray(DicomTag tag, string[] deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmMultiStringElement)
         return (elem as DcmMultiStringElement).GetValues();
     if (elem is DcmStringElement)
         return new string[] { (elem as DcmStringElement).GetValue() };
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     return deflt;
 }
Exemple #2
0
 public int GetInt32(DicomTag tag, int deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem != null && elem.Length > 0) {
         if (elem.VR == DicomVR.IS)
             return (elem as DcmIntegerString).GetInt32();
         else if (elem.VR == DicomVR.SL)
             return (elem as DcmSignedLong).GetValue();
         else
             throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     }
     return deflt;
 }
Exemple #3
0
 public string GetString(DicomTag tag, int index, string deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmStringElement)
         return (elem as DcmStringElement).GetValue(index);
     if (elem is DcmMultiStringElement)
         return (elem as DcmMultiStringElement).GetValue(index);
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     return deflt;
 }
Exemple #4
0
 public float GetFloat(DicomTag tag, float deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem != null && elem.Length > 0) {
         if (elem.VR == DicomVR.FL)
             return (elem as DcmFloatingPointSingle).GetValue();
         else if (elem.VR == DicomVR.DS)
             return (elem as DcmDecimalString).GetFloat();
         else
             throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     }
     return deflt;
 }
Exemple #5
0
 public DateTime GetDateTime(DicomTag tag, int index, DateTime deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmDate || elem is DcmTime || elem is DcmDateTime) {
         try {
             if (elem is DcmDate)
                 return (elem as DcmDate).GetDateTime(index);
             if (elem is DcmTime)
                 return (elem as DcmTime).GetDateTime(index);
             if (elem is DcmDateTime)
                 return (elem as DcmDateTime).GetDateTime(index);
         }
         catch {
             return deflt;
         }
     }
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     return deflt;
 }
Exemple #6
0
 public void SetStringArray(DicomTag tag, string[] values)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmMultiStringElement) {
         (elem as DcmMultiStringElement).SetValues(values);
         return;
     }
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     throw new DicomDataException("Element " + tag.ToString() + " does not exist in Dataset");
 }
Exemple #7
0
 public double GetDouble(DicomTag tag, double deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem != null && elem.Length > 0)
     {
         if (elem.VR == DicomVR.FD)
             return (elem as DcmFloatingPointDouble).GetValue();
         else if (elem.VR == DicomVR.DS)
             return (elem as DcmDecimalString).GetDouble();
         else if (elem.VR == DicomVR.OB || elem.VR == DicomVR.UN)
         {
             var bytes = elem.ByteBuffer.ToBytes();
             return BitConverter.ToDouble(bytes, 0);
         }
         else
             throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     }
     return deflt;
 }
Exemple #8
0
 public void ToString()
 {
     var t = new DicomTag(0x0028, 0x9145);
     Assert.AreEqual("(0028,9145)", t.ToString());
 }