Mercurial > hg > orthanc-webviewer
comparison Orthanc/Core/Enumerations.cpp @ 133:3251ec958a29
Option "RestrictTransferSyntaxes" saying which transfer syntaxes should be decoded with GDCM
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Jun 2016 17:04:58 +0200 |
parents | 2c73a785c08e |
children | d850500b8ca6 |
comparison
equal
deleted
inserted
replaced
132:2fffa4d0f313 | 133:3251ec958a29 |
---|---|
33 #include "PrecompiledHeaders.h" | 33 #include "PrecompiledHeaders.h" |
34 #include "Enumerations.h" | 34 #include "Enumerations.h" |
35 | 35 |
36 #include "OrthancException.h" | 36 #include "OrthancException.h" |
37 #include "Toolbox.h" | 37 #include "Toolbox.h" |
38 #include "Logging.h" | |
38 | 39 |
39 #include <string.h> | 40 #include <string.h> |
40 #include <cassert> | 41 #include <cassert> |
41 | 42 |
42 namespace Orthanc | 43 namespace Orthanc |
894 return LogLevel_Trace; | 895 return LogLevel_Trace; |
895 } | 896 } |
896 else | 897 else |
897 { | 898 { |
898 throw OrthancException(ErrorCode_InternalError); | 899 throw OrthancException(ErrorCode_InternalError); |
900 } | |
901 } | |
902 | |
903 | |
904 ValueRepresentation StringToValueRepresentation(const std::string& vr, | |
905 bool throwIfUnsupported) | |
906 { | |
907 if (vr == "AE") | |
908 { | |
909 return ValueRepresentation_ApplicationEntity; | |
910 } | |
911 else if (vr == "AS") | |
912 { | |
913 return ValueRepresentation_AgeString; | |
914 } | |
915 else if (vr == "AT") | |
916 { | |
917 return ValueRepresentation_AttributeTag; | |
918 } | |
919 else if (vr == "CS") | |
920 { | |
921 return ValueRepresentation_CodeString; | |
922 } | |
923 else if (vr == "DA") | |
924 { | |
925 return ValueRepresentation_Date; | |
926 } | |
927 else if (vr == "DS") | |
928 { | |
929 return ValueRepresentation_DecimalString; | |
930 } | |
931 else if (vr == "DT") | |
932 { | |
933 return ValueRepresentation_DateTime; | |
934 } | |
935 else if (vr == "FL") | |
936 { | |
937 return ValueRepresentation_FloatingPointSingle; | |
938 } | |
939 else if (vr == "FD") | |
940 { | |
941 return ValueRepresentation_FloatingPointDouble; | |
942 } | |
943 else if (vr == "IS") | |
944 { | |
945 return ValueRepresentation_IntegerString; | |
946 } | |
947 else if (vr == "LO") | |
948 { | |
949 return ValueRepresentation_LongString; | |
950 } | |
951 else if (vr == "LT") | |
952 { | |
953 return ValueRepresentation_LongText; | |
954 } | |
955 else if (vr == "OB") | |
956 { | |
957 return ValueRepresentation_OtherByte; | |
958 } | |
959 else if (vr == "OD") | |
960 { | |
961 return ValueRepresentation_OtherDouble; | |
962 } | |
963 else if (vr == "OF") | |
964 { | |
965 return ValueRepresentation_OtherFloat; | |
966 } | |
967 else if (vr == "OL") | |
968 { | |
969 return ValueRepresentation_OtherLong; | |
970 } | |
971 else if (vr == "OW") | |
972 { | |
973 return ValueRepresentation_OtherWord; | |
974 } | |
975 else if (vr == "PN") | |
976 { | |
977 return ValueRepresentation_PersonName; | |
978 } | |
979 else if (vr == "SH") | |
980 { | |
981 return ValueRepresentation_ShortString; | |
982 } | |
983 else if (vr == "SL") | |
984 { | |
985 return ValueRepresentation_SignedLong; | |
986 } | |
987 else if (vr == "SQ") | |
988 { | |
989 return ValueRepresentation_Sequence; | |
990 } | |
991 else if (vr == "SS") | |
992 { | |
993 return ValueRepresentation_SignedShort; | |
994 } | |
995 else if (vr == "ST") | |
996 { | |
997 return ValueRepresentation_ShortText; | |
998 } | |
999 else if (vr == "TM") | |
1000 { | |
1001 return ValueRepresentation_Time; | |
1002 } | |
1003 else if (vr == "UC") | |
1004 { | |
1005 return ValueRepresentation_UnlimitedCharacters; | |
1006 } | |
1007 else if (vr == "UI") | |
1008 { | |
1009 return ValueRepresentation_UniqueIdentifier; | |
1010 } | |
1011 else if (vr == "UL") | |
1012 { | |
1013 return ValueRepresentation_UnsignedLong; | |
1014 } | |
1015 else if (vr == "UN") | |
1016 { | |
1017 return ValueRepresentation_Unknown; | |
1018 } | |
1019 else if (vr == "UR") | |
1020 { | |
1021 return ValueRepresentation_UniversalResource; | |
1022 } | |
1023 else if (vr == "US") | |
1024 { | |
1025 return ValueRepresentation_UnsignedShort; | |
1026 } | |
1027 else if (vr == "UT") | |
1028 { | |
1029 return ValueRepresentation_UnlimitedText; | |
1030 } | |
1031 else | |
1032 { | |
1033 std::string s = "Unsupported value representation encountered: " + vr; | |
1034 | |
1035 if (throwIfUnsupported) | |
1036 { | |
1037 LOG(ERROR) << s; | |
1038 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1039 } | |
1040 else | |
1041 { | |
1042 LOG(INFO) << s; | |
1043 return ValueRepresentation_NotSupported; | |
1044 } | |
899 } | 1045 } |
900 } | 1046 } |
901 | 1047 |
902 | 1048 |
903 unsigned int GetBytesPerPixel(PixelFormat format) | 1049 unsigned int GetBytesPerPixel(PixelFormat format) |
1185 bool IsUserContentType(FileContentType type) | 1331 bool IsUserContentType(FileContentType type) |
1186 { | 1332 { |
1187 return (type >= FileContentType_StartUser && | 1333 return (type >= FileContentType_StartUser && |
1188 type <= FileContentType_EndUser); | 1334 type <= FileContentType_EndUser); |
1189 } | 1335 } |
1336 | |
1337 | |
1338 bool IsBinaryValueRepresentation(ValueRepresentation vr) | |
1339 { | |
1340 // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html | |
1341 | |
1342 switch (vr) | |
1343 { | |
1344 case ValueRepresentation_ApplicationEntity: // AE | |
1345 case ValueRepresentation_AgeString: // AS | |
1346 case ValueRepresentation_CodeString: // CS | |
1347 case ValueRepresentation_Date: // DA | |
1348 case ValueRepresentation_DecimalString: // DS | |
1349 case ValueRepresentation_DateTime: // DT | |
1350 case ValueRepresentation_IntegerString: // IS | |
1351 case ValueRepresentation_LongString: // LO | |
1352 case ValueRepresentation_LongText: // LT | |
1353 case ValueRepresentation_PersonName: // PN | |
1354 case ValueRepresentation_ShortString: // SH | |
1355 case ValueRepresentation_ShortText: // ST | |
1356 case ValueRepresentation_Time: // TM | |
1357 case ValueRepresentation_UnlimitedCharacters: // UC | |
1358 case ValueRepresentation_UniqueIdentifier: // UI (UID) | |
1359 case ValueRepresentation_UniversalResource: // UR (URI or URL) | |
1360 case ValueRepresentation_UnlimitedText: // UT | |
1361 { | |
1362 return false; | |
1363 } | |
1364 | |
1365 /** | |
1366 * Below are all the VR whose character repertoire is tagged as | |
1367 * "not applicable" | |
1368 **/ | |
1369 case ValueRepresentation_AttributeTag: // AT (2 x uint16_t) | |
1370 case ValueRepresentation_FloatingPointSingle: // FL (float) | |
1371 case ValueRepresentation_FloatingPointDouble: // FD (double) | |
1372 case ValueRepresentation_OtherByte: // OB | |
1373 case ValueRepresentation_OtherDouble: // OD | |
1374 case ValueRepresentation_OtherFloat: // OF | |
1375 case ValueRepresentation_OtherLong: // OL | |
1376 case ValueRepresentation_OtherWord: // OW | |
1377 case ValueRepresentation_SignedLong: // SL (int32_t) | |
1378 case ValueRepresentation_Sequence: // SQ | |
1379 case ValueRepresentation_SignedShort: // SS (int16_t) | |
1380 case ValueRepresentation_UnsignedLong: // UL (uint32_t) | |
1381 case ValueRepresentation_Unknown: // UN | |
1382 case ValueRepresentation_UnsignedShort: // US (uint16_t) | |
1383 { | |
1384 return true; | |
1385 } | |
1386 | |
1387 case ValueRepresentation_NotSupported: | |
1388 default: | |
1389 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1390 } | |
1391 } | |
1190 } | 1392 } |