예제 #1
0
            private bool ParseTag(IByteSource source)
            {
                if (_parseStage == ParseStage.Tag)
                {
                    source.Mark();

                    if (!source.Require(4))
                    {
                        _result = DicomReaderResult.Suspended;
                        return(false);
                    }

                    var group   = source.GetUInt16();
                    var element = source.GetUInt16();
                    DicomPrivateCreator creator = null;

                    // according to
                    // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_7.8.html
                    // The requirements of this section do not allow any use of elements in the ranges
                    // (gggg,0001-000F) and (gggg,0100-0FFF) where gggg is odd.
                    // So element at [0x0100-0x0FFF] should not has a creator
                    if (@group.IsOdd() && element >= 0x1000)
                    {
                        var card = (uint)(@group << 16) + (uint)(element >> 8);
                        lock (_locker)
                        {
                            if (_private.TryGetValue(card, out string pvt))
                            {
                                creator = _dictionary.GetPrivateCreator(pvt);
                            }
                        }
                    }

                    _tag   = new DicomTag(@group, element, creator);
                    _entry = _dictionary[_tag];

                    if (!_tag.IsPrivate && _entry != null && _entry.MaskTag == null)
                    {
                        _tag = _entry.Tag; // Use dictionary tag
                    }

                    if (_stop != null &&
                        _stop(new ParseState {
                        Tag = _tag, SequenceDepth = _sequenceDepth
                    }))
                    {
                        _result = DicomReaderResult.Stopped;
                        return(false);
                    }

                    _parseStage = ParseStage.VR;
                }
                return(true);
            }
예제 #2
0
            private bool ParseTag(IByteSource source)
            {
                if (_parseStage == ParseStage.Tag)
                {
                    source.Mark();

                    if (!source.Require(4))
                    {
                        _result = DicomReaderResult.Suspended;
                        return(false);
                    }

                    var group   = source.GetUInt16();
                    var element = source.GetUInt16();
                    DicomPrivateCreator creator = null;

                    if (@group.IsOdd() && element > 0x00ff)
                    {
                        var card = (uint)(@group << 16) + (uint)(element >> 8);
                        lock (_locker)
                        {
                            if (_private.TryGetValue(card, out string pvt))
                            {
                                creator = _dictionary.GetPrivateCreator(pvt);
                            }
                        }
                    }

                    _tag   = new DicomTag(@group, element, creator);
                    _entry = _dictionary[_tag];

                    if (!_tag.IsPrivate && _entry != null && _entry.MaskTag == null)
                    {
                        _tag = _entry.Tag; // Use dictionary tag
                    }

                    if (_stop != null &&
                        _stop(new ParseState {
                        Tag = _tag, SequenceDepth = _sequenceDepth
                    }))
                    {
                        _result = DicomReaderResult.Stopped;
                        return(false);
                    }

                    _parseStage = ParseStage.VR;
                }
                return(true);
            }
예제 #3
0
        public void AddPrivateTagAndReadOut()
        {
            var dict = new DicomDictionary
            {
                new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO)
            };

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

            var dictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x1010), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT);

            privDict.Add(dictEntry);

            Assert.True(dictEntry.Equals(dict[dictEntry.Tag.PrivateCreator][dictEntry.Tag]));
        }
예제 #4
0
        public void EnumerateBothPublicAndPrivateEntries()
        {
            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.True(dict.Contains(dictEntry1));
            Assert.True(dict.Contains(privCreatorDictEntry));
            Assert.True(dict[dictEntry2.Tag.PrivateCreator].Contains(dictEntry2));
            Assert.True(dict.PrivateCreators.Any(pc => dict[pc].Contains(dictEntry2)));
        }