Mercurial > hg > orthanc
changeset 3580:46a8050583a1
OrthancPlugins::DicomPath::Format()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Nov 2019 17:59:53 +0100 |
parents | 74fc2a3b43bb |
children | 4de1b019ca71 |
files | Plugins/Samples/Common/DicomPath.cpp Plugins/Samples/Common/DicomPath.h Plugins/Samples/Common/DicomTag.cpp Plugins/Samples/Common/DicomTag.h |
diffstat | 4 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/Samples/Common/DicomPath.cpp Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomPath.cpp Wed Nov 20 17:59:53 2019 +0100 @@ -35,6 +35,8 @@ #include "OrthancPluginException.h" +#include <boost/lexical_cast.hpp> + namespace OrthancPlugins { const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const @@ -97,4 +99,18 @@ AddToPrefix(sequence2, index2); AddToPrefix(sequence3, index3); } + + + std::string DicomPath::Format() const + { + std::string s; + + for (size_t i = 0; i < GetPrefixLength(); i++) + { + s += (GetPrefixTag(i).FormatHexadecimal() + " / " + + boost::lexical_cast<std::string>(i) + " / "); + } + + return s + GetFinalTag().FormatHexadecimal(); + } }
--- a/Plugins/Samples/Common/DicomPath.h Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomPath.h Wed Nov 20 17:59:53 2019 +0100 @@ -112,5 +112,7 @@ { finalTag_ = tag; } + + std::string Format() const; }; }
--- a/Plugins/Samples/Common/DicomTag.cpp Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomTag.cpp Wed Nov 20 17:59:53 2019 +0100 @@ -108,4 +108,12 @@ ORTHANC_PLUGINS_THROW_EXCEPTION(NotImplemented); } } + + + std::string DicomTag::FormatHexadecimal() const + { + char buf[16]; + sprintf(buf, "(%04x,%04x)", group_, element_); + return buf; + } }
--- a/Plugins/Samples/Common/DicomTag.h Wed Nov 20 09:44:46 2019 +0100 +++ b/Plugins/Samples/Common/DicomTag.h Wed Nov 20 17:59:53 2019 +0100 @@ -34,6 +34,7 @@ #pragma once #include <stdint.h> +#include <string> namespace OrthancPlugins { @@ -74,6 +75,8 @@ { return !(*this == other); } + + std::string FormatHexadecimal() const; };