Mercurial > hg > orthanc-webviewer
comparison Plugin/SeriesInformationAdapter.cpp @ 99:46ec13a1177c refactoring
use of ordered-slices
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2015 21:39:41 +0100 |
parents | abdde1dfb3eb |
children | f5b1a9267da0 |
comparison
equal
deleted
inserted
replaced
98:745cc19aa32b | 99:46ec13a1177c |
---|---|
23 #include "ViewerToolbox.h" | 23 #include "ViewerToolbox.h" |
24 #include "SeriesVolumeSorter.h" | 24 #include "SeriesVolumeSorter.h" |
25 | 25 |
26 #include "../Orthanc/Core/OrthancException.h" | 26 #include "../Orthanc/Core/OrthancException.h" |
27 | 27 |
28 #include <boost/regex.hpp> | |
29 | |
28 namespace OrthancPlugins | 30 namespace OrthancPlugins |
29 { | 31 { |
30 bool SeriesInformationAdapter::Create(std::string& content, | 32 bool SeriesInformationAdapter::Create(std::string& content, |
31 const std::string& seriesId) | 33 const std::string& seriesId) |
32 { | 34 { |
33 std::string message = "Ordering instances of series: " + seriesId; | 35 std::string message = "Ordering instances of series: " + seriesId; |
34 OrthancPluginLogInfo(context_, message.c_str()); | 36 OrthancPluginLogInfo(context_, message.c_str()); |
35 | 37 |
36 Json::Value series, study, patient; | 38 Json::Value series, study, patient, ordered; |
37 if (!GetJsonFromOrthanc(series, context_, "/series/" + seriesId) || | 39 if (!GetJsonFromOrthanc(series, context_, "/series/" + seriesId) || |
38 !GetJsonFromOrthanc(study, context_, "/studies/" + series["ID"].asString() + "/module?simplify") || | 40 !GetJsonFromOrthanc(study, context_, "/studies/" + series["ID"].asString() + "/module?simplify") || |
39 !GetJsonFromOrthanc(patient, context_, "/studies/" + series["ID"].asString() + "/module-patient?simplify") || | 41 !GetJsonFromOrthanc(patient, context_, "/studies/" + series["ID"].asString() + "/module-patient?simplify") || |
42 !GetJsonFromOrthanc(ordered, context_, "/series/" + series["ID"].asString() + "/ordered-slices") || | |
40 !series.isMember("Instances") || | 43 !series.isMember("Instances") || |
41 series["Instances"].type() != Json::arrayValue) | 44 series["Instances"].type() != Json::arrayValue) |
42 { | 45 { |
43 return false; | 46 return false; |
44 } | 47 } |
47 result["ID"] = seriesId; | 50 result["ID"] = seriesId; |
48 result["SeriesDescription"] = series["MainDicomTags"]["SeriesDescription"].asString(); | 51 result["SeriesDescription"] = series["MainDicomTags"]["SeriesDescription"].asString(); |
49 result["StudyDescription"] = study["StudyDescription"].asString(); | 52 result["StudyDescription"] = study["StudyDescription"].asString(); |
50 result["PatientID"] = patient["PatientID"].asString(); | 53 result["PatientID"] = patient["PatientID"].asString(); |
51 result["PatientName"] = patient["PatientName"].asString(); | 54 result["PatientName"] = patient["PatientName"].asString(); |
55 result["Type"] = ordered["Type"]; | |
56 result["Slices"] = ordered["Slices"]; | |
57 | |
58 boost::regex pattern("^/instances/([a-f0-9-]+)/frames/([0-9]+)$"); | |
59 | |
60 for (Json::Value::ArrayIndex i = 0; i < result["Slices"].size(); i++) | |
61 { | |
62 boost::cmatch what; | |
63 if (regex_match(result["Slices"][i].asCString(), what, pattern)) | |
64 { | |
65 result["Slices"][i] = std::string(what[1]) + "_" + std::string(what[2]); | |
66 } | |
67 else | |
68 { | |
69 return false; | |
70 } | |
71 } | |
72 | |
73 #if 0 | |
52 result["SortedInstances"] = Json::arrayValue; | 74 result["SortedInstances"] = Json::arrayValue; |
53 | 75 |
54 SeriesVolumeSorter sorter; | 76 SeriesVolumeSorter sorter; |
55 sorter.Reserve(series["Instances"].size()); | 77 sorter.Reserve(series["Instances"].size()); |
56 | 78 |
72 for (size_t i = 0; i < sorter.GetSize(); i++) | 94 for (size_t i = 0; i < sorter.GetSize(); i++) |
73 { | 95 { |
74 result["SortedInstances"].append(sorter.GetInstance(i)); | 96 result["SortedInstances"].append(sorter.GetInstance(i)); |
75 } | 97 } |
76 | 98 |
99 std::cout << result.toStyledString(); | |
100 | |
101 #endif | |
102 | |
77 content = result.toStyledString(); | 103 content = result.toStyledString(); |
78 | 104 |
79 return true; | 105 return true; |
80 } | 106 } |
81 } | 107 } |