annotate OrthancFramework/Sources/DicomNetworking/DicomFindAnswers.cpp @ 4204:318c16cfccab

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Sep 2020 16:18:01 +0200
parents bf7b9edf6b81
children 0034f855c023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1860
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3276
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 62
diff changeset
11 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
23 #include "../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "DicomFindAnswers.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
26 #include "../DicomParsing/FromDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
27 #include "../OrthancException.h"
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
28
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
29 #include <memory>
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
30 #include <dcmtk/dcmdata/dcfilefo.h>
1847
559956d5ceb2 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1797
diff changeset
31 #include <boost/noncopyable.hpp>
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
32
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
34 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
36 void DicomFindAnswers::AddAnswerInternal(ParsedDicomFile* answer)
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
37 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
38 std::unique_ptr<ParsedDicomFile> protection(answer);
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
39
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
40 if (isWorklist_)
1797
23722a191e4e worklists are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
41 {
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
42 // These lines are necessary when serving worklists, otherwise
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
43 // Orthanc does not behave as "wlmscpfs"
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
44 protection->Remove(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
45 protection->Remove(DICOM_TAG_SOP_INSTANCE_UID);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
46 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
47
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
48 protection->ChangeEncoding(encoding_);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
49
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
50 answers_.push_back(protection.release());
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
51 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
52
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
53
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
54 DicomFindAnswers::DicomFindAnswers(bool isWorklist) :
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
55 encoding_(GetDefaultDicomEncoding()),
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
56 isWorklist_(isWorklist),
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
57 complete_(true)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
58 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
59 }
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
60
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
61
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
62 void DicomFindAnswers::SetEncoding(Encoding encoding)
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
63 {
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
64 for (size_t i = 0; i < answers_.size(); i++)
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
65 {
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
66 assert(answers_[i] != NULL);
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
67 answers_[i]->ChangeEncoding(encoding);
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
68 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
69
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
70 encoding_ = encoding;
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
71 }
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
72
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
73
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
74 void DicomFindAnswers::SetWorklist(bool isWorklist)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
75 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
76 if (answers_.empty())
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
77 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
78 isWorklist_ = isWorklist;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
79 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
80 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
81 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
82 // This set of answers is not empty anymore, cannot change its type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
83 throw OrthancException(ErrorCode_BadSequenceOfCalls);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
84 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
85 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
86
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1995
diff changeset
87
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void DicomFindAnswers::Clear()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
90 for (size_t i = 0; i < answers_.size(); i++)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
92 assert(answers_[i] != NULL);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
93 delete answers_[i];
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
95
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
96 answers_.clear();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
99
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 void DicomFindAnswers::Reserve(size_t size)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
102 if (size > answers_.size())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
104 answers_.reserve(size);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
108
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
109 void DicomFindAnswers::Add(const DicomMap& map)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
110 {
3276
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3158
diff changeset
111 // We use the permissive mode to be tolerant wrt. invalid DICOM
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3158
diff changeset
112 // files that contain some tags with out-of-range values (such
9b0e67161600 More tolerance wrt. invalid DICOM files that must be returned by Orthanc C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3158
diff changeset
113 // tags are removed from the answers)
4035
cc6ed76bba27 added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
114 AddAnswerInternal(new ParsedDicomFile(map, encoding_, true /* permissive */));
cc6ed76bba27 added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
115 //"" /* no private creator */));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
116 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
117
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
118
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
119 void DicomFindAnswers::Add(const ParsedDicomFile& dicom)
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
120 {
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
121 AddAnswerInternal(dicom.Clone(true));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
122 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
123
1995
f0acfa753973 New callback to handle non-worklists C-Find requests: OrthancPluginRegisterCFindCallback()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
124 void DicomFindAnswers::Add(const void* dicom,
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
125 size_t size)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
126 {
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
127 AddAnswerInternal(new ParsedDicomFile(dicom, size));
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
128 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
129
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
130
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
131 ParsedDicomFile& DicomFindAnswers::GetAnswer(size_t index) const
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
132 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
133 if (index < answers_.size())
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
134 {
2207
6dc3bdb4088b Fix handling of encodings in C-FIND for worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2202
diff changeset
135 return *answers_[index];
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
136 }
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
137 else
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
138 {
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
139 throw OrthancException(ErrorCode_ParameterOutOfRange);
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
140 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
141 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
142
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
143
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
144 DcmDataset* DicomFindAnswers::ExtractDcmDataset(size_t index) const
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
145 {
3158
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
146 // As "DicomFindAnswers" stores its content using class
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
147 // "ParsedDicomFile" (that internally uses "DcmFileFormat" from
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
148 // DCMTK), the dataset can contain tags that are reserved if
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
149 // storing the media on the disk, notably tag
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
150 // "MediaStorageSOPClassUID" (0002,0002). In this function, we
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
151 // remove all those tags whose group is below 0x0008. The
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
152 // resulting data set is clean for emission in the C-FIND SCP.
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
153
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
154 // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#sect_C.4.1.1.3
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
155 // https://groups.google.com/d/msg/orthanc-users/D3kpPuX8yV0/_zgHOzkMEQAJ
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
156
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
157 DcmDataset& source = *GetAnswer(index).GetDcmtkObject().getDataset();
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
158
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
159 std::unique_ptr<DcmDataset> target(new DcmDataset);
3158
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
160
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
161 for (unsigned long i = 0; i < source.card(); i++)
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
162 {
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
163 const DcmElement* element = source.getElement(i);
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
164 assert(element != NULL);
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
165
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
166 if (element != NULL &&
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
167 element->getTag().getGroup() >= 0x0008 &&
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
168 element->getTag().getElement() != 0x0000)
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
169 {
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
170 target->insert(dynamic_cast<DcmElement*>(element->clone()));
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
171 }
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
172 }
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
173
b6e7714c3fe6 Don't return tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
174 return target.release();
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
175 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
176
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
177
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
178 void DicomFindAnswers::ToJson(Json::Value& target,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
179 size_t index,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
180 bool simplify) const
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
181 {
1860
c7d70f659190 DicomToJsonFormat_Simple -> DicomToJsonFormat_Human
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1847
diff changeset
182 DicomToJsonFormat format = (simplify ? DicomToJsonFormat_Human : DicomToJsonFormat_Full);
2128
9329ba17a069 Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2059
diff changeset
183 GetAnswer(index).DatasetToJson(target, format, DicomToJsonFlags_None, 0);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
184 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
185
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
186
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
187 void DicomFindAnswers::ToJson(Json::Value& target,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
188 bool simplify) const
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 target = Json::arrayValue;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 for (size_t i = 0; i < GetSize(); i++)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
194 Json::Value answer;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
195 ToJson(answer, i, simplify);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 target.append(answer);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }