Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Loaders/LoadedDicomResources.cpp @ 2129:169e2e586ef7 StoneWebViewer-2.2
closing StoneWebViewer-2.2
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 17:08:21 +0200 |
parents | 0489fe25ce48 |
children | 3889ae96d2e9 |
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 |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 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 |
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 |
1228
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 |
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:
1512
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/>. |
1228
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "LoadedDicomResources.h" |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
25 #include <OrthancException.h> |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include <cassert> |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
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 namespace OrthancStone |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 { |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
32 LoadedDicomResources::Resource::Resource(const Orthanc::DicomMap& dicom) : |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
33 dicom_(dicom.Clone()) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
34 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
35 if (dicom_.get() == NULL) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
36 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
37 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
38 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
39 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
40 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
41 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
42 LoadedDicomResources::Resource* LoadedDicomResources::Resource::Clone() const |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
43 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
44 assert(dicom_.get() != NULL); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
45 return new Resource(*dicom_); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
46 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
47 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
48 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
49 const Json::Value& LoadedDicomResources::Resource::GetSourceJson() const |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
50 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
51 if (sourceJson_.get() == NULL) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
52 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
53 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
54 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
55 else |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
56 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
57 return *sourceJson_; |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
58 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
59 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
60 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
61 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
62 void LoadedDicomResources::Resource::SetSourceJson(const Json::Value& json) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
63 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
64 sourceJson_.reset(new Json::Value(json)); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
65 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
66 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
67 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
68 void LoadedDicomResources::AddResourceInternal(Resource* resource) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
69 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
70 std::unique_ptr<Resource> protection(resource); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
71 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
72 std::string id; |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
73 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
74 if (protection->GetDicom().LookupStringValue(id, indexedTag_, false /* no binary value */) && |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
75 resources_.find(id) == resources_.end() /* Don't index twice the same resource */) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
76 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
77 resources_[id] = protection.release(); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
78 flattened_.clear(); // Invalidate the flattened version |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
79 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
80 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
81 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
82 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
83 const LoadedDicomResources::Resource& LoadedDicomResources::GetResourceInternal(size_t index) |
1228
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 // Lazy generation of a "std::vector" from the "std::map" |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 if (flattened_.empty()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 flattened_.resize(resources_.size()); |
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 size_t pos = 0; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 for (Resources::const_iterator it = resources_.begin(); it != resources_.end(); ++it) |
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 assert(it->second != NULL); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 flattened_[pos++] = it->second; |
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 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 else |
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 // No need to flatten |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 assert(flattened_.size() == resources_.size()); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
102 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
103 if (index >= flattened_.size()) |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
104 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
105 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
106 } |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
107 else |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
108 { |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
109 assert(flattened_[index] != NULL); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
110 return *flattened_[index]; |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
111 } |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 } |
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 void LoadedDicomResources::AddFromDicomWebInternal(const Json::Value& dicomweb) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 assert(dicomweb.type() == Json::objectValue); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 Orthanc::DicomMap dicom; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 dicom.FromDicomWeb(dicomweb); |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
120 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
121 std::unique_ptr<Resource> resource(new Resource(dicom)); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
122 resource->SetSourceJson(dicomweb); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
123 AddResourceInternal(resource.release()); |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 LoadedDicomResources::LoadedDicomResources(const LoadedDicomResources& other, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 const Orthanc::DicomTag& indexedTag) : |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 indexedTag_(indexedTag) |
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 for (Resources::const_iterator it = other.resources_.begin(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 it != other.resources_.end(); ++it) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 assert(it->second != NULL); |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
135 AddResourceInternal(it->second->Clone()); |
1228
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 void LoadedDicomResources::Clear() |
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 for (Resources::iterator it = resources_.begin(); it != resources_.end(); ++it) |
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 assert(it->second != NULL); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 delete it->second; |
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 resources_.clear(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 flattened_.clear(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 } |
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 |
1250
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
152 void LoadedDicomResources::MergeResource(Orthanc::DicomMap& target, |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
153 const std::string& id) const |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
154 { |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
155 Resources::const_iterator it = resources_.find(id); |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
156 |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
157 if (it == resources_.end()) |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
158 { |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem); |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
160 } |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
161 else |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
162 { |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
163 assert(it->second != NULL); |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
164 target.Merge(it->second->GetDicom()); |
1250
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
165 } |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
166 } |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
167 |
a8248b08115c
LoadedDicomResources::MergeResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1228
diff
changeset
|
168 |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 bool LoadedDicomResources::LookupStringValue(std::string& target, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 const std::string& id, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 const Orthanc::DicomTag& tag) const |
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 Resources::const_iterator found = resources_.find(id); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 if (found == resources_.end()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 return false; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 else |
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 assert(found->second != NULL); |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
182 return found->second->GetDicom().LookupStringValue(target, tag, false); |
1228
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 } |
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 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 void LoadedDicomResources::AddResource(const Orthanc::DicomMap& dicom) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 { |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
189 AddResourceInternal(new Resource(dicom)); |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 void LoadedDicomResources::AddFromOrthanc(const Json::Value& tags) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 Orthanc::DicomMap dicom; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 dicom.FromDicomAsJson(tags); |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
197 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
198 std::unique_ptr<Resource> resource(new Resource(dicom)); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
199 resource->SetSourceJson(tags); |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
200 AddResourceInternal(resource.release()); |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 void LoadedDicomResources::AddFromDicomWeb(const Json::Value& dicomweb) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 if (dicomweb.type() == Json::objectValue) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 AddFromDicomWebInternal(dicomweb); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 else if (dicomweb.type() == Json::arrayValue) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 for (Json::Value::ArrayIndex i = 0; i < dicomweb.size(); i++) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 if (dicomweb[i].type() == Json::objectValue) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 AddFromDicomWebInternal(dicomweb[i]); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 bool LoadedDicomResources::LookupTagValueConsensus(std::string& target, |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 const Orthanc::DicomTag& tag) const |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 typedef std::map<std::string, unsigned int> Counter; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 Counter counter; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 for (Resources::const_iterator it = resources_.begin(); it != resources_.end(); ++it) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 assert(it->second != NULL); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 std::string value; |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
243 if (it->second->GetDicom().LookupStringValue(value, tag, false)) |
1228
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 Counter::iterator found = counter.find(value); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 if (found == counter.end()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 counter[value] = 1; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 found->second ++; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 Counter::const_iterator best = counter.end(); |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 for (Counter::const_iterator it = counter.begin(); it != counter.end(); ++it) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 if (best == counter.end() || |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 best->second < it->second) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 best = it; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 if (best == counter.end()) |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 return false; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 else |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 { |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 target = best->first; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 return true; |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 } |
c471a0aa137b
adding the next generation of loaders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 } |