annotate OrthancStone/Sources/Toolbox/SortedFrames.cpp @ 1598:8563ea5d8ae4

relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2020 20:49:28 +0100
parents 4fb8fdf03314
children 73cd85d7da6a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * modify it under the terms of the GNU Lesser General Public License
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
16 *
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
17 * 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
18 * 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
19 * <http://www.gnu.org/licenses/>.
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "SortedFrames.h"
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
1490
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
25 #include "GeometryToolbox.h"
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
1490
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
27 #include <OrthancException.h>
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
28 #include <Toolbox.h>
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace OrthancStone
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 SortedFrames::Instance::Instance(const Orthanc::DicomMap& tags)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 tags_.Assign(tags);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 if (!tags.LookupStringValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 uint32_t tmp;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 if (tags.ParseUnsignedInteger32(tmp, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 numberOfFrames_ = tmp;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 numberOfFrames_ = 1;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
1490
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
51 std::string photometric;
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
52 if (tags.LookupStringValue(photometric, Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION, false))
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
53 {
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
54 Orthanc::Toolbox::StripSpaces(photometric);
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
55 monochrome1_ = (photometric == "MONOCHROME1");
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
56 }
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
57 else
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
58 {
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
59 monochrome1_ = false;
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
60 }
5d892f5dd9c4 SortedFrames::IsFrameMonochrome1()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1485
diff changeset
61
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 hasPosition_ = (
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 LinearAlgebra::ParseVector(position_, tags, Orthanc::DICOM_TAG_IMAGE_POSITION_PATIENT) &&
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 position_.size() == 3 &&
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 GeometryToolbox::ComputeNormal(normal_, tags));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 const Vector& SortedFrames::Instance::GetNormal() const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 if (hasPosition_)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 return normal_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 const Vector& SortedFrames::Instance::GetPosition() const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 if (hasPosition_)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 return position_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 SortedFrames::Frame::Frame(const Instance& instance,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 unsigned int frameIndex) :
1485
60be4627ae52 fix for msvc2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1479
diff changeset
97 instance_(&instance),
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 frameIndex_(frameIndex)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 if (frameIndex >= instance.GetNumberOfFrames())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 const SortedFrames::Instance& SortedFrames::GetInstance(size_t index) const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 if (index >= instances_.size())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 assert(instances_[index] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 return *instances_[index];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 const SortedFrames::Frame& SortedFrames::GetFrame(size_t index) const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 if (!sorted_)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 "Sort() has not been called");
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 if (index >= frames_.size())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 return frames_[index];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
1479
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
139 void SortedFrames::Clear()
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 for (size_t i = 0; i < instances_.size(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 assert(instances_[i] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 delete instances_[i];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
1479
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
146
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
147 studyInstanceUid_.clear();
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
148 seriesInstanceUid_.clear();
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
149 frames_.clear();
5e3cfe87a873 SortedFrames::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1478
diff changeset
150 sorted_ = true;
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 void SortedFrames::AddInstance(const Orthanc::DicomMap& tags)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 std::unique_ptr<Instance> instance(new Instance(tags));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 std::string studyInstanceUid, seriesInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 if (!tags.LookupStringValue(studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) ||
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 !tags.LookupStringValue(seriesInstanceUid, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 if (instances_.empty())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 studyInstanceUid_ = studyInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 seriesInstanceUid_ = seriesInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 if (studyInstanceUid_ != studyInstanceUid ||
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 seriesInstanceUid_ != seriesInstanceUid)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 "Mixing instances from different series");
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 instances_.push_back(instance.release());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 sorted_ = false;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 frames_.clear();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 void SortedFrames::AddFramesOfInstance(std::set<size_t>& remainingInstances,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 size_t index)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 assert(instances_[index] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 const Instance& instance = *instances_[index];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 for (unsigned int i = 0; i < instance.GetNumberOfFrames(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 frames_.push_back(Frame(instance, i));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 assert(remainingInstances.find(index) != remainingInstances.end());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 remainingInstances.erase(index);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 namespace
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 template<typename T>
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 class SortableItem
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 private:
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 T value_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 size_t instance_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 std::string sopInstanceUid_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 public:
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 SortableItem(const T& value,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 size_t instance,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 const std::string& sopInstanceUid) :
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 value_(value),
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 instance_(instance),
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 sopInstanceUid_(sopInstanceUid)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 size_t GetInstanceIndex() const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 return instance_;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 bool operator< (const SortableItem& other) const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 return (value_ < other.value_ ||
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 (value_ == other.value_ &&
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 sopInstanceUid_ < other.sopInstanceUid_));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 };
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 void SortedFrames::SortUsingIntegerTag(std::set<size_t>& remainingInstances,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 const Orthanc::DicomTag& tag)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 std::vector< SortableItem<int32_t> > items;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 items.reserve(remainingInstances.size());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 for (std::set<size_t>::const_iterator it = remainingInstances.begin();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 it != remainingInstances.end(); ++it)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 assert(instances_[*it] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 const Instance& instance = *instances_[*it];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 int32_t value;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 std::string sopInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 if (instance.GetTags().ParseInteger32(value, tag) &&
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 instance.GetTags().LookupStringValue(
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 items.push_back(SortableItem<int32_t>(value, *it, sopInstanceUid));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 std::sort(items.begin(), items.end());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 for (size_t i = 0; i < items.size(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 AddFramesOfInstance(remainingInstances, items[i].GetInstanceIndex());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 void SortedFrames::SortUsingSopInstanceUid(std::set<size_t>& remainingInstances)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 std::vector<SortableItem<int32_t> > items;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 items.reserve(remainingInstances.size());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 for (std::set<size_t>::const_iterator it = remainingInstances.begin();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 it != remainingInstances.end(); ++it)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 assert(instances_[*it] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 const Instance& instance = *instances_[*it];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 std::string sopInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 if (instance.GetTags().LookupStringValue(
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 items.push_back(SortableItem<int32_t>(0 /* arbitrary value */, *it, sopInstanceUid));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 std::sort(items.begin(), items.end());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 for (size_t i = 0; i < items.size(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 AddFramesOfInstance(remainingInstances, items[i].GetInstanceIndex());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 void SortedFrames::SortUsing3DLocation(std::set<size_t>& remainingInstances)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 /**
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 * Compute the mean of the normal vectors, using the recursive
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 * formula for arithmetic means for numerical stability.
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 * https://diego.assencio.com/?index=c34d06f4f4de2375658ed41f70177d59
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 **/
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 Vector meanNormal;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 LinearAlgebra::AssignVector(meanNormal, 0, 0, 0);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 unsigned int n = 0;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 for (std::set<size_t>::const_iterator it = remainingInstances.begin();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 it != remainingInstances.end(); ++it)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 assert(instances_[*it] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 const Instance& instance = *instances_[*it];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 if (instance.HasPosition())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 n += 1;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 meanNormal += (instance.GetNormal() - meanNormal) / static_cast<float>(n);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 std::vector<SortableItem<float> > items;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 items.reserve(n);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 for (std::set<size_t>::const_iterator it = remainingInstances.begin();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 it != remainingInstances.end(); ++it)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 assert(instances_[*it] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 const Instance& instance = *instances_[*it];
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 std::string sopInstanceUid;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 if (instance.HasPosition() &&
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 instance.GetTags().LookupStringValue(
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 sopInstanceUid, Orthanc::DICOM_TAG_SOP_INSTANCE_UID, false))
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 double p = LinearAlgebra::DotProduct(meanNormal, instance.GetPosition());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 items.push_back(SortableItem<float>(p, *it, sopInstanceUid));
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 assert(items.size() <= n);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 std::sort(items.begin(), items.end());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 for (size_t i = 0; i < items.size(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 AddFramesOfInstance(remainingInstances, items[i].GetInstanceIndex());
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 size_t SortedFrames::GetFramesCount() const
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 if (sorted_)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 return frames_.size();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 else
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 "Sort() has not been called");
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 void SortedFrames::Sort()
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 if (!sorted_)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 size_t totalFrames = 0;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 std::set<size_t> remainingInstances;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 for (size_t i = 0; i < instances_.size(); i++)
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 assert(instances_[i] != NULL);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 totalFrames += instances_[i]->GetNumberOfFrames();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 remainingInstances.insert(i);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 frames_.clear();
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 frames_.reserve(totalFrames);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 SortUsingIntegerTag(remainingInstances, Orthanc::DICOM_TAG_INSTANCE_NUMBER); // VR is "IS"
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 SortUsingIntegerTag(remainingInstances, Orthanc::DICOM_TAG_IMAGE_INDEX); // VR is "US"
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 SortUsing3DLocation(remainingInstances);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 SortUsingSopInstanceUid(remainingInstances);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 // The following could in theory happen if several instances
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 // have the same SOPInstanceUID, no ordering is available
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 for (std::set<size_t>::const_iterator it = remainingInstances.begin();
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
392 it != remainingInstances.end(); ++it)
1478
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 AddFramesOfInstance(remainingInstances, *it);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 if (frames_.size() != totalFrames ||
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 !remainingInstances.empty())
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 {
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 sorted_ = true;
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 }
fab6c6e795a3 Framework/Toolbox/SortedFrames.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 }