Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.h @ 1225:16738485e457 broker
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 08 Dec 2019 11:45:09 +0100 |
parents | Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h@34ee7204fde3 |
children | 0ca50d275b9a |
comparison
equal
deleted
inserted
replaced
1224:37bc7f115f81 | 1225:16738485e457 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
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. | |
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 | |
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 | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../../Loaders/IFetchingItemsSorter.h" | |
25 #include "../../Loaders/IFetchingStrategy.h" | |
26 #include "../../Messages/IObservable.h" | |
27 #include "../../Messages/ObserverBase.h" | |
28 #include "../../Oracle/GetOrthancImageCommand.h" | |
29 #include "../../Oracle/GetOrthancWebViewerJpegCommand.h" | |
30 #include "../../Oracle/IOracle.h" | |
31 #include "../../Oracle/OrthancRestApiCommand.h" | |
32 #include "../../Toolbox/SlicesSorter.h" | |
33 #include "../../Volumes/DicomVolumeImage.h" | |
34 #include "../../Volumes/IVolumeSlicer.h" | |
35 | |
36 #include <boost/shared_ptr.hpp> | |
37 | |
38 namespace Deprecated | |
39 { | |
40 /** | |
41 This class is used to manage the progressive loading of a volume that | |
42 is stored in a Dicom series. | |
43 */ | |
44 class OrthancSeriesVolumeProgressiveLoader : | |
45 public OrthancStone::ObserverBase<OrthancSeriesVolumeProgressiveLoader>, | |
46 public OrthancStone::IObservable, | |
47 public OrthancStone::IVolumeSlicer | |
48 { | |
49 private: | |
50 static const unsigned int LOW_QUALITY = 0; | |
51 static const unsigned int MIDDLE_QUALITY = 1; | |
52 static const unsigned int BEST_QUALITY = 2; | |
53 | |
54 class ExtractedSlice; | |
55 | |
56 /** Helper class internal to OrthancSeriesVolumeProgressiveLoader */ | |
57 class SeriesGeometry : public boost::noncopyable | |
58 { | |
59 private: | |
60 void CheckSlice(size_t index, | |
61 const OrthancStone::DicomInstanceParameters& reference) const; | |
62 | |
63 void CheckVolume() const; | |
64 | |
65 void Clear(); | |
66 | |
67 void CheckSliceIndex(size_t index) const; | |
68 | |
69 std::auto_ptr<OrthancStone::VolumeImageGeometry> geometry_; | |
70 std::vector<OrthancStone::DicomInstanceParameters*> slices_; | |
71 std::vector<uint64_t> slicesRevision_; | |
72 | |
73 public: | |
74 ~SeriesGeometry() | |
75 { | |
76 Clear(); | |
77 } | |
78 | |
79 void ComputeGeometry(OrthancStone::SlicesSorter& slices); | |
80 | |
81 virtual bool HasGeometry() const | |
82 { | |
83 return geometry_.get() != NULL; | |
84 } | |
85 | |
86 virtual const OrthancStone::VolumeImageGeometry& GetImageGeometry() const; | |
87 | |
88 const OrthancStone::DicomInstanceParameters& GetSliceParameters(size_t index) const; | |
89 | |
90 uint64_t GetSliceRevision(size_t index) const; | |
91 | |
92 void IncrementSliceRevision(size_t index); | |
93 }; | |
94 | |
95 void ScheduleNextSliceDownload(); | |
96 | |
97 void LoadGeometry(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message); | |
98 | |
99 void SetSliceContent(unsigned int sliceIndex, | |
100 const Orthanc::ImageAccessor& image, | |
101 unsigned int quality); | |
102 | |
103 void LoadBestQualitySliceContent(const OrthancStone::GetOrthancImageCommand::SuccessMessage& message); | |
104 | |
105 void LoadJpegSliceContent(const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message); | |
106 | |
107 OrthancStone::IOracle& oracle_; | |
108 bool active_; | |
109 unsigned int simultaneousDownloads_; | |
110 SeriesGeometry seriesGeometry_; | |
111 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume_; | |
112 std::auto_ptr<OrthancStone::IFetchingItemsSorter::IFactory> sorter_; | |
113 std::auto_ptr<OrthancStone::IFetchingStrategy> strategy_; | |
114 std::vector<unsigned int> slicesQuality_; | |
115 bool volumeImageReadyInHighQuality_; | |
116 | |
117 | |
118 public: | |
119 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, VolumeImageReadyInHighQuality, OrthancSeriesVolumeProgressiveLoader); | |
120 | |
121 | |
122 OrthancSeriesVolumeProgressiveLoader(const boost::shared_ptr<OrthancStone::DicomVolumeImage>& volume, | |
123 OrthancStone::IOracle& oracle, | |
124 OrthancStone::IObservable& oracleObservable); | |
125 | |
126 virtual ~OrthancSeriesVolumeProgressiveLoader(); | |
127 | |
128 void SetSimultaneousDownloads(unsigned int count); | |
129 | |
130 bool IsVolumeImageReadyInHighQuality() const | |
131 { | |
132 return volumeImageReadyInHighQuality_; | |
133 } | |
134 | |
135 void LoadSeries(const std::string& seriesId); | |
136 | |
137 /** | |
138 This getter is used by clients that do not receive the geometry through | |
139 subscribing, for instance if they are created or listening only AFTER the | |
140 "geometry loaded" message is broadcast | |
141 */ | |
142 bool HasGeometry() const | |
143 { | |
144 return seriesGeometry_.HasGeometry(); | |
145 } | |
146 | |
147 /** | |
148 Same remark as HasGeometry | |
149 */ | |
150 const OrthancStone::VolumeImageGeometry& GetImageGeometry() const | |
151 { | |
152 return seriesGeometry_.GetImageGeometry(); | |
153 } | |
154 | |
155 /** | |
156 When a slice is requested, the strategy algorithm (that defines the | |
157 sequence of resources to be loaded from the server) is modified to | |
158 take into account this request (this is done in the ExtractedSlice ctor) | |
159 */ | |
160 virtual IExtractedSlice* | |
161 ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) ORTHANC_OVERRIDE; | |
162 }; | |
163 } |