comparison Framework/Loaders/OrthancMultiframeVolumeLoader.cpp @ 925:4639d0bf6390

Added support for Grayscale16 in the multiframe loader (Victor)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 22 Jul 2019 16:00:03 +0200
parents 81d30cd93b65
children 401808e7ff2e
comparison
equal deleted inserted replaced
922:988fa647df21 925:4639d0bf6390
125 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) 125 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
126 { 126 {
127 GetLoader<OrthancMultiframeVolumeLoader>().SetTransferSyntax(message.GetAnswer()); 127 GetLoader<OrthancMultiframeVolumeLoader>().SetTransferSyntax(message.GetAnswer());
128 } 128 }
129 }; 129 };
130 130
131
132 class OrthancMultiframeVolumeLoader::LoadUncompressedPixelData : public State 131 class OrthancMultiframeVolumeLoader::LoadUncompressedPixelData : public State
133 { 132 {
134 public: 133 public:
135 LoadUncompressedPixelData(OrthancMultiframeVolumeLoader& that) : 134 LoadUncompressedPixelData(OrthancMultiframeVolumeLoader& that) :
136 State(that) 135 State(that)
140 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) 139 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message)
141 { 140 {
142 GetLoader<OrthancMultiframeVolumeLoader>().SetUncompressedPixelData(message.GetAnswer()); 141 GetLoader<OrthancMultiframeVolumeLoader>().SetUncompressedPixelData(message.GetAnswer());
143 } 142 }
144 }; 143 };
145 144
146
147 const std::string& OrthancMultiframeVolumeLoader::GetInstanceId() const 145 const std::string& OrthancMultiframeVolumeLoader::GetInstanceId() const
148 { 146 {
149 if (IsActive()) 147 if (IsActive())
150 { 148 {
151 return instanceId_; 149 return instanceId_;
153 else 151 else
154 { 152 {
155 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 153 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
156 } 154 }
157 } 155 }
158
159 156
160 void OrthancMultiframeVolumeLoader::ScheduleFrameDownloads() 157 void OrthancMultiframeVolumeLoader::ScheduleFrameDownloads()
161 { 158 {
162 if (transferSyntaxUid_.empty() || 159 if (transferSyntaxUid_.empty() ||
163 !volume_->HasGeometry()) 160 !volume_->HasGeometry())
241 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_)); 238 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_));
242 } 239 }
243 240
244 241
245 ORTHANC_FORCE_INLINE 242 ORTHANC_FORCE_INLINE
246 static void CopyPixel(uint32_t& target, 243 static void CopyPixel(uint32_t& target, const void* source)
247 const void* source)
248 { 244 {
249 // TODO - check alignement? 245 // TODO - check alignement?
250 target = le32toh(*reinterpret_cast<const uint32_t*>(source)); 246 target = le32toh(*reinterpret_cast<const uint32_t*>(source));
251 } 247 }
252 248
249 ORTHANC_FORCE_INLINE
250 static void CopyPixel(uint16_t& target, const void* source)
251 {
252 // TODO - check alignement?
253 target = le16toh(*reinterpret_cast<const uint16_t*>(source));
254 }
253 255
254 template <typename T> 256 template <typename T>
255 void OrthancMultiframeVolumeLoader::CopyPixelData(const std::string& pixelData) 257 void OrthancMultiframeVolumeLoader::CopyPixelData(const std::string& pixelData)
256 { 258 {
257 ImageBuffer3D& target = volume_->GetPixelData(); 259 ImageBuffer3D& target = volume_->GetPixelData();
303 switch (volume_->GetPixelData().GetFormat()) 305 switch (volume_->GetPixelData().GetFormat())
304 { 306 {
305 case Orthanc::PixelFormat_Grayscale32: 307 case Orthanc::PixelFormat_Grayscale32:
306 CopyPixelData<uint32_t>(pixelData); 308 CopyPixelData<uint32_t>(pixelData);
307 break; 309 break;
308 310 case Orthanc::PixelFormat_Grayscale16:
311 CopyPixelData<uint16_t>(pixelData);
312 break;
309 default: 313 default:
310 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 314 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
311 } 315 }
312 316
313 volume_->IncrementRevision(); 317 volume_->IncrementRevision();