Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/ParsedDicomDataset.cpp @ 1477:5732edec7cbd
sorting frames in 3D
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Jun 2020 15:48:59 +0200 |
parents | 0ca50d275b9a |
children | d8af188ab545 |
rev | line source |
---|---|
1180
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1271
0ca50d275b9a
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1180
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1180
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "ParsedDicomDataset.h" |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <dcmtk/dcmdata/dcfilefo.h> |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 namespace OrthancStone |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 static DcmItem* LookupPath(Orthanc::ParsedDicomFile& dicom, |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 const OrthancPlugins::DicomPath& path) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 DcmItem* node = dicom.GetDcmtkObject().getDataset(); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 for (size_t i = 0; i < path.GetPrefixLength(); i++) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 const OrthancPlugins::DicomTag& tmp = path.GetPrefixTag(i); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 DcmTagKey tag(tmp.GetGroup(), tmp.GetElement()); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 DcmSequenceOfItems* sequence = NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 if (!node->findAndGetSequence(tag, sequence).good() || |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 sequence == NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 return NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 unsigned long pos = path.GetPrefixIndex(i); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 if (pos >= sequence->card()) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 return NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 node = sequence->getItem(pos); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 if (node == NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 return NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 return node; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 bool ParsedDicomDataset::GetStringValue(std::string& result, |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 const OrthancPlugins::DicomPath& path) const |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 DcmItem* node = LookupPath(dicom_, path); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 if (node != NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 DcmTagKey tag(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 const char* s = NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 if (node->findAndGetString(tag, s).good() && |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 s != NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 result.assign(s); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 return true; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 return false; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 bool ParsedDicomDataset::GetSequenceSize(size_t& size, |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 const OrthancPlugins::DicomPath& path) const |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 DcmItem* node = LookupPath(dicom_, path); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 if (node != NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 DcmTagKey tag(path.GetFinalTag().GetGroup(), path.GetFinalTag().GetElement()); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 DcmSequenceOfItems* s = NULL; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 if (node->findAndGetSequence(tag, s).good() && |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 s != NULL) |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 size = s->card(); |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 return true; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 return false; |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 } |
9c8f557ea799
ParsedDicomDataset to speed up loading RT-STRUCT from parsed DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |