Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 4105:c02a2d9efbc2
move FromDcmtkBridge::ExecuteToDicom() to LuaFunctionCall, to remove dependency of DCMTK on Lua
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 06 Jul 2020 13:48:10 +0200 |
parents | d25f4c0fa160 |
children | bf7b9edf6b81 |
comparison
equal
deleted
inserted
replaced
4104:d5c09b5f882f | 4105:c02a2d9efbc2 |
---|---|
2045 } | 2045 } |
2046 } | 2046 } |
2047 } | 2047 } |
2048 | 2048 |
2049 | 2049 |
2050 #if ORTHANC_ENABLE_LUA == 1 | |
2051 void FromDcmtkBridge::ExecuteToDicom(DicomMap& target, | |
2052 LuaFunctionCall& call) | |
2053 { | |
2054 Json::Value output; | |
2055 call.ExecuteToJson(output, true /* keep strings */); | |
2056 | |
2057 target.Clear(); | |
2058 | |
2059 if (output.type() == Json::arrayValue && | |
2060 output.size() == 0) | |
2061 { | |
2062 // This case happens for empty tables | |
2063 return; | |
2064 } | |
2065 | |
2066 if (output.type() != Json::objectValue) | |
2067 { | |
2068 throw OrthancException(ErrorCode_LuaBadOutput, | |
2069 "Lua: The script must return a table"); | |
2070 } | |
2071 | |
2072 Json::Value::Members members = output.getMemberNames(); | |
2073 | |
2074 for (size_t i = 0; i < members.size(); i++) | |
2075 { | |
2076 if (output[members[i]].type() != Json::stringValue) | |
2077 { | |
2078 throw OrthancException(ErrorCode_LuaBadOutput, | |
2079 "Lua: The script must return a table " | |
2080 "mapping names of DICOM tags to strings"); | |
2081 } | |
2082 | |
2083 DicomTag tag(ParseTag(members[i])); | |
2084 target.SetValue(tag, output[members[i]].asString(), false); | |
2085 } | |
2086 } | |
2087 #endif | |
2088 | |
2089 | |
2090 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target, | 2050 void FromDcmtkBridge::ExtractDicomSummary(DicomMap& target, |
2091 DcmItem& dataset, | 2051 DcmItem& dataset, |
2092 const std::set<DicomTag>& ignoreTagLength) | 2052 const std::set<DicomTag>& ignoreTagLength) |
2093 { | 2053 { |
2094 ExtractDicomSummary(target, dataset, | 2054 ExtractDicomSummary(target, dataset, |