Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomStructureSet2.cpp @ 1002:341e68752354
dot product
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 20 Sep 2019 12:00:04 +0200 |
parents | 38b6bb0bdd72 |
children | 4f28d9459e31 |
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 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
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 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "DicomStructureSet2.h" |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
23 #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
|
24 #include "../StoneException.h" |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 #include <Core/Logging.h> |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 #include <Core/OrthancException.h> |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include <Core/Toolbox.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
|
29 #include <Core/DicomFormat/DicomTag.h> |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
30 |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 #include <Plugins/Samples/Common/FullOrthancDataset.h> |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 #include <Plugins/Samples/Common/DicomDatasetReader.h> |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 namespace OrthancStone |
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 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
49 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
|
50 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 if (v < 0) |
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 return 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 else if (v >= 255) |
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 return 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 else |
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 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
|
62 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 std::string value; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 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
|
71 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
|
72 } |
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 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
74 std::ostream& operator<<(std::ostream& 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
|
75 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
76 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
|
77 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
|
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 OrthancPlugins::DicomTag tag = dicomPath.GetPrefixTag(i); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
80 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
81 // 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
|
82 // 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
|
83 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
|
84 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
|
85 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
|
86 } |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
87 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
|
88 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
|
89 tmp << tag2.GetMainTagsName() << " (" << tag2.Format() << ")"; |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
90 s << tmp.str(); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
91 return s; |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
95 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
|
96 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
97 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
|
98 ComputeDependentProperties(); |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
99 } |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
100 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
101 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
|
102 { |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
103 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
|
104 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
105 structures_[i].ComputeDependentProperties(); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
109 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
|
110 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 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
|
112 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
113 // 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
|
114 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
|
115 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
116 // 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
|
117 // 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
|
118 // 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
|
119 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
|
120 !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
|
121 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
|
122 !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
|
123 tmp != count) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 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
|
126 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
128 // 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
|
129 // 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
|
130 // 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
|
131 // 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
|
132 // 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
|
133 structures_.resize(count); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 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
|
135 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
136 // (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
|
137 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
|
138 (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
|
139 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
|
140 "No interpretation"); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
142 // (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
|
143 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
|
144 (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
|
145 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
|
146 "No name"); |
987
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 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
|
149 // (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
|
150 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
|
151 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
|
152 && color.size() == 3) |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
154 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
|
155 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
|
156 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
|
157 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 else |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 structures_[i].red_ = 255; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 structures_[i].green_ = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 structures_[i].blue_ = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 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
|
166 // 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
|
167 // 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
|
168 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
|
169 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
|
170 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
171 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
|
172 countSlices = 0; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 } |
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 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
|
176 << "\" 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
|
177 << "\" 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
|
178 << 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
|
179 << 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
|
180 << 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
|
181 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 // 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
|
183 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
184 // (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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 |
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 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
|
199 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 // (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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 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
|
211 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 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
|
213 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
214 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
|
215 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 countPointsPath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 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
|
218 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
219 LOG(ERROR) << "Dicom path " << countPointsPath << " 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
|
220 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
|
221 } |
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 |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 //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
|
224 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 geometricTypePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 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
|
227 if (type != "CLOSED_PLANAR") |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
229 // TODO: support points!! |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 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
|
231 continue; |
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 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
234 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
|
235 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 imageSequencePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 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
|
238 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 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
|
240 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
|
241 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 referencedInstancePath.SetPrefixIndex(1, j); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 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
|
245 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
246 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
|
247 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
|
248 |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 Vector points; |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 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
|
251 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
|
252 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
253 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
|
254 } |
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 // 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
|
257 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
|
258 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 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
|
260 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
262 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
|
263 polygon.Reserve(countPoints); |
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 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
|
266 { |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 Vector v(3); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 polygon.AddPoint(v); |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 } |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
273 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
|
274 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 } |
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 } |
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 |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
279 void DicomStructureSet2::Clear() |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 { |
998
38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
Benjamin Golinvaux <bgo@osimis.io>
parents:
994
diff
changeset
|
281 structures_.clear(); |
987
d225bccd4d4a
Scaffolding for A/B tests with DicomStructureSet[Loader] (A/B testing)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 } |
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 } |