Mercurial > hg > orthanc-stone
annotate Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp @ 1357:0dc5b8a4b3a0 broker
hgignore
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 15 Apr 2020 15:23:07 +0200 |
parents | 556b4bc19118 |
children | b497e1217aa5 |
rev | line source |
---|---|
1337
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include "OrthancSeriesVolumeProgressiveLoader.h" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
1339
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
24 #include "../StoneException.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
25 #include "../Loaders/ILoadersContext.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
26 #include "../Loaders/BasicFetchingItemsSorter.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
27 #include "../Loaders/BasicFetchingStrategy.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
28 #include "../Toolbox/GeometryToolbox.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
29 #include "../Volumes/DicomVolumeImageMPRSlicer.h" |
1337
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 #include <Core/Images/ImageProcessing.h> |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 #include <Core/OrthancException.h> |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 namespace OrthancStone |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 using OrthancStone::ILoadersContext; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 class OrthancSeriesVolumeProgressiveLoader::ExtractedSlice : public OrthancStone::DicomVolumeImageMPRSlicer::Slice |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 private: |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 const OrthancSeriesVolumeProgressiveLoader& that_; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 public: |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 ExtractedSlice(const OrthancSeriesVolumeProgressiveLoader& that, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 const OrthancStone::CoordinateSystem3D& plane) : |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 OrthancStone::DicomVolumeImageMPRSlicer::Slice(*that.volume_, plane), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 that_(that) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 if (IsValid()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 if (GetProjection() == OrthancStone::VolumeProjection_Axial) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 // For coronal and sagittal projections, we take the global |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 // revision of the volume because even if a single slice changes, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 // this means the projection will yield a different result --> |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 // we must increase the revision as soon as any slice changes |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 SetRevision(that_.seriesGeometry_.GetSliceRevision(GetSliceIndex())); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 if (that_.strategy_.get() != NULL && |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 GetProjection() == OrthancStone::VolumeProjection_Axial) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 that_.strategy_->SetCurrent(GetSliceIndex()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 }; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSlice( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 size_t index, const OrthancStone::DicomInstanceParameters& reference) const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 const OrthancStone::DicomInstanceParameters& slice = *slices_[index]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 if (!OrthancStone::GeometryToolbox::IsParallel( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 reference.GetGeometry().GetNormal(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 slice.GetGeometry().GetNormal())) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 "A slice in the volume image is not parallel to the others"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 if (reference.GetExpectedPixelFormat() != slice.GetExpectedPixelFormat()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 "The pixel format changes across the slices of the volume image"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 if (reference.GetImageInformation().GetWidth() != slice.GetImageInformation().GetWidth() || |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 reference.GetImageInformation().GetHeight() != slice.GetImageInformation().GetHeight()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 "The width/height of slices are not constant in the volume image"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 if (!OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingX(), slice.GetPixelSpacingX()) || |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 !OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingY(), slice.GetPixelSpacingY())) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 "The pixel spacing of the slices change across the volume image"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckVolume() const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 for (size_t i = 0; i < slices_.size(); i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 assert(slices_[i] != NULL); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 if (slices_[i]->GetImageInformation().GetNumberOfFrames() != 1) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 "This class does not support multi-frame images"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 if (slices_.size() != 0) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 const OrthancStone::DicomInstanceParameters& reference = *slices_[0]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 for (size_t i = 1; i < slices_.size(); i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 CheckSlice(i, reference); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::Clear() |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 for (size_t i = 0; i < slices_.size(); i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 assert(slices_[i] != NULL); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 delete slices_[i]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 slices_.clear(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 slicesRevision_.clear(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index) const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 if (!HasGeometry()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index): (!HasGeometry())"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 else if (index >= slices_.size()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 assert(slices_.size() == GetImageGeometry().GetDepth() && |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 slices_.size() == slicesRevision_.size()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 // WARNING: The payload of "slices" must be of class "DicomInstanceParameters" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 // (called with the slices created in LoadGeometry) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::ComputeGeometry(OrthancStone::SlicesSorter& slices) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 Clear(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 if (!slices.Sort()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 "Cannot sort the 3D slices of a DICOM series"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 if (slices.GetSlicesCount() == 0) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 geometry_.reset(new OrthancStone::VolumeImageGeometry); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 slices_.reserve(slices.GetSlicesCount()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 slicesRevision_.resize(slices.GetSlicesCount(), 0); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 for (size_t i = 0; i < slices.GetSlicesCount(); i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 const OrthancStone::DicomInstanceParameters& slice = |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 dynamic_cast<const OrthancStone::DicomInstanceParameters&>(slices.GetSlicePayload(i)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 slices_.push_back(new OrthancStone::DicomInstanceParameters(slice)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 CheckVolume(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 double spacingZ; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 if (slices.ComputeSpacingBetweenSlices(spacingZ)) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 LOG(TRACE) << "Computed spacing between slices: " << spacingZ << "mm"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 const OrthancStone::DicomInstanceParameters& parameters = *slices_[0]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 geometry_.reset(new OrthancStone::VolumeImageGeometry); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 parameters.GetImageInformation().GetHeight(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 static_cast<unsigned int>(slices.GetSlicesCount())); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 geometry_->SetAxialGeometry(slices.GetSliceGeometry(0)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 parameters.GetPixelSpacingY(), spacingZ); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 "The origins of the slices of a volume image are not regularly spaced"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 const OrthancStone::VolumeImageGeometry& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry() const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 if (!HasGeometry()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry(): (!HasGeometry())"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 assert(slices_.size() == geometry_->GetDepth()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 return *geometry_; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 const OrthancStone::DicomInstanceParameters& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceParameters(size_t index) const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 CheckSliceIndex(index); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 return *slices_[index]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 uint64_t OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceRevision(size_t index) const |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 CheckSliceIndex(index); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 return slicesRevision_[index]; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::IncrementSliceRevision(size_t index) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
245 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 CheckSliceIndex(index); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 slicesRevision_[index] ++; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 static unsigned int GetSliceIndexPayload(const OrthancStone::OracleCommandBase& command) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 assert(command.HasPayload()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 return dynamic_cast< const Orthanc::SingleValueObject<unsigned int>& >(command.GetPayload()).GetValue(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
258 void OrthancSeriesVolumeProgressiveLoader::ScheduleNextSliceDownload() |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 assert(strategy_.get() != NULL); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 unsigned int sliceIndex = 0, quality = 0; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
263 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 if (strategy_->GetNext(sliceIndex, quality)) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 if (!progressiveQuality_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 ORTHANC_ASSERT(quality == QUALITY_00, "INTERNAL ERROR. quality != QUALITY_00 in " |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
269 << "OrthancSeriesVolumeProgressiveLoader::ScheduleNextSliceDownload"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 const OrthancStone::DicomInstanceParameters& slice = seriesGeometry_.GetSliceParameters(sliceIndex); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 const std::string& instance = slice.GetOrthancInstanceIdentifier(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 if (instance.empty()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 std::unique_ptr<OrthancStone::OracleCommandBase> command; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 if (!progressiveQuality_ || quality == QUALITY_02) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 std::unique_ptr<OrthancStone::GetOrthancImageCommand> tmp(new OrthancStone::GetOrthancImageCommand); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
285 // TODO: review the following comment. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 // - Commented out by bgo on 2019-07-19 | reason: Alain has seen cases |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 // where gzipping the uint16 image took 11 sec to produce 5mb. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 // The unzipped request was much much faster. |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 // - Re-enabled on 2019-07-30. Reason: in Web Assembly, the browser |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 // does not use the Accept-Encoding header and always requests |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 // compression. Furthermore, NOT |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
293 tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
296 //LOG(INFO) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 // << "OrthancSeriesVolumeProgressiveLoader.ScheduleNextSliceDownload()" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 // << " sliceIndex = " << sliceIndex << " slice quality = " << quality |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 // << " URI = " << tmp->GetUri(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 command.reset(tmp.release()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
302 else // progressive mode is true AND quality is not final (different from QUALITY_02 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 std::unique_ptr<OrthancStone::GetOrthancWebViewerJpegCommand> tmp( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 new OrthancStone::GetOrthancWebViewerJpegCommand); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 // TODO: review the following comment. Commented out by bgo on 2019-07-19 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 // (gzip for jpeg seems overkill) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 //tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 tmp->SetInstance(instance); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 tmp->SetQuality((quality == 0 ? 50 : 90)); // QUALITY_00 is Jpeg50 while QUALITY_01 is Jpeg90 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 LOG(TRACE) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 << "OrthancSeriesVolumeProgressiveLoader.ScheduleNextSliceDownload()" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 << " sliceIndex = " << sliceIndex << " slice quality = " << quality; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 command.reset(tmp.release()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 command->AcquirePayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
322 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
323 boost::shared_ptr<IObserver> observer(GetSharedObserver()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 lock->Schedule(observer, 0, command.release()); // TODO: priority! |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
325 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
326 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
328 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 // loading is finished! |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
330 volumeImageReadyInHighQuality_ = true; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 BroadcastMessage(OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality(*this)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 /** |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 This is called in response to GET "/series/XXXXXXXXXXXXX/instances-tags" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
337 */ |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
338 void OrthancSeriesVolumeProgressiveLoader::LoadGeometry(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 Json::Value body; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 message.ParseJsonBody(body); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 if (body.type() != Json::objectValue) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
347 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 Json::Value::Members instances = body.getMemberNames(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
351 OrthancStone::SlicesSorter slices; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 for (size_t i = 0; i < instances.size(); i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
354 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 Orthanc::DicomMap dicom; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 dicom.FromDicomAsJson(body[instances[i]]); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 std::unique_ptr<OrthancStone::DicomInstanceParameters> instance(new OrthancStone::DicomInstanceParameters(dicom)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 instance->SetOrthancInstanceIdentifier(instances[i]); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 // the 3D plane corresponding to the slice |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 slices.AddSlice(geometry, instance.release()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
365 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 seriesGeometry_.ComputeGeometry(slices); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 size_t slicesCount = seriesGeometry_.GetImageGeometry().GetDepth(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 if (slicesCount == 0) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 volume_->Initialize(seriesGeometry_.GetImageGeometry(), Orthanc::PixelFormat_Grayscale8); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
374 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
375 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
376 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
377 const OrthancStone::DicomInstanceParameters& parameters = seriesGeometry_.GetSliceParameters(0); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
379 volume_->Initialize(seriesGeometry_.GetImageGeometry(), parameters.GetExpectedPixelFormat()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
380 volume_->SetDicomParameters(parameters); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 volume_->GetPixelData().Clear(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
382 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
383 // If we are in progressive mode, the Fetching strategy will first request QUALITY_00, then QUALITY_01, then |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
384 // QUALITY_02... Otherwise, it's only QUALITY_00 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
385 unsigned int maxQuality = QUALITY_00; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
386 if (progressiveQuality_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 maxQuality = QUALITY_02; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
388 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
389 strategy_.reset(new OrthancStone::BasicFetchingStrategy( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 sorter_->CreateSorter(static_cast<unsigned int>(slicesCount)), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
391 maxQuality)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 assert(simultaneousDownloads_ != 0); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 for (unsigned int i = 0; i < simultaneousDownloads_; i++) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 ScheduleNextSliceDownload(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 slicesQuality_.resize(slicesCount, 0); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
402 BroadcastMessage(OrthancStone::DicomVolumeImage::GeometryReadyMessage(*volume_)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
405 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
406 void OrthancSeriesVolumeProgressiveLoader::SetSliceContent(unsigned int sliceIndex, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
407 const Orthanc::ImageAccessor& image, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
408 unsigned int quality) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
409 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
410 ORTHANC_ASSERT(sliceIndex < slicesQuality_.size() && |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
411 slicesQuality_.size() == volume_->GetPixelData().GetDepth()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
412 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
413 if (!progressiveQuality_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
414 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
415 ORTHANC_ASSERT(quality == QUALITY_00); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
416 ORTHANC_ASSERT(slicesQuality_[sliceIndex] == QUALITY_00); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
417 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
418 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
419 if (quality >= slicesQuality_[sliceIndex]) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
420 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
421 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
422 OrthancStone::ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
423 OrthancStone::VolumeProjection_Axial, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
424 sliceIndex); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
425 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
426 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
427 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
428 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
429 volume_->IncrementRevision(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
430 seriesGeometry_.IncrementSliceRevision(sliceIndex); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 slicesQuality_[sliceIndex] = quality; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
432 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
433 BroadcastMessage(OrthancStone::DicomVolumeImage::ContentUpdatedMessage(*volume_)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
434 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 LOG(TRACE) << "SetSliceContent sliceIndex = " << sliceIndex << " -- will " |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 << " now call ScheduleNextSliceDownload()"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 ScheduleNextSliceDownload(); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 void OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 const OrthancStone::GetOrthancImageCommand::SuccessMessage& message) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 unsigned int quality = QUALITY_00; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 if (progressiveQuality_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
445 quality = QUALITY_02; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
446 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 message.GetImage(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
449 quality); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 void OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 ORTHANC_ASSERT(progressiveQuality_, "INTERNAL ERROR: OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent" |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 << " called while progressiveQuality_ is false!"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
457 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 unsigned int quality; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 switch (dynamic_cast<const OrthancStone::GetOrthancWebViewerJpegCommand&>(message.GetOrigin()).GetQuality()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
462 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 case 50: |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 quality = QUALITY_00; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 break; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
466 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
467 case 90: |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
468 quality = QUALITY_01; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
469 break; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 default: |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
473 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), quality); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 OrthancSeriesVolumeProgressiveLoader::OrthancSeriesVolumeProgressiveLoader( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 OrthancStone::ILoadersContext& loadersContext, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
480 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
481 bool progressiveQuality) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
482 : loadersContext_(loadersContext) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
483 , active_(false) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
484 , progressiveQuality_(progressiveQuality) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
485 , simultaneousDownloads_(4) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
486 , volume_(volume) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 , sorter_(new OrthancStone::BasicFetchingItemsSorter::Factory) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 , volumeImageReadyInHighQuality_(false) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
490 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 OrthancSeriesVolumeProgressiveLoader::Create( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 OrthancStone::ILoadersContext& loadersContext, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
495 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
496 bool progressiveQuality) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
498 std::auto_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext.Lock()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
499 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
500 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> obj( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
501 new OrthancSeriesVolumeProgressiveLoader( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
502 loadersContext, volume, progressiveQuality)); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
503 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
504 obj->Register<OrthancStone::OrthancRestApiCommand::SuccessMessage>( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
505 lock->GetOracleObservable(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
506 &OrthancSeriesVolumeProgressiveLoader::LoadGeometry); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
507 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
508 obj->Register<OrthancStone::GetOrthancImageCommand::SuccessMessage>( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
509 lock->GetOracleObservable(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
510 &OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
511 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
512 obj->Register<OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage>( |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
513 lock->GetOracleObservable(), |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
514 &OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
515 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
516 return obj; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
517 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
518 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
519 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
520 OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader() |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
521 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
522 LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader()"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
523 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
524 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
525 void OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(unsigned int count) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
526 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
527 if (active_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
528 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
529 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(): (active_)"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
530 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
531 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
532 else if (count == 0) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
533 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
534 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
535 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
536 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
537 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
538 simultaneousDownloads_ = count; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
539 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
540 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
541 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
542 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
543 void OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
544 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
545 if (active_) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
546 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
547 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId): (active_)"; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
548 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
549 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
550 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
551 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
552 active_ = true; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
553 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
554 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
555 command->SetUri("/series/" + seriesId + "/instances-tags"); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
556 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
557 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
558 boost::shared_ptr<IObserver> observer(GetSharedObserver()); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
559 lock->Schedule(observer, 0, command.release()); //TODO: priority! |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
560 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
561 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
562 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
563 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
564 |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
565 OrthancStone::IVolumeSlicer::IExtractedSlice* |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
566 OrthancSeriesVolumeProgressiveLoader::ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
567 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
568 if (volume_->HasGeometry()) |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
569 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
570 return new ExtractedSlice(*this, cuttingPlane); |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
571 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
572 else |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
573 { |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
574 return new IVolumeSlicer::InvalidSlice; |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
575 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
576 } |
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
577 } |