comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 2124:2b1520efa282

cleaning up
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Nov 2016 12:11:34 +0100
parents 2ecc95a239f7
children bfa92c9328d7
comparison
equal deleted inserted replaced
2123:1cf093cbdad8 2124:2b1520efa282
185 ServerContext& context = OrthancRestApi::GetContext(call); 185 ServerContext& context = OrthancRestApi::GetContext(call);
186 186
187 std::string publicId = call.GetUriComponent("id", ""); 187 std::string publicId = call.GetUriComponent("id", "");
188 188
189 std::string dicom; 189 std::string dicom;
190 context.ReadFile(dicom, publicId, FileContentType_Dicom); 190 context.ReadDicom(dicom, publicId);
191 191
192 std::string target; 192 std::string target;
193 call.BodyToString(target); 193 call.BodyToString(target);
194 Toolbox::WriteFile(dicom, target); 194 Toolbox::WriteFile(dicom, target);
195 195
205 std::string publicId = call.GetUriComponent("id", ""); 205 std::string publicId = call.GetUriComponent("id", "");
206 206
207 if (simplify) 207 if (simplify)
208 { 208 {
209 Json::Value full; 209 Json::Value full;
210 context.ReadJson(full, publicId); 210 context.ReadDicomAsJson(full, publicId);
211 211
212 Json::Value simplified; 212 Json::Value simplified;
213 ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human); 213 ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human);
214 call.GetOutput().AnswerJson(simplified); 214 call.GetOutput().AnswerJson(simplified);
215 } 215 }
378 #if ORTHANC_PLUGINS_ENABLED == 1 378 #if ORTHANC_PLUGINS_ENABLED == 1
379 if (context.GetPlugins().HasCustomImageDecoder()) 379 if (context.GetPlugins().HasCustomImageDecoder())
380 { 380 {
381 // TODO create a cache of file 381 // TODO create a cache of file
382 std::string dicomContent; 382 std::string dicomContent;
383 context.ReadFile(dicomContent, publicId, FileContentType_Dicom); 383 context.ReadDicom(dicomContent, publicId);
384 decoded.reset(context.GetPlugins().DecodeUnsafe(dicomContent.c_str(), dicomContent.size(), frame)); 384 decoded.reset(context.GetPlugins().DecodeUnsafe(dicomContent.c_str(), dicomContent.size(), frame));
385 385
386 /** 386 /**
387 * Note that we call "DecodeUnsafe()": We do not fallback to 387 * Note that we call "DecodeUnsafe()": We do not fallback to
388 * the builtin decoder if no installed decoder plugin is able 388 * the builtin decoder if no installed decoder plugin is able
448 return; 448 return;
449 } 449 }
450 450
451 std::string publicId = call.GetUriComponent("id", ""); 451 std::string publicId = call.GetUriComponent("id", "");
452 std::string dicomContent; 452 std::string dicomContent;
453 context.ReadFile(dicomContent, publicId, FileContentType_Dicom); 453 context.ReadDicom(dicomContent, publicId);
454 454
455 #if ORTHANC_PLUGINS_ENABLED == 1 455 #if ORTHANC_PLUGINS_ENABLED == 1
456 IDicomImageDecoder& decoder = context.GetPlugins(); 456 IDicomImageDecoder& decoder = context.GetPlugins();
457 #else 457 #else
458 DefaultDicomImageDecoder decoder; // This is Orthanc's built-in decoder 458 DefaultDicomImageDecoder decoder; // This is Orthanc's built-in decoder
869 // Get the tags of the current instance, in the simplified format 869 // Get the tags of the current instance, in the simplified format
870 Json::Value tags; 870 Json::Value tags;
871 871
872 try 872 try
873 { 873 {
874 context.ReadJson(tags, *it); 874 context.ReadDicomAsJson(tags, *it);
875 } 875 }
876 catch (OrthancException&) 876 catch (OrthancException&)
877 { 877 {
878 // Race condition: This instance has been removed since 878 // Race condition: This instance has been removed since
879 // (*). Ignore this instance. 879 // (*). Ignore this instance.
987 987
988 // Select one child instance 988 // Select one child instance
989 publicId = instances.front(); 989 publicId = instances.front();
990 } 990 }
991 991
992 context.ReadJson(tags, publicId); 992 context.ReadDicomAsJson(tags, publicId);
993 993
994 // Filter the tags of the instance according to the module 994 // Filter the tags of the instance according to the module
995 Json::Value result = Json::objectValue; 995 Json::Value result = Json::objectValue;
996 for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); ++tag) 996 for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); ++tag)
997 { 997 {
1204 1204
1205 for (Instances::const_iterator it = instances.begin(); 1205 for (Instances::const_iterator it = instances.begin();
1206 it != instances.end(); ++it) 1206 it != instances.end(); ++it)
1207 { 1207 {
1208 Json::Value full; 1208 Json::Value full;
1209 context.ReadJson(full, *it); 1209 context.ReadDicomAsJson(full, *it);
1210 1210
1211 if (simplify) 1211 if (simplify)
1212 { 1212 {
1213 Json::Value simplified; 1213 Json::Value simplified;
1214 ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human); 1214 ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human);
1293 1293
1294 std::string publicId = call.GetUriComponent("id", ""); 1294 std::string publicId = call.GetUriComponent("id", "");
1295 bool simplify = call.HasArgument("simplify"); 1295 bool simplify = call.HasArgument("simplify");
1296 1296
1297 std::string dicomContent; 1297 std::string dicomContent;
1298 context.ReadFile(dicomContent, publicId, FileContentType_Dicom); 1298 context.ReadDicom(dicomContent, publicId);
1299 1299
1300 // TODO Consider using "DicomMap::ParseDicomMetaInformation()" to 1300 // TODO Consider using "DicomMap::ParseDicomMetaInformation()" to
1301 // speed up things here 1301 // speed up things here
1302 1302
1303 ParsedDicomFile dicom(dicomContent); 1303 ParsedDicomFile dicom(dicomContent);