Mercurial > hg > orthanc
diff OrthancServer/FromDcmtkBridge.cpp @ 532:b22312081388 dicom-rt
extract roi geometry
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 Aug 2013 16:09:19 +0200 |
parents | 7a966b440f19 |
children | da8e064d0d49 |
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.cpp Thu Aug 29 17:59:09 2013 +0200 +++ b/OrthancServer/FromDcmtkBridge.cpp Fri Aug 30 16:09:19 2013 +0200 @@ -706,13 +706,13 @@ - bool ParsedDicomFile::GetTagValue(std::string& value, - const DicomTag& tag) + static bool GetTagValueInternal(std::string& value, + DcmItem& item, + const DicomTag& tag) { DcmTagKey k(tag.GetGroup(), tag.GetElement()); - DcmDataset& dataset = *file_->getDataset(); DcmElement* element = NULL; - if (!dataset.findAndGetElement(k, element).good() || + if (!item.findAndGetElement(k, element).good() || element == NULL) { return false; @@ -729,7 +729,53 @@ value = v->AsString(); } - return true; + return true; + } + + + bool ParsedDicomFile::GetTagValue(std::string& value, + const DicomTag& tag) + { + DcmDataset& dataset = *file_->getDataset(); + return GetTagValueInternal(value, dataset, tag); + } + + + + bool ParsedDicomFile::GetTagValue(std::string& value, + const SequencePath& path, + const DicomTag& tag) + { + if (path.size() == 0) + { + return GetTagValue(value, tag); + } + + DcmItem* current = file_->getDataset(); + assert(current != NULL); + + for (SequencePath::const_iterator it = path.begin(); it != path.end(); it++) + { + DcmTagKey k(it->first.GetGroup(), it->first.GetElement()); + + DcmSequenceOfItems* sequence = NULL; + if (!current->findAndGetSequence(k, sequence).good() || + sequence == NULL || + sequence->getVR() != EVR_SQ) + { + return false; + } + + if (it->second > sequence->card()) + { + return false; + } + + current = sequence->getItem(it->second); + assert(current != NULL); + } + + return GetTagValueInternal(value, *current, tag); }