Mercurial > hg > orthanc-stone
comparison Framework/Volumes/VolumeImage.h @ 0:351ab0da0150
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Oct 2016 15:34:11 +0200 |
parents | |
children | 517c46f527cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:351ab0da0150 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * | |
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 | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #pragma once | |
34 | |
35 #include "ISliceableVolume.h" | |
36 #include "ImageBuffer3D.h" | |
37 #include "../Toolbox/ISeriesLoader.h" | |
38 #include "../Toolbox/ObserversRegistry.h" | |
39 #include "../Messaging/MessagingToolbox.h" | |
40 #include "../Layers/ILayerRendererFactory.h" | |
41 | |
42 #include <boost/thread.hpp> | |
43 | |
44 namespace OrthancStone | |
45 { | |
46 class VolumeImage : public ISliceableVolume | |
47 { | |
48 public: | |
49 class IDownloadPolicy : public IThreadSafe | |
50 { | |
51 public: | |
52 virtual void Initialize(ImageBuffer3D& buffer, | |
53 ISeriesLoader& loader) = 0; | |
54 | |
55 virtual void Finalize() = 0; | |
56 | |
57 // Must return "true" if the thread has completed its task. Pay | |
58 // attention that this method can be invoked concurrently by | |
59 // several download threads. | |
60 virtual bool DownloadStep(bool& complete) = 0; | |
61 | |
62 virtual bool IsFullQualityAxial(size_t slice) = 0; | |
63 }; | |
64 | |
65 | |
66 private: | |
67 std::auto_ptr<ISeriesLoader> loader_; | |
68 std::auto_ptr<ImageBuffer3D> buffer_; | |
69 std::vector<boost::thread*> threads_; | |
70 bool started_; | |
71 bool continue_; | |
72 ObserversRegistry<ISliceableVolume> observers_; | |
73 bool loadingComplete_; | |
74 MessagingToolbox::Timestamp lastUpdate_; | |
75 std::auto_ptr<DicomDataset> referenceDataset_; | |
76 std::auto_ptr<IDownloadPolicy> policy_; | |
77 | |
78 std::auto_ptr<ParallelSlices> axialGeometry_; | |
79 std::auto_ptr<ParallelSlices> coronalGeometry_; | |
80 std::auto_ptr<ParallelSlices> sagittalGeometry_; | |
81 | |
82 void StoreUpdateTime(); | |
83 | |
84 void NotifyChange(bool force); | |
85 | |
86 static void LoadThread(VolumeImage* that); | |
87 | |
88 bool DetectProjection(VolumeProjection& projection, | |
89 bool& reverse, | |
90 const SliceGeometry& viewportSlice); | |
91 | |
92 const ParallelSlices& GetGeometryInternal(VolumeProjection projection); | |
93 | |
94 public: | |
95 VolumeImage(ISeriesLoader* loader); // Takes ownership | |
96 | |
97 virtual ~VolumeImage(); | |
98 | |
99 void SetDownloadPolicy(IDownloadPolicy* policy); // Takes ownership | |
100 | |
101 void SetThreadCount(size_t count); | |
102 | |
103 size_t GetThreadCount() const | |
104 { | |
105 return threads_.size(); | |
106 } | |
107 | |
108 virtual void Register(IChangeObserver& observer); | |
109 | |
110 virtual void Unregister(IChangeObserver& observer); | |
111 | |
112 virtual void Start(); | |
113 | |
114 virtual void Stop(); | |
115 | |
116 ParallelSlices* GetGeometry(VolumeProjection projection, | |
117 bool reverse); | |
118 | |
119 Vector GetVoxelDimensions(VolumeProjection projection) | |
120 { | |
121 return buffer_->GetVoxelDimensions(projection); | |
122 } | |
123 | |
124 bool IsLoadingComplete() const | |
125 { | |
126 return loadingComplete_; | |
127 } | |
128 | |
129 class LayerFactory : public ILayerRendererFactory | |
130 { | |
131 private: | |
132 VolumeImage& that_; | |
133 | |
134 public: | |
135 LayerFactory(VolumeImage& that) : | |
136 that_(that) | |
137 { | |
138 } | |
139 | |
140 virtual bool HasSourceVolume() const | |
141 { | |
142 return true; | |
143 } | |
144 | |
145 virtual ISliceableVolume& GetSourceVolume() const | |
146 { | |
147 return that_; | |
148 } | |
149 | |
150 virtual bool GetExtent(double& x1, | |
151 double& y1, | |
152 double& x2, | |
153 double& y2, | |
154 const SliceGeometry& viewportSlice); | |
155 | |
156 virtual ILayerRenderer* CreateLayerRenderer(const SliceGeometry& viewportSlice); | |
157 }; | |
158 }; | |
159 } |