Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 120:063f7f3d9f14 wasm
fix 3d locations of the doses
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Oct 2017 15:51:34 +0200 |
parents | ba83e38cf3ff |
children | e66b2c757790 |
comparison
equal
deleted
inserted
replaced
119:ba83e38cf3ff | 120:063f7f3d9f14 |
---|---|
275 { | 275 { |
276 userCallback_.NotifySliceImageError | 276 userCallback_.NotifySliceImageError |
277 (*this, operation.GetSliceIndex(), operation.GetSlice(), operation.GetQuality()); | 277 (*this, operation.GetSliceIndex(), operation.GetSlice(), operation.GetQuality()); |
278 } | 278 } |
279 | 279 |
280 | |
281 void OrthancSlicesLoader::SortAndFinalizeSlices() | |
282 { | |
283 bool ok = false; | |
284 | |
285 if (slices_.GetSliceCount() > 0) | |
286 { | |
287 Vector normal; | |
288 if (slices_.SelectNormal(normal)) | |
289 { | |
290 slices_.FilterNormal(normal); | |
291 slices_.SetNormal(normal); | |
292 slices_.Sort(); | |
293 ok = true; | |
294 } | |
295 } | |
296 | |
297 state_ = State_GeometryReady; | |
298 | |
299 if (ok) | |
300 { | |
301 LOG(INFO) << "Loaded a series with " << slices_.GetSliceCount() << " slice(s)"; | |
302 userCallback_.NotifyGeometryReady(*this); | |
303 } | |
304 else | |
305 { | |
306 LOG(ERROR) << "This series is empty"; | |
307 userCallback_.NotifyGeometryError(*this); | |
308 } | |
309 } | |
310 | |
280 | 311 |
281 void OrthancSlicesLoader::ParseSeriesGeometry(const void* answer, | 312 void OrthancSlicesLoader::ParseSeriesGeometry(const void* answer, |
282 size_t size) | 313 size_t size) |
283 { | 314 { |
284 Json::Value series; | 315 Json::Value series; |
318 LOG(WARNING) << "Skipping invalid frame " << frame << " within instance " << instances[i]; | 349 LOG(WARNING) << "Skipping invalid frame " << frame << " within instance " << instances[i]; |
319 } | 350 } |
320 } | 351 } |
321 } | 352 } |
322 | 353 |
323 bool ok = false; | 354 SortAndFinalizeSlices(); |
324 | |
325 if (slices_.GetSliceCount() > 0) | |
326 { | |
327 Vector normal; | |
328 if (slices_.SelectNormal(normal)) | |
329 { | |
330 slices_.FilterNormal(normal); | |
331 slices_.SetNormal(normal); | |
332 slices_.Sort(); | |
333 ok = true; | |
334 } | |
335 } | |
336 | |
337 state_ = State_GeometryReady; | |
338 | |
339 if (ok) | |
340 { | |
341 LOG(INFO) << "Loaded a series with " << slices_.GetSliceCount() << " slice(s)"; | |
342 userCallback_.NotifyGeometryReady(*this); | |
343 } | |
344 else | |
345 { | |
346 LOG(ERROR) << "This series is empty"; | |
347 userCallback_.NotifyGeometryError(*this); | |
348 } | |
349 } | 355 } |
350 | 356 |
351 | 357 |
352 void OrthancSlicesLoader::ParseInstanceGeometry(const std::string& instanceId, | 358 void OrthancSlicesLoader::ParseInstanceGeometry(const std::string& instanceId, |
353 const void* answer, | 359 const void* answer, |
372 frames = 1; | 378 frames = 1; |
373 } | 379 } |
374 | 380 |
375 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; | 381 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; |
376 | 382 |
377 state_ = State_GeometryReady; | |
378 | |
379 for (unsigned int frame = 0; frame < frames; frame++) | 383 for (unsigned int frame = 0; frame < frames; frame++) |
380 { | 384 { |
381 std::auto_ptr<Slice> slice(new Slice); | 385 std::auto_ptr<Slice> slice(new Slice); |
382 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 386 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
383 { | 387 { |
389 userCallback_.NotifyGeometryError(*this); | 393 userCallback_.NotifyGeometryError(*this); |
390 return; | 394 return; |
391 } | 395 } |
392 } | 396 } |
393 | 397 |
394 userCallback_.NotifyGeometryReady(*this); | 398 SortAndFinalizeSlices(); |
395 } | 399 } |
396 | 400 |
397 | 401 |
398 void OrthancSlicesLoader::ParseFrameGeometry(const std::string& instanceId, | 402 void OrthancSlicesLoader::ParseFrameGeometry(const std::string& instanceId, |
399 unsigned int frame, | 403 unsigned int frame, |
669 | 673 |
670 std::auto_ptr<Orthanc::ImageAccessor> image | 674 std::auto_ptr<Orthanc::ImageAccessor> image |
671 (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), | 675 (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), |
672 info.GetHeight(), raw)); | 676 info.GetHeight(), raw)); |
673 | 677 |
678 // TODO - Only for big endian | |
674 for (unsigned int y = 0; y < image->GetHeight(); y++) | 679 for (unsigned int y = 0; y < image->GetHeight(); y++) |
675 { | 680 { |
676 uint32_t *p = reinterpret_cast<uint32_t*>(image->GetRow(y)); | 681 uint32_t *p = reinterpret_cast<uint32_t*>(image->GetRow(y)); |
677 for (unsigned int x = 0; x < image->GetWidth(); x++, p++) | 682 for (unsigned int x = 0; x < image->GetWidth(); x++, p++) |
678 { | 683 { |
679 *p = le32toh(*p); | 684 *p = le32toh(*p); |
680 } | 685 } |
681 } | 686 } |
687 | |
688 NotifySliceImageSuccess(operation, image); | |
689 } | |
690 else if (info.GetBitsAllocated() == 16 && | |
691 info.GetBitsStored() == 16 && | |
692 info.GetHighBit() == 15 && | |
693 info.GetChannelCount() == 1 && | |
694 !info.IsSigned() && | |
695 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && | |
696 raw.size() == info.GetWidth() * info.GetHeight() * 2) | |
697 { | |
698 std::auto_ptr<Orthanc::ImageAccessor> image | |
699 (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), | |
700 info.GetHeight(), raw)); | |
701 | |
702 // TODO - Big endian ? | |
682 | 703 |
683 NotifySliceImageSuccess(operation, image); | 704 NotifySliceImageSuccess(operation, image); |
684 } | 705 } |
685 else | 706 else |
686 { | 707 { |