Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1738:15a788a63846 | 1739:df331354cea2 |
---|---|
405 | 405 |
406 case EVR_OB: // other byte | 406 case EVR_OB: // other byte |
407 case EVR_OF: // other float | 407 case EVR_OF: // other float |
408 case EVR_OW: // other word | 408 case EVR_OW: // other word |
409 case EVR_UN: // unknown value representation | 409 case EVR_UN: // unknown value representation |
410 { | 410 case EVR_ox: // OB or OW depending on context |
411 DicomTag tag(Convert(element.getTag())); | 411 { |
412 | 412 if (!(flags & DicomToJsonFlags_ConvertBinaryToNull)) |
413 if ((tag == DICOM_TAG_PIXEL_DATA && flags & DicomToJsonFlags_IncludePixelData) || | |
414 (tag != DICOM_TAG_PIXEL_DATA && flags & DicomToJsonFlags_IncludeBinary)) | |
415 { | 413 { |
416 Uint8* data = NULL; | 414 Uint8* data = NULL; |
417 if (element.getUint8Array(data) == EC_Normal) | 415 if (element.getUint8Array(data) == EC_Normal) |
418 { | 416 { |
419 return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true); | 417 return new DicomValue(reinterpret_cast<const char*>(data), element.getLength(), true); |
420 } | 418 } |
421 } | 419 } |
422 | 420 |
423 return new DicomValue; | 421 return new DicomValue; |
424 } | 422 } |
425 | 423 |
535 | 533 |
536 /** | 534 /** |
537 * Internal to DCMTK. | 535 * Internal to DCMTK. |
538 **/ | 536 **/ |
539 | 537 |
540 case EVR_ox: // OB or OW depending on context | |
541 case EVR_xs: // SS or US depending on context | 538 case EVR_xs: // SS or US depending on context |
542 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) | 539 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) |
543 case EVR_na: // na="not applicable", for data which has no VR | 540 case EVR_na: // na="not applicable", for data which has no VR |
544 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor | 541 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor |
545 case EVR_item: // used internally for items | 542 case EVR_item: // used internally for items |
792 { | 789 { |
793 continue; | 790 continue; |
794 } | 791 } |
795 } | 792 } |
796 | 793 |
794 DcmEVR evr = element->getTag().getEVR(); | |
795 if (evr == EVR_OB || | |
796 evr == EVR_OF || | |
797 evr == EVR_OW || | |
798 evr == EVR_UN || | |
799 evr == EVR_ox) | |
800 { | |
801 // This is a binary tag | |
802 DicomTag tag(FromDcmtkBridge::Convert(element->getTag())); | |
803 | |
804 if ((tag == DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludePixelData)) || | |
805 (tag != DICOM_TAG_PIXEL_DATA && !(flags & DicomToJsonFlags_IncludeBinary))) | |
806 { | |
807 continue; | |
808 } | |
809 } | |
810 | |
797 FromDcmtkBridge::ToJson(parent, *element, format, flags, maxStringLength, encoding); | 811 FromDcmtkBridge::ToJson(parent, *element, format, flags, maxStringLength, encoding); |
798 } | 812 } |
799 } | 813 } |
800 | 814 |
801 | 815 |
1059 } | 1073 } |
1060 | 1074 |
1061 | 1075 |
1062 static bool IsBinaryTag(const DcmTag& key) | 1076 static bool IsBinaryTag(const DcmTag& key) |
1063 { | 1077 { |
1064 return key.isPrivate() || key.isUnknownVR(); | 1078 return (key.isPrivate() || |
1079 key.isUnknownVR() || | |
1080 key.getEVR() == EVR_OB || | |
1081 key.getEVR() == EVR_OF || | |
1082 key.getEVR() == EVR_OW || | |
1083 key.getEVR() == EVR_UN || | |
1084 key.getEVR() == EVR_ox); | |
1065 } | 1085 } |
1066 | 1086 |
1067 | 1087 |
1068 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag) | 1088 DcmElement* FromDcmtkBridge::CreateElementForTag(const DicomTag& tag) |
1069 { | 1089 { |
1077 switch (key.getEVR()) | 1097 switch (key.getEVR()) |
1078 { | 1098 { |
1079 // http://support.dcmtk.org/docs/dcvr_8h-source.html | 1099 // http://support.dcmtk.org/docs/dcvr_8h-source.html |
1080 | 1100 |
1081 /** | 1101 /** |
1082 * TODO. | 1102 * Binary types, handled above |
1083 **/ | 1103 **/ |
1084 | 1104 |
1085 case EVR_OB: // other byte | 1105 case EVR_OB: // other byte |
1086 case EVR_OF: // other float | 1106 case EVR_OF: // other float |
1087 case EVR_OW: // other word | 1107 case EVR_OW: // other word |
1088 case EVR_AT: // attribute tag | |
1089 throw OrthancException(ErrorCode_NotImplemented); | |
1090 | |
1091 case EVR_UN: // unknown value representation | 1108 case EVR_UN: // unknown value representation |
1092 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1109 case EVR_ox: // OB or OW depending on context |
1110 throw OrthancException(ErrorCode_InternalError); | |
1093 | 1111 |
1094 | 1112 |
1095 /** | 1113 /** |
1096 * String types. | 1114 * String types. |
1097 * http://support.dcmtk.org/docs/classDcmByteString.html | 1115 * http://support.dcmtk.org/docs/classDcmByteString.html |
1173 case EVR_SQ: // sequence of items | 1191 case EVR_SQ: // sequence of items |
1174 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1192 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1175 | 1193 |
1176 | 1194 |
1177 /** | 1195 /** |
1196 * TODO | |
1197 **/ | |
1198 | |
1199 case EVR_AT: // attribute tag | |
1200 throw OrthancException(ErrorCode_NotImplemented); | |
1201 | |
1202 | |
1203 /** | |
1178 * Internal to DCMTK. | 1204 * Internal to DCMTK. |
1179 **/ | 1205 **/ |
1180 | 1206 |
1181 case EVR_ox: // OB or OW depending on context | |
1182 case EVR_xs: // SS or US depending on context | 1207 case EVR_xs: // SS or US depending on context |
1183 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) | 1208 case EVR_lt: // US, SS or OW depending on context, used for LUT Data (thus the name) |
1184 case EVR_na: // na="not applicable", for data which has no VR | 1209 case EVR_na: // na="not applicable", for data which has no VR |
1185 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor | 1210 case EVR_up: // up="unsigned pointer", used internally for DICOMDIR suppor |
1186 case EVR_item: // used internally for items | 1211 case EVR_item: // used internally for items |