Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Loaders/DicomVolumeLoader.cpp @ 2068:22a83fb9dd23 deep-learning
added AlignedMatrix and TimerLogger
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 May 2023 17:30:52 +0200 |
parents | 7053b8a0aaec |
children | 990f396484b1 |
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 |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * 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
|
11 * 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
|
12 * |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
1228
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 |
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 "DicomVolumeLoader.h" |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1323
diff
changeset
|
26 #include <Images/ImageProcessing.h> |
1228
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 namespace OrthancStone |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 DicomVolumeLoader::DicomVolumeLoader(boost::shared_ptr<SeriesFramesLoader>& framesLoader, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 bool computeRange) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 framesLoader_(framesLoader), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 isValid_(false), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 started_(false), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 remaining_(0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
37 volume_.reset(new DicomVolumeImage); |
1228
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 const SeriesOrderedFrames& frames = framesLoader_->GetOrderedFrames(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 if (frames.IsRegular3DVolume() && |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 frames.GetFramesCount() > 0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 // 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
|
45 // 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
|
46 // of the normal? |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
47 const DicomInstanceParameters& parameters = frames.GetInstanceParameters(0); |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
49 CoordinateSystem3D plane(frames.GetInstance(0)); |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
51 VolumeImageGeometry geometry; |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 geometry.SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 parameters.GetImageInformation().GetHeight(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 static_cast<unsigned int>(frames.GetFramesCount())); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 geometry.SetAxialGeometry(plane); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 double spacing; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 if (parameters.GetSopClassUid() == SopClassUid_RTDose) |
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 if (!parameters.ComputeRegularSpacing(spacing)) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 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
|
63 spacing = frames.GetSpacingBetweenSlices(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
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 else |
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 spacing = frames.GetSpacingBetweenSlices(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 geometry.SetVoxelDimensions(parameters.GetPixelSpacingX(), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 parameters.GetPixelSpacingY(), spacing); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 volume_->Initialize(geometry, parameters.GetExpectedPixelFormat(), computeRange); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 volume_->GetPixelData().Clear(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 volume_->SetDicomParameters(parameters); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 remaining_ = frames.GetFramesCount(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 isValid_ = true; |
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 else |
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 LOG(WARNING) << "Not a regular 3D volume"; |
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
87 void DicomVolumeLoader::Handle(const SeriesFramesLoader::FrameLoadedMessage& message) |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 if (remaining_ == 0 || |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 !message.HasUserPayload()) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 if (message.GetImage().GetWidth() != volume_->GetPixelData().GetWidth() || |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 message.GetImage().GetHeight() != volume_->GetPixelData().GetHeight()) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 } |
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 if (message.GetImage().GetFormat() != volume_->GetPixelData().GetFormat()) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
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 if (message.GetFrameIndex() >= volume_->GetPixelData().GetDepth()) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 |
1323 | 111 size_t frameIndex = dynamic_cast<const Orthanc::SingleValueObject<size_t>&> |
112 (message.GetUserPayload()).GetValue(); | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 { |
1323 | 115 ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), |
116 VolumeProjection_Axial, | |
117 static_cast<unsigned int>(frameIndex)); | |
118 | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage()); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 } |
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 volume_->IncrementRevision(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 { |
1323 | 125 VolumeUpdatedMessage updated(*this, |
126 static_cast<unsigned int>(frameIndex)); | |
127 | |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 BroadcastMessage(updated); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 } |
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 remaining_--; |
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 if (remaining_ == 0) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 VolumeReadyMessage ready(*this); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 BroadcastMessage(ready); |
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 DicomVolumeLoader::Factory::Factory(LoadedDicomResources& instances) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 framesFactory_(instances), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 computeRange_(false) |
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 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
1476
4db187d29731
renamed SeriesMetadataLoader::SeriesLoadedMessage to SuccessMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
147 DicomVolumeLoader::Factory::Factory(const SeriesMetadataLoader::SuccessMessage& metadata) : |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 framesFactory_(metadata.GetInstances()), |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 computeRange_(false) |
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 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
|
152 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
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<IObserver> DicomVolumeLoader::Factory::Create(ILoadersContext::ILock& context) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 boost::shared_ptr<SeriesFramesLoader> frames = |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 boost::dynamic_pointer_cast<SeriesFramesLoader>(framesFactory_.Create(context)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 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
|
161 volume->Register<SeriesFramesLoader::FrameLoadedMessage>(*frames, &DicomVolumeLoader::Handle); |
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 return volume; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 void DicomVolumeLoader::Start(int priority, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 const DicomSource& source) |
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 if (started_) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |
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 started_ = true; |
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 if (IsValid()) |
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 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
|
179 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 framesLoader_->ScheduleLoadFrame(priority, source, i, source.GetQualityCount() - 1, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 new Orthanc::SingleValueObject<size_t>(i)); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 } |
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 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 VolumeReadyMessage ready(*this); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 BroadcastMessage(ready); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |