Mercurial > hg > orthanc-stone
annotate Framework/Loaders/DicomVolumeLoader.cpp @ 1326:55166e57a77c broker
doc
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 24 Mar 2020 21:32:35 +0100 |
parents | c0af7657d398 |
children | 30deba7bc8e2 |
rev | line source |
---|---|
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1271
0ca50d275b9a
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "DicomVolumeLoader.h" |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <Core/Images/ImageProcessing.h> |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 namespace OrthancStone |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 DicomVolumeLoader::DicomVolumeLoader(boost::shared_ptr<SeriesFramesLoader>& framesLoader, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 bool computeRange) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 framesLoader_(framesLoader), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 isValid_(false), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 started_(false), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 remaining_(0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 volume_.reset(new OrthancStone::DicomVolumeImage); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 const SeriesOrderedFrames& frames = framesLoader_->GetOrderedFrames(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 if (frames.IsRegular3DVolume() && |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 frames.GetFramesCount() > 0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 // TODO - Is "0" the good choice for the reference frame? |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 // Shouldn't we use "count - 1" depending on the direction |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 // of the normal? |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 const OrthancStone::DicomInstanceParameters& parameters = frames.GetInstanceParameters(0); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 OrthancStone::CoordinateSystem3D plane(frames.GetInstance(0)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 OrthancStone::VolumeImageGeometry geometry; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 geometry.SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 parameters.GetImageInformation().GetHeight(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 static_cast<unsigned int>(frames.GetFramesCount())); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 geometry.SetAxialGeometry(plane); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 double spacing; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 if (parameters.GetSopClassUid() == SopClassUid_RTDose) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 if (!parameters.ComputeRegularSpacing(spacing)) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 LOG(WARNING) << "Unable to compute the spacing in a RT-DOSE instance"; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 spacing = frames.GetSpacingBetweenSlices(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 spacing = frames.GetSpacingBetweenSlices(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 geometry.SetVoxelDimensions(parameters.GetPixelSpacingX(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 parameters.GetPixelSpacingY(), spacing); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 volume_->Initialize(geometry, parameters.GetExpectedPixelFormat(), computeRange); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 volume_->GetPixelData().Clear(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 volume_->SetDicomParameters(parameters); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 remaining_ = frames.GetFramesCount(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 isValid_ = true; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 LOG(WARNING) << "Not a regular 3D volume"; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 void DicomVolumeLoader::Handle(const OrthancStone::SeriesFramesLoader::FrameLoadedMessage& message) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 if (remaining_ == 0 || |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 !message.HasUserPayload()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 if (message.GetImage().GetWidth() != volume_->GetPixelData().GetWidth() || |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 message.GetImage().GetHeight() != volume_->GetPixelData().GetHeight()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 if (message.GetImage().GetFormat() != volume_->GetPixelData().GetFormat()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 if (message.GetFrameIndex() >= volume_->GetPixelData().GetDepth()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
1323 | 109 size_t frameIndex = dynamic_cast<const Orthanc::SingleValueObject<size_t>&> |
110 (message.GetUserPayload()).GetValue(); | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 { |
1323 | 113 ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), |
114 VolumeProjection_Axial, | |
115 static_cast<unsigned int>(frameIndex)); | |
116 | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage()); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 volume_->IncrementRevision(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
1323 | 123 VolumeUpdatedMessage updated(*this, |
124 static_cast<unsigned int>(frameIndex)); | |
125 | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 BroadcastMessage(updated); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 remaining_--; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 if (remaining_ == 0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 VolumeReadyMessage ready(*this); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 BroadcastMessage(ready); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 DicomVolumeLoader::Factory::Factory(LoadedDicomResources& instances) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 framesFactory_(instances), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 computeRange_(false) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 DicomVolumeLoader::Factory::Factory(const SeriesMetadataLoader::SeriesLoadedMessage& metadata) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 framesFactory_(metadata.GetInstances()), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 computeRange_(false) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 SetDicomDir(metadata.GetDicomDirPath(), metadata.GetDicomDir()); // Only useful for DICOMDIR sources |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 boost::shared_ptr<IObserver> DicomVolumeLoader::Factory::Create(ILoadersContext::ILock& context) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 boost::shared_ptr<SeriesFramesLoader> frames = |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 boost::dynamic_pointer_cast<SeriesFramesLoader>(framesFactory_.Create(context)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 boost::shared_ptr<DicomVolumeLoader> volume(new DicomVolumeLoader(frames, computeRange_)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 volume->Register<SeriesFramesLoader::FrameLoadedMessage>(*frames, &DicomVolumeLoader::Handle); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 return volume; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 void DicomVolumeLoader::Start(int priority, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 const DicomSource& source) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 if (started_) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 started_ = true; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 if (IsValid()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 for (size_t i = 0; i < GetOrderedFrames().GetFramesCount(); i++) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 framesLoader_->ScheduleLoadFrame(priority, source, i, source.GetQualityCount() - 1, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 new Orthanc::SingleValueObject<size_t>(i)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 VolumeReadyMessage ready(*this); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 BroadcastMessage(ready); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 } |