comparison Framework/Volumes/ImageBuffer3D.h @ 87:4a541cd4fa83 wasm

OrthancVolumeImageLoader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 15:31:58 +0200
parents c2dc924f1a63
children e0ddd8cad909
comparison
equal deleted inserted replaced
86:02c3a7a4938f 87:4a541cd4fa83
25 #include "../Toolbox/SliceGeometry.h" 25 #include "../Toolbox/SliceGeometry.h"
26 #include "../Toolbox/ParallelSlices.h" 26 #include "../Toolbox/ParallelSlices.h"
27 27
28 #include "../../Resources/Orthanc/Core/Images/Image.h" 28 #include "../../Resources/Orthanc/Core/Images/Image.h"
29 29
30 #include <boost/thread/shared_mutex.hpp>
31
32 #if defined(_WIN32)
33 # include <boost/thread/win32/mutex.hpp>
34 #endif
35
36 namespace OrthancStone 30 namespace OrthancStone
37 { 31 {
38 class ImageBuffer3D : public boost::noncopyable 32 class ImageBuffer3D : public boost::noncopyable
39 { 33 {
40 private: 34 private:
41 typedef boost::shared_mutex Mutex;
42 typedef boost::unique_lock<Mutex> WriteLock;
43 typedef boost::shared_lock<Mutex> ReadLock;
44
45 Mutex mutex_;
46 SliceGeometry axialGeometry_; 35 SliceGeometry axialGeometry_;
47 Vector voxelDimensions_; 36 Vector voxelDimensions_;
48 Orthanc::Image image_; 37 Orthanc::Image image_;
49 Orthanc::PixelFormat format_; 38 Orthanc::PixelFormat format_;
50 unsigned int width_; 39 unsigned int width_;
105 94
106 95
107 class SliceReader : public boost::noncopyable 96 class SliceReader : public boost::noncopyable
108 { 97 {
109 private: 98 private:
110 ReadLock lock_;
111 Orthanc::ImageAccessor accessor_; 99 Orthanc::ImageAccessor accessor_;
112 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal 100 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal
113 101
114 public: 102 public:
115 SliceReader(ImageBuffer3D& that, 103 SliceReader(ImageBuffer3D& that,
124 112
125 113
126 class SliceWriter : public boost::noncopyable 114 class SliceWriter : public boost::noncopyable
127 { 115 {
128 private: 116 private:
129 WriteLock lock_; 117 bool modified_;
130 Orthanc::ImageAccessor accessor_; 118 Orthanc::ImageAccessor accessor_;
131 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal 119 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal
132 120
133 void Flush(); 121 void Flush();
134 122
140 ~SliceWriter() 128 ~SliceWriter()
141 { 129 {
142 Flush(); 130 Flush();
143 } 131 }
144 132
133 const Orthanc::ImageAccessor& GetAccessor() const
134 {
135 return accessor_;
136 }
137
145 Orthanc::ImageAccessor& GetAccessor() 138 Orthanc::ImageAccessor& GetAccessor()
146 { 139 {
140 modified_ = true;
147 return accessor_; 141 return accessor_;
148 } 142 }
149 }; 143 };
150 }; 144 };
151 } 145 }