comparison OrthancCppClient/Series.cpp @ 502:ee33c7d0cda0 laaw

laaw runs correctly on the c++ api
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Jul 2013 09:32:03 +0200
parents ec19da4a1fe7
children 50d9660f960c
comparison
equal deleted inserted replaced
500:ec19da4a1fe7 502:ee33c7d0cda0
172 if (GetInstanceCount() == 0) 172 if (GetInstanceCount() == 0)
173 { 173 {
174 return true; 174 return true;
175 } 175 }
176 176
177 Instance& i1 = GetInstance(0);
178
177 for (unsigned int i = 0; i < GetInstanceCount(); i++) 179 for (unsigned int i = 0; i < GetInstanceCount(); i++)
178 { 180 {
179 if (GetInstance(0).GetTagAsString("Columns") != GetInstance(i).GetTagAsString("Columns") || 181 Instance& i2 = GetInstance(1);
180 GetInstance(0).GetTagAsString("Rows") != GetInstance(i).GetTagAsString("Rows") || 182
181 GetInstance(0).GetTagAsString("ImageOrientationPatient") != GetInstance(i).GetTagAsString("ImageOrientationPatient") || 183 if (std::string(i1.GetTagAsString("Columns")) != std::string(i2.GetTagAsString("Columns")) ||
182 GetInstance(0).GetTagAsString("SliceThickness") != GetInstance(i).GetTagAsString("SliceThickness") || 184 std::string(i1.GetTagAsString("Rows")) != std::string(i2.GetTagAsString("Rows")) ||
183 GetInstance(0).GetTagAsString("PixelSpacing") != GetInstance(i).GetTagAsString("PixelSpacing")) 185 std::string(i1.GetTagAsString("ImageOrientationPatient")) != std::string(i2.GetTagAsString("ImageOrientationPatient")) ||
186 std::string(i1.GetTagAsString("SliceThickness")) != std::string(i2.GetTagAsString("SliceThickness")) ||
187 std::string(i1.GetTagAsString("PixelSpacing")) != std::string(i2.GetTagAsString("PixelSpacing")))
184 { 188 {
185 return false; 189 return false;
186 } 190 }
187 } 191 }
188 192
227 instances_(*this) 231 instances_(*this)
228 { 232 {
229 ReadSeries(); 233 ReadSeries();
230 status_ = Status3DImage_NotTested; 234 status_ = Status3DImage_NotTested;
231 url_ = std::string(connection_.GetOrthancUrl()) + "/series/" + id_; 235 url_ = std::string(connection_.GetOrthancUrl()) + "/series/" + id_;
236 isVoxelSizeRead_ = false;
232 237
233 instances_.SetThreadCount(connection.GetThreadCount()); 238 instances_.SetThreadCount(connection.GetThreadCount());
234 } 239 }
235 240
236 241
272 return 0; 277 return 0;
273 else 278 else
274 return GetInstance(0).GetTagAsInt("Rows"); 279 return GetInstance(0).GetTagAsInt("Rows");
275 } 280 }
276 281
277 void Series::GetVoxelSize(float& sizeX, float& sizeY, float& sizeZ) 282 void Series::LoadVoxelSize()
278 { 283 {
284 if (isVoxelSizeRead_)
285 {
286 return;
287 }
288
279 Check3DImage(); 289 Check3DImage();
280 290
281 if (GetInstanceCount() == 0) 291 if (GetInstanceCount() == 0)
282 { 292 {
283 sizeX = 0; 293 // Empty image, use some default value
284 sizeY = 0; 294 voxelSizeX_ = 1;
285 sizeZ = 0; 295 voxelSizeY_ = 1;
296 voxelSizeZ_ = 1;
286 } 297 }
287 else 298 else
288 { 299 {
289 try 300 try
290 { 301 {
292 size_t pos = s.find('\\'); 303 size_t pos = s.find('\\');
293 assert(pos != std::string::npos); 304 assert(pos != std::string::npos);
294 std::string sy = s.substr(0, pos); 305 std::string sy = s.substr(0, pos);
295 std::string sx = s.substr(pos + 1); 306 std::string sx = s.substr(pos + 1);
296 307
297 sizeX = boost::lexical_cast<float>(sx); 308 voxelSizeX_ = boost::lexical_cast<float>(sx);
298 sizeY = boost::lexical_cast<float>(sy); 309 voxelSizeY_ = boost::lexical_cast<float>(sy);
299 sizeZ = GetInstance(0).GetTagAsFloat("SliceThickness"); 310 voxelSizeZ_ = GetInstance(0).GetTagAsFloat("SliceThickness");
300 } 311 }
301 catch (boost::bad_lexical_cast) 312 catch (boost::bad_lexical_cast)
302 { 313 {
303 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 314 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
304 } 315 }
305 } 316 }
317
318 isVoxelSizeRead_ = true;
306 } 319 }
307 320
308 321
309 const char* Series::GetMainDicomTag(const char* tag, const char* defaultValue) const 322 const char* Series::GetMainDicomTag(const char* tag, const char* defaultValue) const
310 { 323 {
424 { 437 {
425 throw OrthancException(ErrorCode_NetworkProtocol); 438 throw OrthancException(ErrorCode_NetworkProtocol);
426 } 439 }
427 } 440 }
428 441
442 float Series::GetVoxelSizeX()
443 {
444 LoadVoxelSize();
445 return voxelSizeX_;
446 }
447
448 float Series::GetVoxelSizeY()
449 {
450 LoadVoxelSize();
451 return voxelSizeY_;
452 }
453
454 float Series::GetVoxelSizeZ()
455 {
456 LoadVoxelSize();
457 return voxelSizeZ_;
458 }
459
429 } 460 }