Mercurial > hg > orthanc
diff OrthancServer/FromDcmtkBridge.cpp @ 1739:df331354cea2
include binary in ToJson
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 22 Oct 2015 19:00:32 +0200 |
parents | 15a788a63846 |
children | 57b9e6890482 |
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.cpp Thu Oct 22 09:28:08 2015 +0200 +++ b/OrthancServer/FromDcmtkBridge.cpp Thu Oct 22 19:00:32 2015 +0200 @@ -407,17 +407,15 @@ case EVR_OF: // other float case EVR_OW: // other word case EVR_UN: // unknown value representation + case EVR_ox: // OB or OW depending on context { - DicomTag tag(Convert(element.getTag())); - - if ((tag == DICOM_TAG_PIXEL_DATA && flags & DicomToJsonFlags_IncludePixelData) || - (tag != DICOM_TAG_PIXEL_DATA && flags & DicomToJsonFlags_IncludeBinary)) + if (!(flags & DicomToJsonFlags_ConvertBinaryToNull)) { Uint8* data = NULL; if (element.getUint8Array(data) == EC_Normal) { return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true); - } + } } return new DicomValue; @@ -537,7 +535,6 @@ * Internal to DCMTK. **/ - case EVR_ox: // OB or OW depending on context case EVR_xs: // SS or US depending on context case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) case EVR_na: // na="not applicable", for data which has no VR @@ -794,6 +791,23 @@ } } + DcmEVR evr = element->getTag().getEVR(); + if (evr == EVR_OB || + evr == EVR_OF || + evr == EVR_OW || + evr == EVR_UN || + evr == EVR_ox) + { + // This is a binary tag + DicomTag tag(FromDcmtkBridge::Convert(element->getTag())); + + if ((tag == DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludePixelData)) || + (tag != DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludeBinary))) + { + continue; + } + } + FromDcmtkBridge::ToJson(parent, *element, format, flags, maxStringLength, encoding); } } @@ -1061,7 +1075,13 @@ static bool IsBinaryTag(const DcmTag& key) { - return key.isPrivate() || key.isUnknownVR(); + return (key.isPrivate() || + key.isUnknownVR() || + key.getEVR() == EVR_OB || + key.getEVR() == EVR_OF || + key.getEVR() == EVR_OW || + key.getEVR() == EVR_UN || + key.getEVR() == EVR_ox); } @@ -1079,17 +1099,15 @@ // http://support.dcmtk.org/docs/dcvr_8h-source.html /** - * TODO. + * Binary types, handled above **/ case EVR_OB: // other byte case EVR_OF: // other float case EVR_OW: // other word - case EVR_AT: // attribute tag - throw OrthancException(ErrorCode_NotImplemented); - case EVR_UN: // unknown value representation - throw OrthancException(ErrorCode_ParameterOutOfRange); + case EVR_ox: // OB or OW depending on context + throw OrthancException(ErrorCode_InternalError); /** @@ -1175,10 +1193,17 @@ /** + * TODO + **/ + + case EVR_AT: // attribute tag + throw OrthancException(ErrorCode_NotImplemented); + + + /** * Internal to DCMTK. **/ - case EVR_ox: // OB or OW depending on context case EVR_xs: // SS or US depending on context case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) case EVR_na: // na="not applicable", for data which has no VR