annotate Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp @ 999:2d69b8bee484

Added tests for Dicom structure set classes (loaders and utils)
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 20 Sep 2019 11:58:33 +0200
parents 262a0244e9b2
children e713f1a99861 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "OrthancSeriesVolumeProgressiveLoader.h"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../Toolbox/GeometryToolbox.h"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../Volumes/DicomVolumeImageMPRSlicer.h"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "BasicFetchingItemsSorter.h"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "BasicFetchingStrategy.h"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <Core/Images/ImageProcessing.h>
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <Core/OrthancException.h>
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace OrthancStone
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class OrthancSeriesVolumeProgressiveLoader::ExtractedSlice : public DicomVolumeImageMPRSlicer::Slice
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 private:
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 const OrthancSeriesVolumeProgressiveLoader& that_;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 public:
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 ExtractedSlice(const OrthancSeriesVolumeProgressiveLoader& that,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 const CoordinateSystem3D& plane) :
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 DicomVolumeImageMPRSlicer::Slice(*that.volume_, plane),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 that_(that)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
819
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
45 if (IsValid())
817
68f888812af4 simplification of DicomVolumeImageMPRSlicer::ExtractedSlice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 814
diff changeset
46 {
819
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
47 if (GetProjection() == VolumeProjection_Axial)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
48 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
49 // For coronal and sagittal projections, we take the global
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
50 // revision of the volume because even if a single slice changes,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
51 // this means the projection will yield a different result -->
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
52 // we must increase the revision as soon as any slice changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
53 SetRevision(that_.seriesGeometry_.GetSliceRevision(GetSliceIndex()));
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
54 }
817
68f888812af4 simplification of DicomVolumeImageMPRSlicer::ExtractedSlice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 814
diff changeset
55
819
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
56 if (that_.strategy_.get() != NULL &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
57 GetProjection() == VolumeProjection_Axial)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
58 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
59 that_.strategy_->SetCurrent(GetSliceIndex());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
60 }
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 };
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSlice(size_t index,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 const DicomInstanceParameters& reference) const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 const DicomInstanceParameters& slice = *slices_[index];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 if (!GeometryToolbox::IsParallel(
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 reference.GetGeometry().GetNormal(),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 slice.GetGeometry().GetNormal()))
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 "A slice in the volume image is not parallel to the others");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 if (reference.GetExpectedPixelFormat() != slice.GetExpectedPixelFormat())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 "The pixel format changes across the slices of the volume image");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if (reference.GetImageInformation().GetWidth() != slice.GetImageInformation().GetWidth() ||
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 reference.GetImageInformation().GetHeight() != slice.GetImageInformation().GetHeight())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 "The width/height of slices are not constant in the volume image");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 if (!LinearAlgebra::IsNear(reference.GetPixelSpacingX(), slice.GetPixelSpacingX()) ||
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 !LinearAlgebra::IsNear(reference.GetPixelSpacingY(), slice.GetPixelSpacingY()))
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 "The pixel spacing of the slices change across the volume image");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckVolume() const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 for (size_t i = 0; i < slices_.size(); i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 assert(slices_[i] != NULL);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if (slices_[i]->GetImageInformation().GetNumberOfFrames() != 1)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 "This class does not support multi-frame images");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (slices_.size() != 0)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 const DicomInstanceParameters& reference = *slices_[0];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 for (size_t i = 1; i < slices_.size(); i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 CheckSlice(i, reference);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::Clear()
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 for (size_t i = 0; i < slices_.size(); i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 assert(slices_[i] != NULL);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 delete slices_[i];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 slices_.clear();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 slicesRevision_.clear();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index) const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 if (!HasGeometry())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
143 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index): (!HasGeometry())";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 else if (index >= slices_.size())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 assert(slices_.size() == GetImageGeometry().GetDepth() &&
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 slices_.size() == slicesRevision_.size());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 // WARNING: The payload of "slices" must be of class "DicomInstanceParameters"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 // (called with the slices created in LoadGeometry)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::ComputeGeometry(SlicesSorter& slices)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 Clear();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 if (!slices.Sort())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 "Cannot sort the 3D slices of a DICOM series");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 if (slices.GetSlicesCount() == 0)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 geometry_.reset(new VolumeImageGeometry);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 slices_.reserve(slices.GetSlicesCount());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 slicesRevision_.resize(slices.GetSlicesCount(), 0);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 for (size_t i = 0; i < slices.GetSlicesCount(); i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 const DicomInstanceParameters& slice =
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 dynamic_cast<const DicomInstanceParameters&>(slices.GetSlicePayload(i));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 slices_.push_back(new DicomInstanceParameters(slice));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 CheckVolume();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 const double spacingZ = slices.ComputeSpacingBetweenSlices();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm";
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 const DicomInstanceParameters& parameters = *slices_[0];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 geometry_.reset(new VolumeImageGeometry);
949
32eaf4929b08 OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
194 geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(),
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 parameters.GetImageInformation().GetHeight(),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 static_cast<unsigned int>(slices.GetSlicesCount()));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 geometry_->SetAxialGeometry(slices.GetSliceGeometry(0));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 parameters.GetPixelSpacingY(), spacingZ);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 const VolumeImageGeometry& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry() const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 if (!HasGeometry())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 {
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
208 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry(): (!HasGeometry())";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 assert(slices_.size() == geometry_->GetDepth());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 return *geometry_;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 const DicomInstanceParameters& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceParameters(size_t index) const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 CheckSliceIndex(index);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 return *slices_[index];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 uint64_t OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceRevision(size_t index) const
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 CheckSliceIndex(index);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 return slicesRevision_[index];
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::IncrementSliceRevision(size_t index)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 CheckSliceIndex(index);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 slicesRevision_[index] ++;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 static unsigned int GetSliceIndexPayload(const OracleCommandWithPayload& command)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 return dynamic_cast< const Orthanc::SingleValueObject<unsigned int>& >(command.GetPayload()).GetValue();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 void OrthancSeriesVolumeProgressiveLoader::ScheduleNextSliceDownload()
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 assert(strategy_.get() != NULL);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 unsigned int sliceIndex, quality;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 if (strategy_->GetNext(sliceIndex, quality))
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 assert(quality <= BEST_QUALITY);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 const DicomInstanceParameters& slice = seriesGeometry_.GetSliceParameters(sliceIndex);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 const std::string& instance = slice.GetOrthancInstanceIdentifier();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 if (instance.empty())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 std::auto_ptr<OracleCommandWithPayload> command;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 if (quality == BEST_QUALITY)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 std::auto_ptr<GetOrthancImageCommand> tmp(new GetOrthancImageCommand);
937
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
269 // TODO: review the following comment.
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
270 // - Commented out by bgo on 2019-07-19 | reason: Alain has seen cases
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
271 // where gzipping the uint16 image took 11 sec to produce 5mb.
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
272 // The unzipped request was much much faster.
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
273 // - Re-enabled on 2019-07-30. Reason: in Web Assembly, the browser
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
274 // does not use the Accept-Encoding header and always requests
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
275 // compression. Furthermore, NOT
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
276 tmp->SetHttpHeader("Accept-Encoding", "gzip");
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam)));
819
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 817
diff changeset
278 tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat());
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 command.reset(tmp.release());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 std::auto_ptr<GetOrthancWebViewerJpegCommand> tmp(new GetOrthancWebViewerJpegCommand);
913
2b4b6b86520a Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents: 819
diff changeset
285 // TODO: review the following comment. Commented out by bgo on 2019-07-19
2b4b6b86520a Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents: 819
diff changeset
286 // (gzip for jpeg seems overkill)
2b4b6b86520a Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents: 819
diff changeset
287 //tmp->SetHttpHeader("Accept-Encoding", "gzip");
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 tmp->SetInstance(instance);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 tmp->SetQuality((quality == 0 ? 50 : 90));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 command.reset(tmp.release());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 command->SetPayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 oracle_.Schedule(*this, command.release());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 }
937
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
297 else
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
298 {
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
299 // loading is finished!
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
300 volumeImageReadyInHighQuality_ = true;
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
301 BroadcastMessage(OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality(*this));
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
302 }
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 /**
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 This is called in response to GET "/series/XXXXXXXXXXXXX/instances-tags"
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 */
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 void OrthancSeriesVolumeProgressiveLoader::LoadGeometry(const OrthancRestApiCommand::SuccessMessage& message)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 Json::Value body;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 message.ParseJsonBody(body);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 if (body.type() != Json::objectValue)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 Json::Value::Members instances = body.getMemberNames();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 SlicesSorter slices;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 for (size_t i = 0; i < instances.size(); i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 Orthanc::DicomMap dicom;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 dicom.FromDicomAsJson(body[instances[i]]);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 std::auto_ptr<DicomInstanceParameters> instance(new DicomInstanceParameters(dicom));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 instance->SetOrthancInstanceIdentifier(instances[i]);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 // the 3D plane corresponding to the slice
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 CoordinateSystem3D geometry = instance->GetGeometry();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 slices.AddSlice(geometry, instance.release());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 seriesGeometry_.ComputeGeometry(slices);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 size_t slicesCount = seriesGeometry_.GetImageGeometry().GetDepth();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 if (slicesCount == 0)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 volume_->Initialize(seriesGeometry_.GetImageGeometry(), Orthanc::PixelFormat_Grayscale8);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 const DicomInstanceParameters& parameters = seriesGeometry_.GetSliceParameters(0);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 volume_->Initialize(seriesGeometry_.GetImageGeometry(), parameters.GetExpectedPixelFormat());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 volume_->SetDicomParameters(parameters);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 volume_->GetPixelData().Clear();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 strategy_.reset(new BasicFetchingStrategy(sorter_->CreateSorter(static_cast<unsigned int>(slicesCount)), BEST_QUALITY));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 assert(simultaneousDownloads_ != 0);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 for (unsigned int i = 0; i < simultaneousDownloads_; i++)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 ScheduleNextSliceDownload();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 slicesQuality_.resize(slicesCount, 0);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 BroadcastMessage(DicomVolumeImage::GeometryReadyMessage(*volume_));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 void OrthancSeriesVolumeProgressiveLoader::SetSliceContent(unsigned int sliceIndex,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 const Orthanc::ImageAccessor& image,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 unsigned int quality)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 assert(sliceIndex < slicesQuality_.size() &&
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 slicesQuality_.size() == volume_->GetPixelData().GetDepth());
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 if (quality >= slicesQuality_[sliceIndex])
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), VolumeProjection_Axial, sliceIndex);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 volume_->IncrementRevision();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 seriesGeometry_.IncrementSliceRevision(sliceIndex);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 slicesQuality_[sliceIndex] = quality;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 BroadcastMessage(DicomVolumeImage::ContentUpdatedMessage(*volume_));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 ScheduleNextSliceDownload();
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 void OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent(const GetOrthancImageCommand::SuccessMessage& message)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), BEST_QUALITY);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 void OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent(const GetOrthancWebViewerJpegCommand::SuccessMessage& message)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 unsigned int quality;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 switch (message.GetOrigin().GetQuality())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 case 50:
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 quality = LOW_QUALITY;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 break;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 case 90:
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 quality = MIDDLE_QUALITY;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 break;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 default:
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), quality);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 OrthancSeriesVolumeProgressiveLoader::OrthancSeriesVolumeProgressiveLoader(const boost::shared_ptr<DicomVolumeImage>& volume,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 IOracle& oracle,
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 IObservable& oracleObservable) :
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 IObserver(oracleObservable.GetBroker()),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 IObservable(oracleObservable.GetBroker()),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 oracle_(oracle),
977
262a0244e9b2 Added missing Unregister for objects that register by the broker + logs + guard in FetchContext
Benjamin Golinvaux <bgo@osimis.io>
parents: 956
diff changeset
427 oracleObservable_(oracleObservable),
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 active_(false),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 simultaneousDownloads_(4),
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 volume_(volume),
937
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
431 sorter_(new BasicFetchingItemsSorter::Factory),
86ac61a040c9 Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents: 935
diff changeset
432 volumeImageReadyInHighQuality_(false)
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 oracleObservable.RegisterObserverCallback(
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 new Callable<OrthancSeriesVolumeProgressiveLoader, OrthancRestApiCommand::SuccessMessage>
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadGeometry));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 oracleObservable.RegisterObserverCallback(
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 new Callable<OrthancSeriesVolumeProgressiveLoader, GetOrthancImageCommand::SuccessMessage>
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 oracleObservable.RegisterObserverCallback(
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 new Callable<OrthancSeriesVolumeProgressiveLoader, GetOrthancWebViewerJpegCommand::SuccessMessage>
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 (*this, &OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent));
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
935
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 933
diff changeset
447 OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader()
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 933
diff changeset
448 {
977
262a0244e9b2 Added missing Unregister for objects that register by the broker + logs + guard in FetchContext
Benjamin Golinvaux <bgo@osimis.io>
parents: 956
diff changeset
449 oracleObservable_.Unregister(this);
935
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 933
diff changeset
450 LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader()";
401808e7ff2e Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents: 933
diff changeset
451 }
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 void OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(unsigned int count)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 if (active_)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 {
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
457 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(): (active_)";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 else if (count == 0)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 simultaneousDownloads_ = count;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 void OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 {
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 913
diff changeset
473 // LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries seriesId=" << seriesId;
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 if (active_)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 {
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 913
diff changeset
476 // LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries NOT ACTIVE! --> ERROR";
956
a7351ad54960 Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents: 949
diff changeset
477 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId): (active_)";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 active_ = true;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 command->SetUri("/series/" + seriesId + "/instances-tags");
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 913
diff changeset
487 // LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries about to call oracle_.Schedule";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 oracle_.Schedule(*this, command.release());
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 913
diff changeset
489 // LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries called oracle_.Schedule";
814
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 IVolumeSlicer::IExtractedSlice*
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 OrthancSeriesVolumeProgressiveLoader::ExtractSlice(const CoordinateSystem3D& cuttingPlane)
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 if (volume_->HasGeometry())
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 return new ExtractedSlice(*this, cuttingPlane);
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 else
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 {
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 return new IVolumeSlicer::InvalidSlice;
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 }
aead999345e0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 }