Mercurial > hg > orthanc-stone
comparison Framework/dev.h @ 714:d2c0e347ddc2
deprecating DicomFrameConverter
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 May 2019 16:26:34 +0200 |
parents | 7719eb852dd5 |
children | 4f2416d519b4 |
comparison
equal
deleted
inserted
replaced
713:e63c8b9b7b02 | 714:d2c0e347ddc2 |
---|---|
62 loader_.ScheduleLoadSliceImage(slice, SliceImageQuality_Jpeg90); | 62 loader_.ScheduleLoadSliceImage(slice, SliceImageQuality_Jpeg90); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 static bool IsCompatible(const Slice& a, | 67 static bool IsCompatible(const Deprecated::Slice& a, |
68 const Slice& b) | 68 const Deprecated::Slice& b) |
69 { | 69 { |
70 if (!GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(), | 70 if (!GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(), |
71 b.GetGeometry().GetNormal())) | 71 b.GetGeometry().GetNormal())) |
72 { | 72 { |
73 LOG(ERROR) << "A slice in the volume image is not parallel to the others."; | 73 LOG(ERROR) << "A slice in the volume image is not parallel to the others."; |
96 | 96 |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 static double GetDistance(const Slice& a, | 101 static double GetDistance(const Deprecated::Slice& a, |
102 const Slice& b) | 102 const Deprecated::Slice& b) |
103 { | 103 { |
104 return fabs(a.GetGeometry().ProjectAlongNormal(a.GetGeometry().GetOrigin()) - | 104 return fabs(a.GetGeometry().ProjectAlongNormal(a.GetGeometry().GetOrigin()) - |
105 a.GetGeometry().ProjectAlongNormal(b.GetGeometry().GetOrigin())); | 105 a.GetGeometry().ProjectAlongNormal(b.GetGeometry().GetOrigin())); |
106 } | 106 } |
107 | 107 |
266 virtual size_t GetSlicesCount() const | 266 virtual size_t GetSlicesCount() const |
267 { | 267 { |
268 return loader_.GetSlicesCount(); | 268 return loader_.GetSlicesCount(); |
269 } | 269 } |
270 | 270 |
271 virtual const Slice& GetSlice(size_t index) const | 271 virtual const Deprecated::Slice& GetSlice(size_t index) const |
272 { | 272 { |
273 return loader_.GetSlice(index); | 273 return loader_.GetSlice(index); |
274 } | 274 } |
275 | 275 |
276 ImageBuffer3D& GetImage() const | 276 ImageBuffer3D& GetImage() const |
285 return *image_; | 285 return *image_; |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 bool FitWindowingToRange(RenderStyle& style, | 289 bool FitWindowingToRange(RenderStyle& style, |
290 const DicomFrameConverter& converter) const | 290 const Deprecated::DicomFrameConverter& converter) const |
291 { | 291 { |
292 if (image_.get() == NULL) | 292 if (image_.get() == NULL) |
293 { | 293 { |
294 return false; | 294 return false; |
295 } | 295 } |
309 size_t depth_; | 309 size_t depth_; |
310 double pixelSpacingX_; | 310 double pixelSpacingX_; |
311 double pixelSpacingY_; | 311 double pixelSpacingY_; |
312 double sliceThickness_; | 312 double sliceThickness_; |
313 CoordinateSystem3D reference_; | 313 CoordinateSystem3D reference_; |
314 DicomFrameConverter converter_; | 314 Deprecated::DicomFrameConverter converter_; |
315 | 315 |
316 double ComputeAxialThickness(const OrthancVolumeImage& volume) const | 316 double ComputeAxialThickness(const OrthancVolumeImage& volume) const |
317 { | 317 { |
318 double thickness; | 318 double thickness; |
319 | 319 |
320 size_t n = volume.GetSlicesCount(); | 320 size_t n = volume.GetSlicesCount(); |
321 if (n > 1) | 321 if (n > 1) |
322 { | 322 { |
323 const Slice& a = volume.GetSlice(0); | 323 const Deprecated::Slice& a = volume.GetSlice(0); |
324 const Slice& b = volume.GetSlice(n - 1); | 324 const Deprecated::Slice& b = volume.GetSlice(n - 1); |
325 thickness = ((reference_.ProjectAlongNormal(b.GetGeometry().GetOrigin()) - | 325 thickness = ((reference_.ProjectAlongNormal(b.GetGeometry().GetOrigin()) - |
326 reference_.ProjectAlongNormal(a.GetGeometry().GetOrigin())) / | 326 reference_.ProjectAlongNormal(a.GetGeometry().GetOrigin())) / |
327 (static_cast<double>(n) - 1.0)); | 327 (static_cast<double>(n) - 1.0)); |
328 } | 328 } |
329 else | 329 else |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 void SetupAxial(const OrthancVolumeImage& volume) | 346 void SetupAxial(const OrthancVolumeImage& volume) |
347 { | 347 { |
348 const Slice& axial = volume.GetSlice(0); | 348 const Deprecated::Slice& axial = volume.GetSlice(0); |
349 | 349 |
350 width_ = axial.GetWidth(); | 350 width_ = axial.GetWidth(); |
351 height_ = axial.GetHeight(); | 351 height_ = axial.GetHeight(); |
352 depth_ = volume.GetSlicesCount(); | 352 depth_ = volume.GetSlicesCount(); |
353 | 353 |
358 reference_ = axial.GetGeometry(); | 358 reference_ = axial.GetGeometry(); |
359 } | 359 } |
360 | 360 |
361 void SetupCoronal(const OrthancVolumeImage& volume) | 361 void SetupCoronal(const OrthancVolumeImage& volume) |
362 { | 362 { |
363 const Slice& axial = volume.GetSlice(0); | 363 const Deprecated::Slice& axial = volume.GetSlice(0); |
364 double axialThickness = ComputeAxialThickness(volume); | 364 double axialThickness = ComputeAxialThickness(volume); |
365 | 365 |
366 width_ = axial.GetWidth(); | 366 width_ = axial.GetWidth(); |
367 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); | 367 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); |
368 depth_ = axial.GetHeight(); | 368 depth_ = axial.GetHeight(); |
380 - axial.GetGeometry().GetNormal()); | 380 - axial.GetGeometry().GetNormal()); |
381 } | 381 } |
382 | 382 |
383 void SetupSagittal(const OrthancVolumeImage& volume) | 383 void SetupSagittal(const OrthancVolumeImage& volume) |
384 { | 384 { |
385 const Slice& axial = volume.GetSlice(0); | 385 const Deprecated::Slice& axial = volume.GetSlice(0); |
386 double axialThickness = ComputeAxialThickness(volume); | 386 double axialThickness = ComputeAxialThickness(volume); |
387 | 387 |
388 width_ = axial.GetHeight(); | 388 width_ = axial.GetHeight(); |
389 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); | 389 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); |
390 depth_ = axial.GetWidth(); | 390 depth_ = axial.GetWidth(); |
468 index = static_cast<size_t>(s); | 468 index = static_cast<size_t>(s); |
469 return true; | 469 return true; |
470 } | 470 } |
471 } | 471 } |
472 | 472 |
473 Slice* GetSlice(size_t slice) const | 473 Deprecated::Slice* GetSlice(size_t slice) const |
474 { | 474 { |
475 if (slice >= depth_) | 475 if (slice >= depth_) |
476 { | 476 { |
477 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 477 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
478 } | 478 } |
481 CoordinateSystem3D origin(reference_.GetOrigin() + | 481 CoordinateSystem3D origin(reference_.GetOrigin() + |
482 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(), | 482 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(), |
483 reference_.GetAxisX(), | 483 reference_.GetAxisX(), |
484 reference_.GetAxisY()); | 484 reference_.GetAxisY()); |
485 | 485 |
486 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_, | 486 return new Deprecated::Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_, |
487 width_, height_, converter_); | 487 width_, height_, converter_); |
488 } | 488 } |
489 } | 489 } |
490 }; | 490 }; |
491 | 491 |
492 | 492 |
498 private: | 498 private: |
499 class RendererFactory : public LayerReadyMessage::IRendererFactory | 499 class RendererFactory : public LayerReadyMessage::IRendererFactory |
500 { | 500 { |
501 private: | 501 private: |
502 const Orthanc::ImageAccessor& frame_; | 502 const Orthanc::ImageAccessor& frame_; |
503 const Slice& slice_; | 503 const Deprecated::Slice& slice_; |
504 bool isFullQuality_; | 504 bool isFullQuality_; |
505 | 505 |
506 public: | 506 public: |
507 RendererFactory(const Orthanc::ImageAccessor& frame, | 507 RendererFactory(const Orthanc::ImageAccessor& frame, |
508 const Slice& slice, | 508 const Deprecated::Slice& slice, |
509 bool isFullQuality) : | 509 bool isFullQuality) : |
510 frame_(frame), | 510 frame_(frame), |
511 slice_(slice), | 511 slice_(slice), |
512 isFullQuality_(isFullQuality) | 512 isFullQuality_(isFullQuality) |
513 { | 513 { |
660 } | 660 } |
661 else | 661 else |
662 { | 662 { |
663 // As the slices of the volumic image are arranged in a box, | 663 // As the slices of the volumic image are arranged in a box, |
664 // we only consider one single reference slice (the one with index 0). | 664 // we only consider one single reference slice (the one with index 0). |
665 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0)); | 665 std::auto_ptr<Deprecated::Slice> slice(GetProjectionGeometry(projection).GetSlice(0)); |
666 slice->GetExtent(points); | 666 slice->GetExtent(points); |
667 | 667 |
668 return true; | 668 return true; |
669 } | 669 } |
670 } | 670 } |
691 | 691 |
692 // TODO Transfer ownership if non-axial, to avoid memcpy | 692 // TODO Transfer ownership if non-axial, to avoid memcpy |
693 frame.reset(Orthanc::Image::Clone(reader.GetAccessor())); | 693 frame.reset(Orthanc::Image::Clone(reader.GetAccessor())); |
694 } | 694 } |
695 | 695 |
696 std::auto_ptr<Slice> slice(geometry.GetSlice(closest)); | 696 std::auto_ptr<Deprecated::Slice> slice(geometry.GetSlice(closest)); |
697 | 697 |
698 RendererFactory factory(*frame, *slice, isFullQuality); | 698 RendererFactory factory(*frame, *slice, isFullQuality); |
699 | 699 |
700 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); | 700 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); |
701 return; | 701 return; |
856 { | 856 { |
857 if (slices_.get() != NULL) | 857 if (slices_.get() != NULL) |
858 { | 858 { |
859 slice_ = slice; | 859 slice_ = slice; |
860 | 860 |
861 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_)); | 861 std::auto_ptr<Deprecated::Slice> tmp(slices_->GetSlice(slice_)); |
862 widget_.SetSlice(tmp->GetGeometry()); | 862 widget_.SetSlice(tmp->GetGeometry()); |
863 } | 863 } |
864 } | 864 } |
865 }; | 865 }; |
866 | 866 |
915 return false; | 915 return false; |
916 } | 916 } |
917 | 917 |
918 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) | 918 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) |
919 { | 919 { |
920 Slice reference(viewportSlice, 0.001); | 920 Deprecated::Slice reference(viewportSlice, 0.001); |
921 | 921 |
922 Vector p, d; | 922 Vector p, d; |
923 | 923 |
924 const CoordinateSystem3D& slice = otherPlane_.GetSlice(); | 924 const CoordinateSystem3D& slice = otherPlane_.GetSlice(); |
925 | 925 |