Mercurial > hg > orthanc-stone
comparison Framework/Volumes/ImageBuffer3D.cpp @ 87:4a541cd4fa83 wasm
OrthancVolumeImageLoader
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 May 2017 15:31:58 +0200 |
parents | 28956ed68280 |
children | e0ddd8cad909 |
comparison
equal
deleted
inserted
replaced
86:02c3a7a4938f | 87:4a541cd4fa83 |
---|---|
22 #include "ImageBuffer3D.h" | 22 #include "ImageBuffer3D.h" |
23 | 23 |
24 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h" | 24 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h" |
25 #include "../../Resources/Orthanc/Core/OrthancException.h" | 25 #include "../../Resources/Orthanc/Core/OrthancException.h" |
26 | 26 |
27 #include <string.h> | |
28 | |
27 namespace OrthancStone | 29 namespace OrthancStone |
28 { | 30 { |
29 Orthanc::ImageAccessor ImageBuffer3D::GetAxialSliceAccessor(unsigned int slice, | 31 Orthanc::ImageAccessor ImageBuffer3D::GetAxialSliceAccessor(unsigned int slice, |
30 bool readOnly) | 32 bool readOnly) |
31 { | 33 { |
120 } | 122 } |
121 | 123 |
122 | 124 |
123 void ImageBuffer3D::Clear() | 125 void ImageBuffer3D::Clear() |
124 { | 126 { |
125 WriteLock lock(mutex_); | 127 memset(image_.GetBuffer(), 0, image_.GetHeight() * image_.GetPitch()); |
126 Orthanc::ImageProcessing::Set(image_, 0); | |
127 } | 128 } |
128 | 129 |
129 | 130 |
130 void ImageBuffer3D::SetAxialGeometry(const SliceGeometry& geometry) | 131 void ImageBuffer3D::SetAxialGeometry(const SliceGeometry& geometry) |
131 { | 132 { |
132 WriteLock lock(mutex_); | |
133 axialGeometry_ = geometry; | 133 axialGeometry_ = geometry; |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 void ImageBuffer3D::SetVoxelDimensions(double x, | 137 void ImageBuffer3D::SetVoxelDimensions(double x, |
144 { | 144 { |
145 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 145 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
146 } | 146 } |
147 | 147 |
148 { | 148 { |
149 WriteLock lock(mutex_); | |
150 GeometryToolbox::AssignVector(voxelDimensions_, x, y, z); | 149 GeometryToolbox::AssignVector(voxelDimensions_, x, y, z); |
151 } | 150 } |
152 } | 151 } |
153 | 152 |
154 | 153 |
155 Vector ImageBuffer3D::GetVoxelDimensions(VolumeProjection projection) | 154 Vector ImageBuffer3D::GetVoxelDimensions(VolumeProjection projection) |
156 { | 155 { |
157 ReadLock lock(mutex_); | |
158 | |
159 Vector result; | 156 Vector result; |
160 switch (projection) | 157 switch (projection) |
161 { | 158 { |
162 case VolumeProjection_Axial: | 159 case VolumeProjection_Axial: |
163 result = voxelDimensions_; | 160 result = voxelDimensions_; |
258 } | 255 } |
259 | 256 |
260 | 257 |
261 ImageBuffer3D::SliceReader::SliceReader(ImageBuffer3D& that, | 258 ImageBuffer3D::SliceReader::SliceReader(ImageBuffer3D& that, |
262 VolumeProjection projection, | 259 VolumeProjection projection, |
263 unsigned int slice) : | 260 unsigned int slice) |
264 lock_(that.mutex_) | |
265 { | 261 { |
266 switch (projection) | 262 switch (projection) |
267 { | 263 { |
268 case VolumeProjection_Axial: | 264 case VolumeProjection_Axial: |
269 accessor_ = that.GetAxialSliceAccessor(slice, true); | 265 accessor_ = that.GetAxialSliceAccessor(slice, true); |
284 } | 280 } |
285 | 281 |
286 | 282 |
287 void ImageBuffer3D::SliceWriter::Flush() | 283 void ImageBuffer3D::SliceWriter::Flush() |
288 { | 284 { |
289 if (sagittal_.get() != NULL) | 285 if (modified_) |
290 { | 286 { |
291 // TODO | 287 if (sagittal_.get() != NULL) |
292 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 288 { |
289 // TODO | |
290 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
291 } | |
293 } | 292 } |
294 } | 293 } |
295 | 294 |
296 | 295 |
297 ImageBuffer3D::SliceWriter::SliceWriter(ImageBuffer3D& that, | 296 ImageBuffer3D::SliceWriter::SliceWriter(ImageBuffer3D& that, |
298 VolumeProjection projection, | 297 VolumeProjection projection, |
299 unsigned int slice) : | 298 unsigned int slice) : |
300 lock_(that.mutex_) | 299 modified_(false) |
301 { | 300 { |
302 switch (projection) | 301 switch (projection) |
303 { | 302 { |
304 case VolumeProjection_Axial: | 303 case VolumeProjection_Axial: |
305 accessor_ = that.GetAxialSliceAccessor(slice, false); | 304 accessor_ = that.GetAxialSliceAccessor(slice, false); |