814
|
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 "../Messages/IObservable.h"
|
|
25 #include "../Messages/IObserver.h"
|
|
26 #include "../Oracle/GetOrthancImageCommand.h"
|
|
27 #include "../Oracle/GetOrthancWebViewerJpegCommand.h"
|
|
28 #include "../Oracle/IOracle.h"
|
|
29 #include "../Oracle/OrthancRestApiCommand.h"
|
|
30 #include "../Toolbox/SlicesSorter.h"
|
|
31 #include "../Volumes/DicomVolumeImage.h"
|
|
32 #include "../Volumes/IVolumeSlicer.h"
|
|
33 #include "IFetchingItemsSorter.h"
|
|
34 #include "IFetchingStrategy.h"
|
|
35
|
|
36 #include <boost/shared_ptr.hpp>
|
|
37
|
|
38 namespace OrthancStone
|
|
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 IObserver,
|
|
46 public IObservable,
|
|
47 public 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 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<VolumeImageGeometry> geometry_;
|
|
70 std::vector<DicomInstanceParameters*> slices_;
|
|
71 std::vector<uint64_t> slicesRevision_;
|
|
72
|
|
73 public:
|
|
74 ~SeriesGeometry()
|
|
75 {
|
|
76 Clear();
|
|
77 }
|
|
78
|
|
79 void ComputeGeometry(SlicesSorter& slices);
|
|
80
|
|
81 bool HasGeometry() const
|
|
82 {
|
|
83 return geometry_.get() != NULL;
|
|
84 }
|
|
85
|
|
86 const VolumeImageGeometry& GetImageGeometry() const;
|
|
87
|
|
88 const 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
|
|
96 void ScheduleNextSliceDownload();
|
|
97
|
|
98 void LoadGeometry(const OrthancRestApiCommand::SuccessMessage& message);
|
|
99
|
|
100 void SetSliceContent(unsigned int sliceIndex,
|
|
101 const Orthanc::ImageAccessor& image,
|
|
102 unsigned int quality);
|
|
103
|
|
104 void LoadBestQualitySliceContent(const GetOrthancImageCommand::SuccessMessage& message);
|
|
105
|
|
106 void LoadJpegSliceContent(const GetOrthancWebViewerJpegCommand::SuccessMessage& message);
|
|
107
|
|
108 IOracle& oracle_;
|
|
109 bool active_;
|
|
110 unsigned int simultaneousDownloads_;
|
|
111 SeriesGeometry seriesGeometry_;
|
|
112 boost::shared_ptr<DicomVolumeImage> volume_;
|
|
113 std::auto_ptr<IFetchingItemsSorter::IFactory> sorter_;
|
|
114 std::auto_ptr<IFetchingStrategy> strategy_;
|
|
115 std::vector<unsigned int> slicesQuality_;
|
|
116
|
|
117
|
|
118 public:
|
|
119 OrthancSeriesVolumeProgressiveLoader(const boost::shared_ptr<DicomVolumeImage>& volume,
|
|
120 IOracle& oracle,
|
|
121 IObservable& oracleObservable);
|
|
122
|
|
123 void SetSimultaneousDownloads(unsigned int count);
|
|
124
|
|
125 void LoadSeries(const std::string& seriesId);
|
|
126
|
|
127 /**
|
|
128 When a slice is requested, the strategy algorithm (that defines the
|
|
129 sequence of resources to be loaded from the server) is modified to
|
|
130 take into account this request (this is done in the ExtractedSlice ctor)
|
|
131 */
|
|
132 virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane);
|
|
133 };
|
|
134 }
|