comparison OrthancCppClient/Instance.cpp @ 540:eaca3d38b2aa laaw

many fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 12 Sep 2013 12:55:07 +0200
parents 50d9660f960c
children 2d0a347e8cfc
comparison
equal deleted inserted replaced
537:2890721b0f57 540:eaca3d38b2aa
77 reader_.reset(new Orthanc::PngReader); 77 reader_.reset(new Orthanc::PngReader);
78 reader_->ReadFromMemory(png); 78 reader_->ReadFromMemory(png);
79 } 79 }
80 } 80 }
81 81
82 void Instance::DownloadDicom()
83 {
84 if (dicom_.get() == NULL)
85 {
86 Orthanc::HttpClient client(connection_.GetHttpClient());
87 client.SetUrl(std::string(connection_.GetOrthancUrl()) + "/instances/" + id_ + "/file");
88
89 dicom_.reset(new std::string);
90
91 if (!client.Apply(*dicom_))
92 {
93 throw OrthancClientException(Orthanc::ErrorCode_NetworkProtocol);
94 }
95 }
96 }
97
82 Instance::Instance(const OrthancConnection& connection, 98 Instance::Instance(const OrthancConnection& connection,
83 const char* id) : 99 const char* id) :
84 connection_(connection), 100 connection_(connection),
85 id_(id), 101 id_(id),
86 mode_(Orthanc::ImageExtractionMode_Int16) 102 mode_(Orthanc::ImageExtractionMode_Int16)
172 } 188 }
173 189
174 void Instance::DiscardImage() 190 void Instance::DiscardImage()
175 { 191 {
176 reader_.reset(); 192 reader_.reset();
193 }
194
195 void Instance::DiscardDicom()
196 {
197 dicom_.reset();
177 } 198 }
178 199
179 200
180 void Instance::SetImageExtractionMode(Orthanc::ImageExtractionMode mode) 201 void Instance::SetImageExtractionMode(Orthanc::ImageExtractionMode mode)
181 { 202 {
218 { 239 {
219 // Unable to parse the Image Orientation Patient. 240 // Unable to parse the Image Orientation Patient.
220 throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat); 241 throw OrthancClientException(Orthanc::ErrorCode_BadFileFormat);
221 } 242 }
222 } 243 }
244
245
246 const uint64_t Instance::GetDicomSize()
247 {
248 DownloadDicom();
249 assert(dicom_.get() != NULL);
250 return dicom_->size();
251 }
252
253 const void* Instance::GetDicom()
254 {
255 DownloadDicom();
256 assert(dicom_.get() != NULL);
257
258 if (dicom_->size() == 0)
259 {
260 return NULL;
261 }
262 else
263 {
264 return &((*dicom_) [0]);
265 }
266 }
267
223 } 268 }