Mercurial > hg > orthanc-stone
annotate Framework/Volumes/ImageBuffer3D.h @ 81:8677d95753f8 wasm
switching to Oracle in SDL samples
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 May 2017 22:54:09 +0200 |
parents | c2dc924f1a63 |
children | 4a541cd4fa83 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
40
7207a407bcd8
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../Enumerations.h" | |
25 #include "../Toolbox/SliceGeometry.h" | |
26 #include "../Toolbox/ParallelSlices.h" | |
27 | |
16 | 28 #include "../../Resources/Orthanc/Core/Images/Image.h" |
0 | 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 | |
37 { | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
38 class ImageBuffer3D : public boost::noncopyable |
0 | 39 { |
40 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_; | |
47 Vector voxelDimensions_; | |
48 Orthanc::Image image_; | |
49 Orthanc::PixelFormat format_; | |
50 unsigned int width_; | |
51 unsigned int height_; | |
52 unsigned int depth_; | |
53 | |
54 Orthanc::ImageAccessor GetAxialSliceAccessor(unsigned int slice, | |
55 bool readOnly); | |
56 | |
57 Orthanc::ImageAccessor GetCoronalSliceAccessor(unsigned int slice, | |
58 bool readOnly); | |
59 | |
60 Orthanc::Image* ExtractSagittalSlice(unsigned int slice) const; | |
61 | |
62 public: | |
63 ImageBuffer3D(Orthanc::PixelFormat format, | |
64 unsigned int width, | |
65 unsigned int height, | |
66 unsigned int depth); | |
67 | |
68 void Clear(); | |
69 | |
70 // Set the geometry of the first axial slice (i.e. the one whose | |
71 // depth == 0) | |
72 void SetAxialGeometry(const SliceGeometry& geometry); | |
73 | |
74 void SetVoxelDimensions(double x, | |
75 double y, | |
76 double z); | |
77 | |
78 Vector GetVoxelDimensions(VolumeProjection projection); | |
79 | |
80 void GetSliceSize(unsigned int& width, | |
81 unsigned int& height, | |
82 VolumeProjection projection); | |
83 | |
84 unsigned int GetWidth() const | |
85 { | |
86 return width_; | |
87 } | |
88 | |
89 unsigned int GetHeight() const | |
90 { | |
91 return height_; | |
92 } | |
93 | |
94 unsigned int GetDepth() const | |
95 { | |
96 return depth_; | |
97 } | |
98 | |
99 Orthanc::PixelFormat GetFormat() const | |
100 { | |
101 return format_; | |
102 } | |
103 | |
104 ParallelSlices* GetGeometry(VolumeProjection projection); | |
105 | |
106 | |
107 class SliceReader : public boost::noncopyable | |
108 { | |
109 private: | |
110 ReadLock lock_; | |
111 Orthanc::ImageAccessor accessor_; | |
112 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal | |
113 | |
114 public: | |
115 SliceReader(ImageBuffer3D& that, | |
116 VolumeProjection projection, | |
117 unsigned int slice); | |
118 | |
119 const Orthanc::ImageAccessor& GetAccessor() const | |
120 { | |
121 return accessor_; | |
122 } | |
123 }; | |
124 | |
125 | |
126 class SliceWriter : public boost::noncopyable | |
127 { | |
128 private: | |
129 WriteLock lock_; | |
130 Orthanc::ImageAccessor accessor_; | |
131 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal | |
132 | |
133 void Flush(); | |
134 | |
135 public: | |
136 SliceWriter(ImageBuffer3D& that, | |
137 VolumeProjection projection, | |
138 unsigned int slice); | |
139 | |
140 ~SliceWriter() | |
141 { | |
142 Flush(); | |
143 } | |
144 | |
145 Orthanc::ImageAccessor& GetAccessor() | |
146 { | |
147 return accessor_; | |
148 } | |
149 }; | |
150 }; | |
151 } |