Ejemplo n.º 1
0
 protected override object GetValueEx(string name)
 {
     if (name == "Tag")
     {
         string str = DHelper.Int2HexString(Tag);
         if (str.Length == 4)
         {
             str = "0000" + str;
         }
         else if (str.Length == 5)
         {
             str = "000" + str;
         }
         else if (str.Length == 6)
         {
             str = "00" + str;
         }
         else if (str.Length == 7)
         {
             str = "0" + str;
         }
         return(str);
     }
     else if (name == "Value")
     {
         // 20110119  To avoid XML-invalid characters such as &,<,> be copied from the DICOM tag into the XML string
         //return string.Format("<![CDATA[{0}]]>", base.GetValueEx(name));
         return(XMLTransformer.ConvertToXMLEscapeString(base.GetValueEx(name).ToString()));
     }
     else
     {
         return(base.GetValueEx(name));
     }
 }
Ejemplo n.º 2
0
        public static DPath GetDPath(DicomTag tag, DVR vr, string description, string sqRootPath, int sqIndex)
        {
            string strG = DHelper.Int2HexString(tag.Group);
            string strE = DHelper.Int2HexString(tag.Element);
            //string name = DHelper.GetTagName((uint)ele.Tag);

            // for shorten the DPath string length 20071010
            string name = "A";

            StringBuilder sb = new StringBuilder();

            if (sqRootPath != null && sqIndex >= 0)
            {
                sb.Append(sqRootPath).Append(Seperator).Append(sqIndex.ToString()).Append(Seperator);
            }
            sb.Append(strG).Append(Seperator).Append(strE).Append(Seperator).Append(name).Append(Seperator);
            string str = sb.ToString();

            DPath dpath = new DPath();

            dpath.Path        = str.TrimEnd(Seperator);
            dpath.Description = description;
            dpath.VR          = vr;
            return(dpath);
        }
Ejemplo n.º 3
0
        private string getValue()
        {
            try
            {
                int vm = 0;
                DVR vr = DHelper.ConvertToDVR(DicomVR.UN);
                if (_element != null)
                {
                    vr = DHelper.ConvertToDVR(_element.ValueRepresentation);
                    //vm = _element.VM;
                }
                if (vr == DVR.UN)
                {
                    if (_element != null)        // do not implement _element yet, because error handler is using Element with (0000,0000), fix this in the future 20080312
                    {
                        return("");
                    }
                }

                // ----------------

                switch (vr)
                {
                case DVR.UN:
                case DVR.OB:
                case DVR.OF:
                case DVR.OW:
                case DVR.SQ:
                {
                    return("");
                }

                //VRs of LO, LT, SH, ST, and UT plus PN for person name are subject to character set extensions.
                //VRs AE, AS, CS, DS, and IS always use the default character set and have further restrictions on their contents.
                case DVR.LO:
                case DVR.LT:
                case DVR.SH:
                case DVR.ST:
                case DVR.UT:
                default:
                {
                    DicomMultiStringElement dicomMultiStringElement = _element as DicomMultiStringElement;

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < dicomMultiStringElement.Count; i++)
                    {
                        sb.Append(dicomMultiStringElement.Get <string>(i)).Append(DHelper.ValueDelimiter);
                    }
                    return(sb.ToString().TrimEnd(DHelper.ValueDelimiter));
                }
                }
            }
            catch (Exception err)
            {
                DElement errEle = new DElement(_tag, _vr);
                LogMgt.Logger.Write(err.ToString());
            }
            return("");
        }
Ejemplo n.º 4
0
        public static bool IsPrivateTag(int tag)
        {
            // private tag or public tag which is not included in KDT's dictionary

            int group = DHelper.GetGroup(tag);

            return((group % 2 != 0) || !Enum.IsDefined(typeof(tag_t), tag));
        }
Ejemplo n.º 5
0
 private int getTag()
 {
     if (_element != null)
     {
         return(DHelper.GE2int(_element.Tag.Group, _element.Tag.Element));
     }
     return(0);
 }
Ejemplo n.º 6
0
 public DVR getVR()
 {
     if (_element != null)
     {
         DicomVR vr = _element.ValueRepresentation;
         return(DHelper.ConvertToDVR(vr));
     }
     return(DVR.UN);
 }
Ejemplo n.º 7
0
        public DElement(int groupNumber, int elementNumber, DVR vr, string value)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = new DicomTag((ushort)groupNumber, (ushort)elementNumber);

            _element = CreateEmptyElement(dicomTag, dicomVR);
            Value    = value;
        }
Ejemplo n.º 8
0
        public DElement(int tag, DVR vr, DValueType type)
        {
            IsRef = false;

            DicomVR  dicomVR  = DHelper.ConvertToDicomVR(vr);
            DicomTag dicomTag = DHelper.Int2DicomTag(tag);

            _element = CreateEmptyElement(dicomTag, dicomVR);

            Type = type;
        }
Ejemplo n.º 9
0
 public string GetTagName()
 {
     if (_description != null && _description.Length > 0)
     {
         return(_description);
     }
     else
     {
         return(DHelper.GetTagName((uint)GetTag()));
     }
 }
Ejemplo n.º 10
0
        private void setTag(int tag)
        {
            DicomTag dicomTag = DicomTag.Parse(DHelper.Int2HexString(tag));

            if (_element != null)
            {
                DicomVR vr = _element.ValueRepresentation;
                //string val = Value;
                _element = CreateEmptyElement(dicomTag, vr);
                //Value = val;
            }
        }
Ejemplo n.º 11
0
 protected override bool SetValueEx(string name, string newvalue)
 {
     if (name == "Tag")
     {
         Tag = DHelper.HexString2Int(newvalue);
         return(true);
     }
     else
     {
         return(base.SetValueEx(name, newvalue));
     }
 }
Ejemplo n.º 12
0
        public int GetTag()
        {
            string strG = GetGroupString();
            string strE = GetElementString();

            if (strG.Length < 1 || strE.Length < 1)
            {
                return(0);
            }
            int tag = DHelper.HexString2Int(strG + strE);

            return(tag);
        }
Ejemplo n.º 13
0
        public override string ToString()
        {
            if (_element != null)
            {
                return("(" + DHelper.Int2HexString(_element.Tag.Group) + ","
                       + DHelper.Int2HexString(_element.Tag.Element) + ") "
                       + getVRString() + " "
                       + getValue() + "\t\t\t"
                       + DHelper.GetTagName(DHelper.GE2uint(_element.Tag.Group, _element.Tag.Element)));
            }

            return("");
        }
Ejemplo n.º 14
0
        internal static DicomVR GetPrivateTagVR(uint tag)
        {
            if (PrivateTagList == null || PrivateTagList.Count < 1 || tag < 1)
            {
                return(DicomVR.UN);
            }

            foreach (PrivateTag t in PrivateTagList)
            {
                if (t.IntTag == tag)
                {
                    return(DHelper.ConvertToDicomVR(t.VR));
                }
            }

            return(DicomVR.UN);
        }
Ejemplo n.º 15
0
        private DicomVR SwitchVR()
        {
            if (_vrSwitched)
            {
                return(_switchedVR);
            }

            uint tag = 0;

            if (_element != null)
            {
                tag = DHelper.GE2uint(_element.Tag.Group, _element.Tag.Element);
            }
            _switchedVR = PrivateTagHelper.GetPrivateTagVR(tag);
            _vrSwitched = true;

            return(_switchedVR);
        }
Ejemplo n.º 16
0
 private void setVR(DVR vr)
 {
     try
     {
         DicomVR dicomVR = DHelper.ConvertToDicomVR(vr);
         if (_element != null)
         {
             DicomTag tag = _element.Tag;
             //string val = Value;
             _element = CreateEmptyElement(tag, dicomVR);
             //Value = val;
         }
     }
     catch (Exception ex)
     {
         LogMgt.Logger.Write(ex.ToString());
     }
 }
Ejemplo n.º 17
0
        public int GetTag(int depth)
        {
            if (depth < 0)
            {
                return(0);
            }
            int gIndex = depth * 4;
            int eIndex = depth * 4 + 1;

            string[] strlist = Path.Split(DPath.Seperator);
            if (strlist.Length <= eIndex)
            {
                return(0);
            }

            string gStr = strlist[gIndex];
            string eStr = strlist[eIndex];

            return(DHelper.HexString2Int(gStr + eStr));
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Convert to DICOM rooted XML string.
 /// </summary>
 /// <returns></returns>
 public string ToDicomXMLString()
 {
     return(DHelper.ConvertToDicomXml(this));
 }
Ejemplo n.º 19
0
 public static DElementList CreateFromDicomXml(string dicomRootedXmlString)
 {
     return(CreateFromXml(DHelper.GetElementListXmlFromDicomXml(dicomRootedXmlString)));
 }
Ejemplo n.º 20
0
        public static int GetElement(int tag)
        {
            DicomTag dicomTag = DHelper.Int2DicomTag(tag);

            return(dicomTag.Element);
        }
Ejemplo n.º 21
0
        public static int GetGroup(int tag)
        {
            DicomTag dicomTag = DHelper.Int2DicomTag(tag);

            return(dicomTag.Group);
        }