comparison Samples/Sdl/Loader.cpp @ 626:cc69acccd9f8

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 May 2019 18:34:40 +0200
parents 2eeb5857eb43
children ea8322566596
comparison
equal deleted inserted replaced
625:2eeb5857eb43 626:cc69acccd9f8
610 610
611 611
612 class DicomInstanceParameters : public boost::noncopyable 612 class DicomInstanceParameters : public boost::noncopyable
613 { 613 {
614 private: 614 private:
615 Orthanc::DicomImageInformation information_; 615 Orthanc::DicomImageInformation imageInformation_;
616 OrthancStone::SopClassUid sopClassUid_; 616 OrthancStone::SopClassUid sopClassUid_;
617 double thickness_; 617 double thickness_;
618 double pixelSpacingX_; 618 double pixelSpacingX_;
619 double pixelSpacingY_; 619 double pixelSpacingY_;
620 OrthancStone::CoordinateSystem3D geometry_; 620 OrthancStone::CoordinateSystem3D geometry_;
624 double rescaleOffset_; 624 double rescaleOffset_;
625 double rescaleSlope_; 625 double rescaleSlope_;
626 bool hasDefaultWindowing_; 626 bool hasDefaultWindowing_;
627 float defaultWindowingCenter_; 627 float defaultWindowingCenter_;
628 float defaultWindowingWidth_; 628 float defaultWindowingWidth_;
629 Orthanc::PixelFormat expectedPixelFormat_;
629 630
630 void ComputeDoseOffsets(const Orthanc::DicomMap& dicom) 631 void ComputeDoseOffsets(const Orthanc::DicomMap& dicom)
631 { 632 {
632 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html 633 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part03/sect_C.8.8.3.2.html
633 634
644 } 645 }
645 } 646 }
646 } 647 }
647 648
648 if (!OrthancStone::LinearAlgebra::ParseVector(frameOffsets_, dicom, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) || 649 if (!OrthancStone::LinearAlgebra::ParseVector(frameOffsets_, dicom, Orthanc::DICOM_TAG_GRID_FRAME_OFFSET_VECTOR) ||
649 frameOffsets_.size() < information_.GetNumberOfFrames()) 650 frameOffsets_.size() < imageInformation_.GetNumberOfFrames())
650 { 651 {
651 LOG(ERROR) << "RT-DOSE: No information about the 3D location of some slice(s)"; 652 LOG(ERROR) << "RT-DOSE: No information about the 3D location of some slice(s)";
652 frameOffsets_.clear(); 653 frameOffsets_.clear();
653 } 654 }
654 else 655 else
665 } 666 }
666 } 667 }
667 668
668 public: 669 public:
669 DicomInstanceParameters(const Orthanc::DicomMap& dicom) : 670 DicomInstanceParameters(const Orthanc::DicomMap& dicom) :
670 information_(dicom) 671 imageInformation_(dicom)
671 { 672 {
672 if (information_.GetNumberOfFrames() <= 0) 673 if (imageInformation_.GetNumberOfFrames() <= 0)
673 { 674 {
674 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 675 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
675 } 676 }
676 677
677 std::string s; 678 std::string s;
701 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose) 702 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose)
702 { 703 {
703 ComputeDoseOffsets(dicom); 704 ComputeDoseOffsets(dicom);
704 } 705 }
705 706
706 isColor_ = (information_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 && 707 isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 &&
707 information_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2); 708 imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2);
708 709
709 double doseGridScaling; 710 double doseGridScaling;
710 711
711 if (dicom.ParseDouble(rescaleOffset_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) && 712 if (dicom.ParseDouble(rescaleOffset_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) &&
712 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) 713 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE))
736 } 737 }
737 else 738 else
738 { 739 {
739 hasDefaultWindowing_ = false; 740 hasDefaultWindowing_ = false;
740 } 741 }
742
743 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose)
744 {
745 switch (imageInformation_.GetBitsStored())
746 {
747 case 16:
748 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16;
749 break;
750
751 case 32:
752 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32;
753 break;
754
755 default:
756 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
757 }
758 }
759 else if (isColor_)
760 {
761 expectedPixelFormat_ = Orthanc::PixelFormat_RGB24;
762 }
763 else if (imageInformation_.IsSigned())
764 {
765 expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16;
766 }
767 else
768 {
769 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16;
770 }
741 } 771 }
742 772
743 const Orthanc::DicomImageInformation& GetImageInformation() const 773 const Orthanc::DicomImageInformation& GetImageInformation() const
744 { 774 {
745 return information_; 775 return imageInformation_;
746 } 776 }
747 777
748 OrthancStone::SopClassUid GetSopClassUid() const 778 OrthancStone::SopClassUid GetSopClassUid() const
749 { 779 {
750 return sopClassUid_; 780 return sopClassUid_;
770 return geometry_; 800 return geometry_;
771 } 801 }
772 802
773 OrthancStone::CoordinateSystem3D GetFrameGeometry(unsigned int frame) const 803 OrthancStone::CoordinateSystem3D GetFrameGeometry(unsigned int frame) const
774 { 804 {
775 if (frame >= information_.GetNumberOfFrames()) 805 if (frame >= imageInformation_.GetNumberOfFrames())
776 { 806 {
777 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 807 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
778 } 808 }
779 809
780 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose) 810 if (sopClassUid_ == OrthancStone::SopClassUid_RTDose)
792 } 822 }
793 823
794 bool FrameContainsPlane(unsigned int frame, 824 bool FrameContainsPlane(unsigned int frame,
795 const OrthancStone::CoordinateSystem3D& plane) const 825 const OrthancStone::CoordinateSystem3D& plane) const
796 { 826 {
797 if (frame >= information_.GetNumberOfFrames()) 827 if (frame >= imageInformation_.GetNumberOfFrames())
798 { 828 {
799 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 829 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
800 } 830 }
801 831
802 OrthancStone::CoordinateSystem3D tmp = geometry_; 832 OrthancStone::CoordinateSystem3D tmp = geometry_;
874 } 904 }
875 else 905 else
876 { 906 {
877 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 907 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
878 } 908 }
909 }
910
911 Orthanc::PixelFormat GetExpectedPixelFormat() const
912 {
913 return expectedPixelFormat_;
879 } 914 }
880 }; 915 };
881 916
882 917
883 class AxialVolumeOrthancLoader : public OrthancStone::IObserver 918 class AxialVolumeOrthancLoader : public OrthancStone::IObserver