Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/DicomStructureSet2.cpp @ 1534:0443d04416d9
don't discard the windowing altered by mouse
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 21:48:43 +0200 |
parents | 244ad1e4e76a |
children | 4fb8fdf03314 |
rev | line source |
---|---|
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1019
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
21 #ifdef BGO_ENABLE_DICOMSTRUCTURESETLOADER2 |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
22 |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #include "DicomStructureSet2.h" |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
25 #include "../Toolbox/LinearAlgebra.h" |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
26 #include "../StoneException.h" |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
28 #include <Logging.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
29 #include <OrthancException.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
30 #include <Toolbox.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
31 #include <DicomFormat/DicomTag.h> |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
32 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
33 #include <FullOrthancDataset.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
34 #include <DicomDatasetReader.h> |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 namespace OrthancStone |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_GEOMETRIC_TYPE(0x3006, 0x0042); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_IMAGE_SEQUENCE(0x3006, 0x0016); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_SEQUENCE(0x3006, 0x0040); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 static const OrthancPlugins::DicomTag DICOM_TAG_CONTOUR_DATA(0x3006, 0x0050); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 static const OrthancPlugins::DicomTag DICOM_TAG_NUMBER_OF_CONTOUR_POINTS(0x3006, 0x0046); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 static const OrthancPlugins::DicomTag DICOM_TAG_REFERENCED_SOP_INSTANCE_UID(0x0008, 0x1155); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_CONTOUR_SEQUENCE(0x3006, 0x0039); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_DISPLAY_COLOR(0x3006, 0x002a); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 static const OrthancPlugins::DicomTag DICOM_TAG_ROI_NAME(0x3006, 0x0026); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_INTERPRETED_TYPE(0x3006, 0x00a4); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 static const OrthancPlugins::DicomTag DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE(0x3006, 0x0080); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 static const OrthancPlugins::DicomTag DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE(0x3006, 0x0020); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
51 static inline uint8_t ConvertAndClipToByte(double v) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 if (v < 0) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 return 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 else if (v >= 255) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 return 255; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 else |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 return static_cast<uint8_t>(v); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
67 static bool ReadDicomToVector(Vector& target, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
68 const OrthancPlugins::IDicomDataset& dataset, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
69 const OrthancPlugins::DicomPath& tag) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 std::string value; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 return (dataset.GetStringValue(value, tag) && |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
73 LinearAlgebra::ParseVector(target, value)); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 } |
1010
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
75 |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
76 |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
77 void DicomPathToString(std::string& s, const OrthancPlugins::DicomPath& dicomPath) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
79 std::stringstream tmp; |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
80 for (size_t i = 0; i < dicomPath.GetPrefixLength(); ++i) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
82 OrthancPlugins::DicomTag tag = dicomPath.GetPrefixTag(i); |
1010
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
83 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
84 // We use this other object to be able to use GetMainTagsName |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
85 // and Format |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
86 Orthanc::DicomTag tag2(tag.GetGroup(), tag.GetElement()); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
87 size_t index = dicomPath.GetPrefixIndex(i); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
88 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ") [" << index << "] / "; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 } |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
90 const OrthancPlugins::DicomTag& tag = dicomPath.GetFinalTag(); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
91 Orthanc::DicomTag tag2(tag.GetGroup(), tag.GetElement()); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
92 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ")"; |
1010
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
93 s = tmp.str(); |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
94 } |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
95 |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
96 std::ostream& operator<<(std::ostream& s, const OrthancPlugins::DicomPath& dicomPath) |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
97 { |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
98 std::string tmp; |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
99 DicomPathToString(tmp, dicomPath); |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
100 s << tmp; |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
101 return s; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 |
1006
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
105 DicomStructureSet2::DicomStructureSet2() |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
106 { |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
107 |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
108 } |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
109 |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
110 |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
111 DicomStructureSet2::~DicomStructureSet2() |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
112 { |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
113 |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
114 } |
4f28d9459e31
Fixed unit tests and deprecated classes according to last API changes. UT all run ok.
Benjamin Golinvaux <bgo@osimis.io>
parents:
998
diff
changeset
|
115 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
116 void DicomStructureSet2::SetContents(const OrthancPlugins::FullOrthancDataset& tags) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
118 FillStructuresFromDataset(tags); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
119 ComputeDependentProperties(); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
120 } |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
121 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
122 void DicomStructureSet2::ComputeDependentProperties() |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
123 { |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
124 for (size_t i = 0; i < structures_.size(); ++i) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
126 structures_[i].ComputeDependentProperties(); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
130 void DicomStructureSet2::FillStructuresFromDataset(const OrthancPlugins::FullOrthancDataset& tags) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 OrthancPlugins::DicomDatasetReader reader(tags); |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
133 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
134 // a few sanity checks |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
135 size_t count = 0, tmp = 0; |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
136 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
137 // DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE (0x3006, 0x0080); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
138 // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
139 // DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE (0x3006, 0x0020); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 if (!tags.GetSequenceSize(count, DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE) || |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
141 !tags.GetSequenceSize(tmp, DICOM_TAG_ROI_CONTOUR_SEQUENCE) || |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
142 tmp != count || |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
143 !tags.GetSequenceSize(tmp, DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE) || |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
144 tmp != count) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
149 // let's now parse the structures stored in the dicom file |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
150 // DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE (0x3006, 0x0080) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
151 // DICOM_TAG_RT_ROI_INTERPRETED_TYPE (0x3006, 0x00a4) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
152 // DICOM_TAG_ROI_DISPLAY_COLOR (0x3006, 0x002a) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
153 // DICOM_TAG_ROI_NAME (0x3006, 0x0026) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 structures_.resize(count); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 for (size_t i = 0; i < count; i++) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
157 // (0x3006, 0x0080)[i]/(0x3006, 0x00a4) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 structures_[i].interpretation_ = reader.GetStringValue |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
159 (OrthancPlugins::DicomPath(DICOM_TAG_RT_ROI_OBSERVATIONS_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
160 DICOM_TAG_RT_ROI_INTERPRETED_TYPE), |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
161 "No interpretation"); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
163 // (0x3006, 0x0020)[i]/(0x3006, 0x0026) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 structures_[i].name_ = reader.GetStringValue |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
165 (OrthancPlugins::DicomPath(DICOM_TAG_STRUCTURE_SET_ROI_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
166 DICOM_TAG_ROI_NAME), |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
167 "No name"); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 Vector color; |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
170 // (0x3006, 0x0039)[i]/(0x3006, 0x002a) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
171 if (ReadDicomToVector(color, tags, OrthancPlugins::DicomPath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
172 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_ROI_DISPLAY_COLOR)) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
173 && color.size() == 3) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
175 structures_[i].red_ = ConvertAndClipToByte(color[0]); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
176 structures_[i].green_ = ConvertAndClipToByte(color[1]); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
177 structures_[i].blue_ = ConvertAndClipToByte(color[2]); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 else |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 structures_[i].red_ = 255; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 structures_[i].green_ = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 structures_[i].blue_ = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 size_t countSlices; |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
187 // DICOM_TAG_ROI_CONTOUR_SEQUENCE (0x3006, 0x0039); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
188 // DICOM_TAG_CONTOUR_SEQUENCE (0x3006, 0x0040); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
189 if (!tags.GetSequenceSize(countSlices, OrthancPlugins::DicomPath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
190 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, DICOM_TAG_CONTOUR_SEQUENCE))) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
192 LOG(WARNING) << "DicomStructureSet2::SetContents | structure \"" << structures_[i].name_ << "\" has no slices!"; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 countSlices = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
196 LOG(INFO) << "New RT structure: \"" << structures_[i].name_ |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
197 << "\" with interpretation \"" << structures_[i].interpretation_ |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
198 << "\" containing " << countSlices << " slices (color: " |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
199 << static_cast<int>(structures_[i].red_) << "," |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
200 << static_cast<int>(structures_[i].green_) << "," |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
201 << static_cast<int>(structures_[i].blue_) << ")"; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 // These temporary variables avoid allocating many vectors in the loop below |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
204 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
205 // (0x3006, 0x0039)[i]/(0x3006, 0x0040)[0]/(0x3006, 0x0046) |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
206 OrthancPlugins::DicomPath countPointsPath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
207 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
208 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
209 DICOM_TAG_NUMBER_OF_CONTOUR_POINTS); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
211 OrthancPlugins::DicomPath geometricTypePath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
212 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
213 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
214 DICOM_TAG_CONTOUR_GEOMETRIC_TYPE); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
215 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
216 OrthancPlugins::DicomPath imageSequencePath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
217 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
218 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
219 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 // (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155) |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
222 OrthancPlugins::DicomPath referencedInstancePath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
223 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
224 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
225 DICOM_TAG_CONTOUR_IMAGE_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
226 DICOM_TAG_REFERENCED_SOP_INSTANCE_UID); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
228 OrthancPlugins::DicomPath contourDataPath( |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
229 DICOM_TAG_ROI_CONTOUR_SEQUENCE, i, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
230 DICOM_TAG_CONTOUR_SEQUENCE, 0, |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
231 DICOM_TAG_CONTOUR_DATA); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 for (size_t j = 0; j < countSlices; j++) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
235 unsigned int countPoints = 0; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 countPointsPath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 if (!reader.GetUnsignedIntegerValue(countPoints, countPointsPath)) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 { |
1010
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
240 std::string s; |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
241 DicomPathToString(s, countPointsPath); |
efe1c44628a1
Fixed mysterious revert of a previous change + converted a .cpp to unix LF
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
242 LOG(ERROR) << "Dicom path " << s << " is not valid (should contain an unsigned integer)"; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 } |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
245 |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 //LOG(INFO) << "Parsing slice containing " << countPoints << " vertices"; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 geometricTypePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 std::string type = reader.GetMandatoryStringValue(geometricTypePath); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 if (type != "CLOSED_PLANAR") |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
252 // TODO: support points!! |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 LOG(WARNING) << "Ignoring contour with geometry type: " << type; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 continue; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
257 size_t size = 0; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
258 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 imageSequencePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 if (!tags.GetSequenceSize(size, imageSequencePath) || size != 1) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 LOG(ERROR) << "The ContourImageSequence sequence (tag 3006,0016) must be present and contain one entry."; |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
263 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 referencedInstancePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 std::string sopInstanceUid = reader.GetMandatoryStringValue(referencedInstancePath); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
269 contourDataPath.SetPrefixIndex(1, j); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 std::string slicesData = reader.GetMandatoryStringValue(contourDataPath); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 Vector points; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 if (!LinearAlgebra::ParseVector(points, slicesData) || |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
274 points.size() != 3 * countPoints) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
276 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 // seen in real world |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
280 if (Orthanc::Toolbox::StripSpaces(sopInstanceUid) == "") |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 LOG(ERROR) << "WARNING. The following Dicom tag (Referenced SOP Instance UID) contains an empty value : // (3006,0039)[" << i << "] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)"; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
285 DicomStructurePolygon2 polygon(sopInstanceUid,type); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 polygon.Reserve(countPoints); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 for (size_t k = 0; k < countPoints; k++) |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 Vector v(3); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 v[0] = points[3 * k]; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 v[1] = points[3 * k + 1]; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
293 v[2] = points[3 * k + 2]; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 polygon.AddPoint(v); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 } |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
296 structures_[i].AddPolygon(polygon); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
302 void DicomStructureSet2::Clear() |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
304 structures_.clear(); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 } |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
308 |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
309 #endif |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
310 // BGO_ENABLE_DICOMSTRUCTURESETLOADER2 |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1010
diff
changeset
|
311 |