comparison OrthancServer/DicomIntegerPixelAccessor.cpp @ 62:a70bb32802ae orthanc-renaming

renaming Server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 16 Sep 2012 09:33:19 +0200
parents 4bc019d2f969
children b8dfde8d64e8
comparison
equal deleted inserted replaced
61:d1c511efd6b1 62:a70bb32802ae
1 /** 1 /**
2 * Palanthir - A Lightweight, RESTful DICOM Store 2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
4 * Belgium 4 * Belgium
5 * 5 *
6 * This program is free software: you can redistribute it and/or 6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
22 22
23 #ifndef NOMINMAX 23 #ifndef NOMINMAX
24 #define NOMINMAX 24 #define NOMINMAX
25 #endif 25 #endif
26 26
27 #include "../Core/PalanthirException.h" 27 #include "../Core/OrthancException.h"
28 #include "FromDcmtkBridge.h" 28 #include "FromDcmtkBridge.h"
29 #include <boost/lexical_cast.hpp> 29 #include <boost/lexical_cast.hpp>
30 #include <limits> 30 #include <limits>
31 31
32 namespace Palanthir 32 namespace Orthanc
33 { 33 {
34 DicomIntegerPixelAccessor::DicomIntegerPixelAccessor(const DicomMap& values, 34 DicomIntegerPixelAccessor::DicomIntegerPixelAccessor(const DicomMap& values,
35 const void* pixelData, 35 const void* pixelData,
36 size_t size) : 36 size_t size) :
37 pixelData_(pixelData), 37 pixelData_(pixelData),
52 highBit = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "HighBit").AsString()); 52 highBit = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "HighBit").AsString());
53 pixelRepresentation = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "PixelRepresentation").AsString()); 53 pixelRepresentation = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "PixelRepresentation").AsString());
54 } 54 }
55 catch (boost::bad_lexical_cast) 55 catch (boost::bad_lexical_cast)
56 { 56 {
57 throw PalanthirException(ErrorCode_NotImplemented); 57 throw OrthancException(ErrorCode_NotImplemented);
58 } 58 }
59 59
60 frame_ = 0; 60 frame_ = 0;
61 try 61 try
62 { 62 {
63 numberOfFrames_ = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "NumberOfFrames").AsString()); 63 numberOfFrames_ = boost::lexical_cast<unsigned int>(FromDcmtkBridge::GetValue(values, "NumberOfFrames").AsString());
64 } 64 }
65 catch (PalanthirException) 65 catch (OrthancException)
66 { 66 {
67 // If the tag "NumberOfFrames" is absent, assume there is a single frame 67 // If the tag "NumberOfFrames" is absent, assume there is a single frame
68 numberOfFrames_ = 1; 68 numberOfFrames_ = 1;
69 } 69 }
70 catch (boost::bad_lexical_cast) 70 catch (boost::bad_lexical_cast)
71 { 71 {
72 throw PalanthirException(ErrorCode_NotImplemented); 72 throw OrthancException(ErrorCode_NotImplemented);
73 } 73 }
74 74
75 if ((bitsAllocated != 8 && bitsAllocated != 16 && 75 if ((bitsAllocated != 8 && bitsAllocated != 16 &&
76 bitsAllocated != 24 && bitsAllocated != 32) || 76 bitsAllocated != 24 && bitsAllocated != 32) ||
77 numberOfFrames_ == 0) 77 numberOfFrames_ == 0)
78 { 78 {
79 throw PalanthirException(ErrorCode_NotImplemented); 79 throw OrthancException(ErrorCode_NotImplemented);
80 } 80 }
81 81
82 if (bitsAllocated > 32 || 82 if (bitsAllocated > 32 ||
83 bitsStored >= 32) 83 bitsStored >= 32)
84 { 84 {
85 // Not available, as the accessor internally uses int32_t values 85 // Not available, as the accessor internally uses int32_t values
86 throw PalanthirException(ErrorCode_NotImplemented); 86 throw OrthancException(ErrorCode_NotImplemented);
87 } 87 }
88 88
89 if (samplesPerPixel_ != 1) 89 if (samplesPerPixel_ != 1)
90 { 90 {
91 throw PalanthirException(ErrorCode_NotImplemented); 91 throw OrthancException(ErrorCode_NotImplemented);
92 } 92 }
93 93
94 if (width_ * height_ * bitsAllocated / 8 * numberOfFrames_ != size) 94 if (width_ * height_ * bitsAllocated / 8 * numberOfFrames_ != size)
95 { 95 {
96 throw PalanthirException(ErrorCode_NotImplemented); 96 throw OrthancException(ErrorCode_NotImplemented);
97 } 97 }
98 98
99 /*printf("%d %d %d %d %d %d %d %d\n", width_, height_, samplesPerPixel_, bitsAllocated, 99 /*printf("%d %d %d %d %d %d %d %d\n", width_, height_, samplesPerPixel_, bitsAllocated,
100 bitsStored, highBit, pixelRepresentation, numberOfFrames_);*/ 100 bitsStored, highBit, pixelRepresentation, numberOfFrames_);*/
101 101
163 v = (v >> shift_) & mask_; 163 v = (v >> shift_) & mask_;
164 164
165 if (v & signMask_) 165 if (v & signMask_)
166 { 166 {
167 // Signed value: Not implemented yet 167 // Signed value: Not implemented yet
168 //throw PalanthirException(ErrorCode_NotImplemented); 168 //throw OrthancException(ErrorCode_NotImplemented);
169 v = 0; 169 v = 0;
170 } 170 }
171 171
172 return v; 172 return v;
173 } 173 }
175 175
176 void DicomIntegerPixelAccessor::SetCurrentFrame(unsigned int frame) 176 void DicomIntegerPixelAccessor::SetCurrentFrame(unsigned int frame)
177 { 177 {
178 if (frame >= numberOfFrames_) 178 if (frame >= numberOfFrames_)
179 { 179 {
180 throw PalanthirException(ErrorCode_ParameterOutOfRange); 180 throw OrthancException(ErrorCode_ParameterOutOfRange);
181 } 181 }
182 182
183 frame_ = frame; 183 frame_ = frame;
184 } 184 }
185 185