diff 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
line wrap: on
line diff
--- a/Plugin/SeriesInformationAdapter.cpp	Fri Nov 27 18:30:46 2015 +0100
+++ b/Plugin/SeriesInformationAdapter.cpp	Fri Nov 27 21:39:41 2015 +0100
@@ -25,6 +25,8 @@
 
 #include "../Orthanc/Core/OrthancException.h"
 
+#include <boost/regex.hpp>
+
 namespace OrthancPlugins
 {
   bool SeriesInformationAdapter::Create(std::string& content,
@@ -33,10 +35,11 @@
     std::string message = "Ordering instances of series: " + seriesId;
     OrthancPluginLogInfo(context_, message.c_str());
 
-    Json::Value series, study, patient;
+    Json::Value series, study, patient, ordered;
     if (!GetJsonFromOrthanc(series, context_, "/series/" + seriesId) ||
         !GetJsonFromOrthanc(study, context_, "/studies/" + series["ID"].asString() + "/module?simplify") ||
         !GetJsonFromOrthanc(patient, context_, "/studies/" + series["ID"].asString() + "/module-patient?simplify") ||
+        !GetJsonFromOrthanc(ordered, context_, "/series/" + series["ID"].asString() + "/ordered-slices") ||
         !series.isMember("Instances") ||
         series["Instances"].type() != Json::arrayValue)
     {
@@ -49,6 +52,25 @@
     result["StudyDescription"] = study["StudyDescription"].asString();
     result["PatientID"] = patient["PatientID"].asString();
     result["PatientName"] = patient["PatientName"].asString();
+    result["Type"] = ordered["Type"];
+    result["Slices"] = ordered["Slices"];
+
+    boost::regex pattern("^/instances/([a-f0-9-]+)/frames/([0-9]+)$");
+
+    for (Json::Value::ArrayIndex i = 0; i < result["Slices"].size(); i++)
+    {
+      boost::cmatch what;
+      if (regex_match(result["Slices"][i].asCString(), what, pattern))
+      {
+        result["Slices"][i] = std::string(what[1]) + "_" + std::string(what[2]);
+      }
+      else
+      {
+        return false;
+      }
+    }
+
+#if 0
     result["SortedInstances"] = Json::arrayValue;
 
     SeriesVolumeSorter sorter;
@@ -74,6 +96,10 @@
       result["SortedInstances"].append(sorter.GetInstance(i));
     }
 
+    std::cout << result.toStyledString();
+
+#endif
+
     content = result.toStyledString();
 
     return true;