Exemplo n.º 1
0
 public DicomDictionary this[DicomPrivateCreator creator]
 {
     get
     {
         return(_private.GetOrAdd(creator, _ => new DicomDictionary(creator)));
     }
 }
Exemplo n.º 2
0
 private DicomDictionary(DicomPrivateCreator creator)
 {
     _privateCreator = creator;
     _entries        = new ConcurrentDictionary <DicomTag, DicomDictionaryEntry>();
     _keywords       = new ConcurrentDictionary <string, DicomTag>();
     _masked         = new ConcurrentBag <DicomDictionaryEntry>();
 }
Exemplo n.º 3
0
        public void Add_PrivateTag_GetsCorrectVR()
        {
            var privCreatorDictEntry = new DicomDictionaryEntry(
                new DicomTag(0x0011, 0x0010),
                "Private Creator",
                "PrivateCreator",
                DicomVM.VM_1,
                false,
                DicomVR.LO);

            DicomDictionary.Default.Add(privCreatorDictEntry);

            DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1");
            DicomDictionary     privDict1       = DicomDictionary.Default[privateCreator1];

            var dictEntry = new DicomDictionaryEntry(
                DicomMaskedTag.Parse("0011", "xx10"),
                "TestPrivTagName",
                "TestPrivTagKeyword",
                DicomVM.VM_1,
                false,
                DicomVR.CS);

            privDict1.Add(dictEntry);

            var ds = new DicomDataset
            {
                { dictEntry.Tag, "VAL1" }
            };

            Assert.Equal(DicomVR.CS, ds.Get <DicomVR>(ds.GetPrivateTag(dictEntry.Tag)));
        }
Exemplo n.º 4
0
 private DicomDictionary(DicomPrivateCreator creator)
 {
     _privateCreator  = creator;
     _entries         = new ConcurrentDictionary <DicomTag, DicomDictionaryEntry>();
     _masked          = new List <DicomDictionaryEntry>();
     _maskedLock      = new object();
     _maskedNeedsSort = false;
 }
Exemplo n.º 5
0
        public DicomPrivateCreator GetPrivateCreator(string creator)
        {
            DicomPrivateCreator pvt = null;

            if (!_creators.TryGetValue(creator, out pvt))
            {
                pvt = new DicomPrivateCreator(creator);
                _creators.Add(creator, pvt);
            }
            return(pvt);
        }
Exemplo n.º 6
0
 public DicomDictionary this[DicomPrivateCreator creator] {
     get {
         DicomDictionary pvt = null;
         if (!_private.TryGetValue(creator, out pvt))
         {
             pvt = new DicomDictionary(creator);
             _private.Add(creator, pvt);
         }
         return(pvt);
     }
 }
Exemplo n.º 7
0
        public static DicomTag Parse(string s)
        {
            try
            {
                if (s.Length < 8)
                {
                    throw new ArgumentOutOfRangeException("s", "Expected a string of 8 or more characters");
                }

                int pos = 0;
                if (s[pos] == '(')
                {
                    pos++;
                }

                ushort group = ushort.Parse(s.Substring(pos, 4), NumberStyles.HexNumber);
                pos += 4;

                if (s[pos] == ',')
                {
                    pos++;
                }

                ushort element = ushort.Parse(s.Substring(pos, 4), NumberStyles.HexNumber);
                pos += 4;

                DicomPrivateCreator creator = null;
                if (s.Length > pos && s[pos] == ':')
                {
                    pos++;

                    string c = null;
                    if (s[s.Length - 1] == ')')
                    {
                        c = s.Substring(pos, s.Length - pos - 1);
                    }
                    else
                    {
                        c = s.Substring(pos);
                    }

                    creator = DicomDictionary.Default.GetPrivateCreator(c);
                }

                //TODO: get value from related DicomDictionaryEntry

                return(new DicomTag(group, element, creator));
            }
            catch (Exception e)
            {
                throw new DicomDataException("Error parsing DICOM tag ['" + s + "']", e);
            }
        }
Exemplo n.º 8
0
        public void Add_PrivateTag_ShouldBeAddedWithCorrectVR()
        {
            var privCreatorDictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO);

            DicomDictionary.Default.Add(privCreatorDictEntry);

            DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1");
            DicomDictionary     privDict1       = DicomDictionary.Default[privateCreator1];

            var dictEntry = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS);

            privDict1.Add(dictEntry);

            var ds = new DicomDataset();

            ds.Add(dictEntry.Tag, "VAL1");
            Assert.Equal(DicomVR.CS, ds.GetDicomItem <DicomItem>(dictEntry.Tag).ValueRepresentation);
        }
Exemplo n.º 9
0
        public void Enumerate_DictionaryEntriesWithPrivateTags_ContainsAllExpectedEntries()
        {
            var dict = new DicomDictionary();

            var tag1       = new DicomTag(0x0010, 0x0020);
            var dictEntry1 = new DicomDictionaryEntry(
                tag1,
                "TestPublicTagName",
                "TestPublicTagKeyword",
                DicomVM.VM_1,
                false,
                DicomVR.DT);
            var privCreatorDictEntry = new DicomDictionaryEntry(
                new DicomTag(0x0011, 0x0010),
                "Private Creator",
                "PrivateCreator",
                DicomVM.VM_1,
                false,
                DicomVR.LO);

            dict.Add(privCreatorDictEntry);

            DicomPrivateCreator privateCreator = dict.GetPrivateCreator("TESTCREATOR");
            DicomDictionary     privDict       = dict[privateCreator];

            var dictEntry2 = new DicomDictionaryEntry(
                DicomMaskedTag.Parse("0011", "xx10"),
                "TestPrivTagName",
                "TestPrivTagKeyword",
                DicomVM.VM_1,
                false,
                DicomVR.DT);

            privDict.Add(dictEntry2);
            dict.Add(dictEntry1);

            Assert.Contains(dictEntry1, dict);
            Assert.Contains(privCreatorDictEntry, dict);
            Assert.Contains(dictEntry2, dict[dictEntry2.Tag.PrivateCreator]);
        }
Exemplo n.º 10
0
 public DicomTag(ushort group, ushort element, DicomPrivateCreator privateCreator)
 {
     Group          = group;
     Element        = element;
     PrivateCreator = privateCreator;
 }
Exemplo n.º 11
0
 private DicomDictionary(DicomPrivateCreator creator)
 {
     _privateCreator = creator;
     _entries        = new Dictionary <DicomTag, DicomDictionaryEntry>();
     _masked         = new List <DicomDictionaryEntry>();
 }