Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Loaders/DicomStructureSetLoader.cpp @ 1859:58681a5c727b
overlay: display ContentDate/ContentTime instead of StudyDate if available + new 'TimeFormat' option
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 20 Sep 2021 17:08:23 +0200 |
parents | a03260db8835 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
815 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1640
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
815 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
815 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
815 | 20 **/ |
21 | |
22 | |
23 #include "DicomStructureSetLoader.h" | |
24 | |
1339
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
25 #include "../Scene2D/PolylineSceneLayer.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
26 #include "../StoneException.h" |
556b4bc19118
The loaders have been adapter to the nobroker architecture
Benjamin Golinvaux <bgo@osimis.io>
parents:
1337
diff
changeset
|
27 #include "../Toolbox/GeometryToolbox.h" |
815 | 28 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1416
diff
changeset
|
29 #include <Toolbox.h> |
1048
f6be9412e42a
cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1030
diff
changeset
|
30 |
1751
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
31 #if STONE_TIME_BLOCKING_OPS |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
32 # include <boost/date_time/posix_time/posix_time.hpp> |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
33 #endif |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
34 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
35 #include <algorithm> |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
36 |
1337
b1396be5aa27
Moved the fixed loaders back from the dead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
37 namespace OrthancStone |
815 | 38 { |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
39 |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
40 #if 0 |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
41 void DumpDicomMap(std::ostream& o, const Orthanc::DicomMap& dicomMap) |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
42 { |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
43 using namespace std; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
44 //ios_base::fmtflags state = o.flags(); |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
45 //o.flags(ios::right | ios::hex); |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
46 //o << "(" << setfill('0') << setw(4) << tag.GetGroup() |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
47 // << "," << setw(4) << tag.GetElement() << ")"; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
48 //o.flags(state); |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
49 Json::Value val; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
50 dicomMap.Serialize(val); |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
51 o << val; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
52 //return o; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
53 } |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
54 #endif |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
55 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
56 // implementation of IInstanceLookupHandler that uses Orthanc REST API calls to retrive the |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
57 // geometry of referenced instances |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
58 class DicomStructureSetLoader::RestInstanceLookupHandler : public DicomStructureSetLoader::IInstanceLookupHandler, |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
59 public LoaderStateMachine |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
60 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
61 public: |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
62 static boost::shared_ptr<RestInstanceLookupHandler > Create(DicomStructureSetLoader& loader) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
63 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
64 boost::shared_ptr<RestInstanceLookupHandler> obj(new RestInstanceLookupHandler(loader)); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
65 obj->LoaderStateMachine::PostConstructor(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
66 return obj; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
67 } |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
68 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
69 protected: |
1571 | 70 explicit RestInstanceLookupHandler(DicomStructureSetLoader& loader) : |
71 LoaderStateMachine(loader.loadersContext_), | |
72 loader_(loader) | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
73 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
74 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
75 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
76 virtual void RetrieveReferencedSlices(const std::set<std::string>& nonEmptyInstances) ORTHANC_OVERRIDE; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
77 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
78 private: |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
79 // these subclasses hold the loading state |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
80 class AddReferencedInstance; // 2nd state |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
81 class LookupInstance; // 1st state |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
82 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
83 DicomStructureSetLoader& loader_; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
84 }; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
85 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
86 class DicomStructureSetLoader::RestInstanceLookupHandler::AddReferencedInstance : public LoaderStateMachine::State |
815 | 87 { |
88 private: | |
89 std::string instanceId_; | |
90 | |
91 public: | |
92 AddReferencedInstance(DicomStructureSetLoader& that, | |
93 const std::string& instanceId) : | |
94 State(that), | |
95 instanceId_(instanceId) | |
96 { | |
97 } | |
98 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
99 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) ORTHANC_OVERRIDE |
815 | 100 { |
101 Json::Value tags; | |
102 message.ParseJsonBody(tags); | |
103 | |
104 Orthanc::DicomMap dicom; | |
105 dicom.FromDicomAsJson(tags); | |
106 | |
107 DicomStructureSetLoader& loader = GetLoader<DicomStructureSetLoader>(); | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
108 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
109 loader.AddReferencedSlice(dicom); |
815 | 110 } |
111 }; | |
112 | |
113 | |
114 // State that converts a "SOP Instance UID" to an Orthanc identifier | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
115 class DicomStructureSetLoader::RestInstanceLookupHandler::LookupInstance : public LoaderStateMachine::State |
815 | 116 { |
117 private: | |
118 std::string sopInstanceUid_; | |
119 | |
120 public: | |
121 LookupInstance(DicomStructureSetLoader& that, | |
122 const std::string& sopInstanceUid) : | |
123 State(that), | |
124 sopInstanceUid_(sopInstanceUid) | |
125 { | |
126 } | |
127 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
128 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) ORTHANC_OVERRIDE |
815 | 129 { |
130 DicomStructureSetLoader& loader = GetLoader<DicomStructureSetLoader>(); | |
131 | |
132 Json::Value lookup; | |
133 message.ParseJsonBody(lookup); | |
134 | |
135 if (lookup.type() != Json::arrayValue || | |
136 lookup.size() != 1 || | |
137 !lookup[0].isMember("Type") || | |
138 !lookup[0].isMember("Path") || | |
139 lookup[0]["Type"].type() != Json::stringValue || | |
140 lookup[0]["ID"].type() != Json::stringValue || | |
141 lookup[0]["Type"].asString() != "Instance") | |
142 { | |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
143 std::stringstream msg; |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
144 msg << "Unknown resource! message.GetAnswer() = " << message.GetAnswer() << " message.GetAnswerHeaders() = "; |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
145 for (OrthancRestApiCommand::HttpHeaders::const_iterator it = message.GetAnswerHeaders().begin(); |
842
2b245953b44b
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
146 it != message.GetAnswerHeaders().end(); ++it) |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
147 { |
842
2b245953b44b
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
148 msg << "\nkey: \"" << it->first << "\" value: \"" << it->second << "\"\n"; |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
149 } |
842
2b245953b44b
removed some c++11 for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
841
diff
changeset
|
150 const std::string msgStr = msg.str(); |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
828
diff
changeset
|
151 LOG(ERROR) << msgStr; |
1758
4ee11b8773e2
Better error description in case of network json payload errors
Benjamin Golinvaux <bgo@osimis.io>
parents:
1751
diff
changeset
|
152 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadJson); |
815 | 153 } |
154 | |
155 const std::string instanceId = lookup[0]["ID"].asString(); | |
156 | |
157 { | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
158 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1771
diff
changeset
|
159 command->SetCallerName("DicomStructureSetLoader::RestInstanceLookupHandler::LookupInstance"); |
815 | 160 command->SetHttpHeader("Accept-Encoding", "gzip"); |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
161 std::string uri = "/instances/" + instanceId + "/tags"; |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
162 command->SetUri(uri); |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1059
diff
changeset
|
163 command->AcquirePayload(new AddReferencedInstance(loader, instanceId)); |
815 | 164 Schedule(command.release()); |
165 } | |
166 } | |
167 }; | |
168 | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
169 void DicomStructureSetLoader::RestInstanceLookupHandler::RetrieveReferencedSlices( |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
170 const std::set<std::string>& nonEmptyInstances) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
171 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
172 for (std::set<std::string>::const_iterator it = nonEmptyInstances.begin(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
173 it != nonEmptyInstances.end(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
174 ++it) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
175 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
176 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1771
diff
changeset
|
177 command->SetCallerName("DicomStructureSetLoader::RestInstanceLookupHandler"); |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
178 command->SetUri("/tools/lookup"); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
179 command->SetMethod(Orthanc::HttpMethod_Post); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
180 command->SetBody(*it); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
181 command->AcquirePayload(new LookupInstance(loader_, *it)); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
182 Schedule(command.release()); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
183 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
184 } |
815 | 185 |
186 class DicomStructureSetLoader::LoadStructure : public LoaderStateMachine::State | |
187 { | |
188 public: | |
1571 | 189 explicit LoadStructure(DicomStructureSetLoader& that) : |
190 State(that) | |
815 | 191 { |
192 } | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
193 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
194 virtual void Handle(const OrthancRestApiCommand::SuccessMessage& message) ORTHANC_OVERRIDE |
815 | 195 { |
1751
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
196 #if STONE_TIME_BLOCKING_OPS |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
197 boost::posix_time::ptime timerStart = boost::posix_time::microsec_clock::universal_time(); |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
198 #endif |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
199 |
815 | 200 DicomStructureSetLoader& loader = GetLoader<DicomStructureSetLoader>(); |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
201 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
202 // Set the actual structure set content |
815 | 203 { |
1504 | 204 FullOrthancDataset dicom(message.GetAnswer()); |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
205 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
206 loader.content_.reset(new DicomStructureSet(dicom)); |
815 | 207 } |
208 | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
209 // initialize visibility flags |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
210 SetDefaultStructureVisibility(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
211 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
212 // retrieve the (non-empty) referenced instances (the CT slices containing the corresponding structures) |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
213 // Some (admittedly invalid) Dicom files have empty values in the |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
214 // 0008,1155 tag. We try our best to cope with this. |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
215 // this is why we use `nonEmptyInstances` and not `instances` |
815 | 216 std::set<std::string> instances; |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
217 std::set<std::string> nonEmptyInstances; |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
218 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
219 // this traverses the polygon collection for all structures and retrieve the SOPInstanceUID of |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
220 // the referenced instances |
815 | 221 loader.content_->GetReferencedInstances(instances); |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
222 |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
223 for (std::set<std::string>::const_iterator |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
224 it = instances.begin(); it != instances.end(); ++it) |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
225 { |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
226 std::string instance = Orthanc::Toolbox::StripSpaces(*it); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
227 if(instance != "") |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
228 nonEmptyInstances.insert(instance); |
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
229 } |
815 | 230 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
231 loader.RetrieveReferencedSlices(nonEmptyInstances); |
1751
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
232 #if STONE_TIME_BLOCKING_OPS |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
233 boost::posix_time::ptime timerEnd = boost::posix_time::microsec_clock::universal_time(); |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
234 boost::posix_time::time_duration duration = timerEnd - timerStart; |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
235 int64_t durationMs = duration.total_milliseconds(); |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
236 LOG(WARNING) << "DicomStructureSetLoader::LoadStructure::Handle took " << durationMs << " ms"; |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
237 #endif |
946eb7200b82
FastParseVector usage + timing instrumentation guarded by STONE_TIME_BLOCKING_OPS
Benjamin Golinvaux <bgo@osimis.io>
parents:
1739
diff
changeset
|
238 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
239 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
240 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
241 void SetDefaultStructureVisibility() |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
242 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
243 DicomStructureSetLoader& loader = GetLoader<DicomStructureSetLoader>(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
244 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
245 size_t structureCount = loader.content_->GetStructuresCount(); |
815 | 246 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
247 loader.structureVisibility_.resize(structureCount); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
248 bool everythingVisible = false; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
249 if ((loader.initiallyVisibleStructures_.size() == 1) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
250 && (loader.initiallyVisibleStructures_[0].size() == 1) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
251 && (loader.initiallyVisibleStructures_[0][0] == '*')) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
252 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
253 everythingVisible = true; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
254 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
255 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
256 for (size_t i = 0; i < structureCount; ++i) |
815 | 257 { |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
258 // if a single "*" string is supplied, this means we want everything |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
259 // to be visible... |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
260 if (everythingVisible) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
261 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
262 loader.structureVisibility_.at(i) = true; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
263 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
264 else |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
265 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
266 // otherwise, we only enable visibility for those structures whose |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
267 // names are mentioned in the initiallyVisibleStructures_ array |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
268 const std::string& structureName = loader.content_->GetStructureName(i); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
269 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
270 std::vector<std::string>::iterator foundIt = |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
271 std::find( |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
272 loader.initiallyVisibleStructures_.begin(), |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
273 loader.initiallyVisibleStructures_.end(), |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
274 structureName); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
275 std::vector<std::string>::iterator endIt = loader.initiallyVisibleStructures_.end(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
276 if (foundIt != endIt) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
277 loader.structureVisibility_.at(i) = true; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
278 else |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
279 loader.structureVisibility_.at(i) = false; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
280 } |
815 | 281 } |
282 } | |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
283 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
284 private: |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
285 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
286 |
815 | 287 }; |
288 | |
289 | |
290 class DicomStructureSetLoader::Slice : public IExtractedSlice | |
291 { | |
292 private: | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
293 const DicomStructureSet& content_; |
815 | 294 uint64_t revision_; |
295 bool isValid_; | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
296 std::vector<bool> visibility_; |
815 | 297 |
298 public: | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
299 /** |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
300 The visibility vector must either: |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
301 - be empty |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
302 or |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
303 - contain the same number of items as the number of structures in the |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
304 structure set. |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
305 In the first case (empty vector), all the structures are displayed. |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
306 In the second case, the visibility of each structure is defined by the |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
307 content of the vector at the corresponding index. |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
308 */ |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
309 Slice(const DicomStructureSet& content, |
815 | 310 uint64_t revision, |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
311 const CoordinateSystem3D& cuttingPlane, |
1571 | 312 const std::vector<bool>& visibility) : |
313 content_(content), | |
314 revision_(revision), | |
315 visibility_(visibility) | |
815 | 316 { |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
317 ORTHANC_ASSERT((visibility_.size() == content_.GetStructuresCount()) |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
318 || (visibility_.size() == 0u)); |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
319 |
815 | 320 bool opposite; |
321 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
322 const Vector normal = content.GetNormal(); |
815 | 323 isValid_ = ( |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
324 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetNormal()) || |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
325 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetAxisX()) || |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
326 GeometryToolbox::IsParallelOrOpposite(opposite, normal, cuttingPlane.GetAxisY())); |
815 | 327 } |
328 | |
1571 | 329 virtual bool IsValid() ORTHANC_OVERRIDE |
815 | 330 { |
331 return isValid_; | |
332 } | |
333 | |
1571 | 334 virtual uint64_t GetRevision() ORTHANC_OVERRIDE |
815 | 335 { |
336 return revision_; | |
337 } | |
338 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
339 virtual ISceneLayer* CreateSceneLayer( |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
340 const ILayerStyleConfigurator* configurator, |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
341 const CoordinateSystem3D& cuttingPlane) ORTHANC_OVERRIDE |
815 | 342 { |
343 assert(isValid_); | |
344 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
345 std::unique_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer); |
815 | 346 layer->SetThickness(2); |
347 | |
1771
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
348 #if 0 |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
349 // For testing - This displays a cross at the origin of the 3D |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
350 // cutting plane in the 2D viewport |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
351 { |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
352 PolylineSceneLayer::Chain chain; |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
353 chain.push_back(ScenePoint2D(-100, 0)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
354 chain.push_back(ScenePoint2D(100, 0)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
355 layer->AddChain(chain, false, Color(255, 0, 0)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
356 } |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
357 |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
358 { |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
359 PolylineSceneLayer::Chain chain; |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
360 chain.push_back(ScenePoint2D(0, -100)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
361 chain.push_back(ScenePoint2D(0, 100)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
362 layer->AddChain(chain, false, Color(255, 0, 0)); |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
363 } |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
364 #endif |
f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1764
diff
changeset
|
365 |
815 | 366 for (size_t i = 0; i < content_.GetStructuresCount(); i++) |
367 { | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
368 if ((visibility_.size() == 0) || visibility_.at(i)) |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
369 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
370 const Color& color = content_.GetStructureColor(i); |
815 | 371 |
1764
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
372 #if USE_BOOST_UNION_FOR_POLYGONS == 1 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
373 std::vector< std::vector<Point2D> > polygons; |
1764
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
374 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
375 if (content_.ProjectStructure(polygons, i, cuttingPlane)) |
815 | 376 { |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
377 for (size_t j = 0; j < polygons.size(); j++) |
815 | 378 { |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
379 PolylineSceneLayer::Chain chain; |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
380 chain.resize(polygons[j].size()); |
1764
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
381 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
382 for (size_t k = 0; k < polygons[j].size(); k++) |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
383 { |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
384 chain[k] = ScenePoint2D(polygons[j][k].x, polygons[j][k].y); |
1764
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
385 } |
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
386 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
387 layer->AddChain(chain, true /* closed */, color); |
1764
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
388 } |
adb59bcb0fc5
fix use of USE_BOOST_UNION_FOR_POLYGONS
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
389 } |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
390 #else |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
391 std::vector< std::pair<Point2D, Point2D> > segments; |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
392 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
393 if (content_.ProjectStructure(segments, i, cuttingPlane)) |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
394 { |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
395 for (size_t j = 0; j < segments.size(); j++) |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
396 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
397 PolylineSceneLayer::Chain chain; |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
398 chain.resize(2); |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
399 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
400 chain[0] = ScenePoint2D(segments[j].first.x, segments[j].first.y); |
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
401 chain[1] = ScenePoint2D(segments[j].second.x, segments[j].second.y); |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
402 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
403 layer->AddChain(chain, false /* NOT closed */, color); |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
404 } |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
405 } |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
406 #endif |
1000
50e5acf5553b
changed RTSTRUCT rendering from polygons to segments
Benjamin Golinvaux <bgo@osimis.io>
parents:
981
diff
changeset
|
407 } |
815 | 408 } |
409 | |
410 return layer.release(); | |
411 } | |
412 }; | |
413 | |
414 | |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
415 DicomStructureSetLoader::DicomStructureSetLoader( |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
416 ILoadersContext& loadersContext) |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
417 : LoaderStateMachine(loadersContext) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
418 , loadersContext_(loadersContext) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
419 , revision_(0) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
420 , countProcessedInstances_(0) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
421 , countReferencedInstances_(0) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
422 , structuresReady_(false) |
815 | 423 { |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
424 // the default handler to retrieve slice geometry is RestInstanceLookupHandler |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
425 instanceLookupHandler_ = RestInstanceLookupHandler::Create(*this); |
815 | 426 } |
427 | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
428 boost::shared_ptr<DicomStructureSetLoader> DicomStructureSetLoader::Create(ILoadersContext& loadersContext) |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
429 { |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
430 boost::shared_ptr<DicomStructureSetLoader> obj( |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
431 new DicomStructureSetLoader( |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
432 loadersContext)); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
433 obj->LoaderStateMachine::PostConstructor(); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
434 return obj; |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
435 } |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
436 |
1416
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
437 void DicomStructureSetLoader::AddReferencedSlice(const Orthanc::DicomMap& dicom) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
438 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
439 content_->AddReferencedSlice(dicom); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
440 countProcessedInstances_ ++; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
441 assert(countProcessedInstances_ <= countReferencedInstances_); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
442 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
443 revision_++; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
444 SetStructuresUpdated(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
445 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
446 if (countProcessedInstances_ == countReferencedInstances_) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
447 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
448 // All the referenced instances have been loaded, finalize the RT-STRUCT |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
449 content_->CheckReferencedSlices(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
450 revision_++; |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
451 SetStructuresReady(); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
452 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
453 } |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
454 |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
455 void DicomStructureSetLoader::RetrieveReferencedSlices(const std::set<std::string>& nonEmptyInstances) |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
456 { |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
457 // we set the number of referenced instances. This allows to know, in the method above, when we're done |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
458 countReferencedInstances_ = static_cast<unsigned int>(nonEmptyInstances.size()); |
d959bc8f6c1b
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1385
diff
changeset
|
459 instanceLookupHandler_->RetrieveReferencedSlices(nonEmptyInstances); |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
460 } |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
461 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
462 void DicomStructureSetLoader::SetStructureDisplayState(size_t structureIndex, bool display) |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
463 { |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
464 structureVisibility_.at(structureIndex) = display; |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
465 revision_++; |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
466 } |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
467 |
935
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
468 DicomStructureSetLoader::~DicomStructureSetLoader() |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
469 { |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
470 LOG(TRACE) << "DicomStructureSetLoader::~DicomStructureSetLoader()"; |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
471 } |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
842
diff
changeset
|
472 |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
473 void DicomStructureSetLoader::LoadInstance( |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
474 const std::string& instanceId, |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
475 const std::vector<std::string>& initiallyVisibleStructures) |
815 | 476 { |
477 Start(); | |
478 | |
479 instanceId_ = instanceId; | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
480 initiallyVisibleStructures_ = initiallyVisibleStructures; |
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
481 |
815 | 482 { |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
483 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1831
a03260db8835
Added SetCallerName to IOracleCommand to ease debugging
Benjamin Golinvaux <bgo@osimis.io>
parents:
1771
diff
changeset
|
484 command->SetCallerName("DicomStructureSetLoader::LoadInstance"); |
815 | 485 command->SetHttpHeader("Accept-Encoding", "gzip"); |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
486 |
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
487 std::string uri = "/instances/" + instanceId + "/tags?ignore-length=3006-0050"; |
981
c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
Benjamin Golinvaux <bgo@osimis.io>
parents:
977
diff
changeset
|
488 |
964
91f827272c1f
Added cache-control headers for POST requests + #ifdef'd tracing logs + trace on context restored
Benjamin Golinvaux <bgo@osimis.io>
parents:
954
diff
changeset
|
489 command->SetUri(uri); |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1059
diff
changeset
|
490 command->AcquirePayload(new LoadStructure(*this)); |
815 | 491 Schedule(command.release()); |
492 } | |
493 } | |
494 | |
1385
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
495 void DicomStructureSetLoader::LoadInstanceFullVisibility(const std::string& instanceId) |
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
496 { |
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
497 std::vector<std::string> initiallyVisibleStructures; |
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
498 initiallyVisibleStructures.push_back("*"); // wildcard to make all structure sets visible |
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
499 LoadInstance(instanceId, initiallyVisibleStructures); |
ffe9beb7c5d3
Added LoadInstanceFullVisibility for default-visible RTSTRUCT
Benjamin Golinvaux <bgo@osimis.io>
parents:
1381
diff
changeset
|
500 } |
815 | 501 |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
502 IVolumeSlicer::IExtractedSlice* DicomStructureSetLoader::ExtractSlice(const CoordinateSystem3D& cuttingPlane) |
815 | 503 { |
504 if (content_.get() == NULL) | |
505 { | |
506 // Geometry is not available yet | |
1640
52b8b96cb55f
cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
507 return new IVolumeSlicer::InvalidSlice; |
815 | 508 } |
509 else | |
510 { | |
1019
29f5f2031310
Added a way to specificy which structures are to be initially displayed (the
Benjamin Golinvaux <bgo@osimis.io>
parents:
1006
diff
changeset
|
511 return new Slice(*content_, revision_, cuttingPlane, structureVisibility_); |
815 | 512 } |
513 } | |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
514 |
1342
13573ff63eb6
New StructuresUpdated message that is sent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1339
diff
changeset
|
515 void DicomStructureSetLoader::SetStructuresUpdated() |
13573ff63eb6
New StructuresUpdated message that is sent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1339
diff
changeset
|
516 { |
13573ff63eb6
New StructuresUpdated message that is sent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1339
diff
changeset
|
517 BroadcastMessage(DicomStructureSetLoader::StructuresUpdated(*this)); |
13573ff63eb6
New StructuresUpdated message that is sent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1339
diff
changeset
|
518 } |
13573ff63eb6
New StructuresUpdated message that is sent
Benjamin Golinvaux <bgo@osimis.io>
parents:
1339
diff
changeset
|
519 |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
520 void DicomStructureSetLoader::SetStructuresReady() |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
521 { |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
522 ORTHANC_ASSERT(!structuresReady_); |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
523 structuresReady_ = true; |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
524 BroadcastMessage(DicomStructureSetLoader::StructuresReady(*this)); |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
525 } |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
526 |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
527 bool DicomStructureSetLoader::AreStructuresReady() const |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
528 { |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
529 return structuresReady_; |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
530 } |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
531 |
815 | 532 } |