Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/DicomStructureSetLoader.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Loaders/DicomStructureSetLoader.h@d959bc8f6c1b |
children | 85e117739eca |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
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 | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "../Toolbox/DicomStructureSet.h" | |
25 #include "../Volumes/IVolumeSlicer.h" | |
26 #include "../Loaders/ILoadersContext.h" | |
27 #include "LoaderStateMachine.h" | |
28 | |
29 #include <vector> | |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class DicomStructureSetLoader : | |
34 public LoaderStateMachine, | |
35 public OrthancStone::IVolumeSlicer, | |
36 public OrthancStone::IObservable | |
37 { | |
38 public: | |
39 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, StructuresReady, DicomStructureSetLoader); | |
40 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, StructuresUpdated, DicomStructureSetLoader); | |
41 | |
42 /** | |
43 | |
44 Once the structure set has been loaded (the LoadStructure state), we need to fill it with geometry information | |
45 from the referenced slices (tag (0008,1155) described here: | |
46 https://dicom.innolitics.com/ciods/rt-structure-set/general-reference/00081140/00081155 | |
47 | |
48 This interface allows to customize how this information can be gathered. By default, the RestInstanceLookupHandler | |
49 will perform a REST call to the Orthanc API to retrieve this information. | |
50 | |
51 Injecting another implementation of this interface is useful when where this information can be supplied in | |
52 another (faster) way (for instance, if a separate loader for the CT series can be used to supply the slice geometry) | |
53 */ | |
54 class IInstanceLookupHandler | |
55 { | |
56 public: | |
57 virtual void RetrieveReferencedSlices(const std::set<std::string>& instances) = 0; | |
58 }; | |
59 | |
60 // predeclaration of the default IInstanceLookupHandler implementation | |
61 class RestInstanceLookupHandler; | |
62 | |
63 static boost::shared_ptr<DicomStructureSetLoader> Create( | |
64 OrthancStone::ILoadersContext& loadersContext); | |
65 | |
66 void SetInstanceLookupHandler(boost::shared_ptr<IInstanceLookupHandler> instanceLookupHandler) | |
67 { | |
68 instanceLookupHandler_ = instanceLookupHandler; | |
69 } | |
70 | |
71 OrthancStone::DicomStructureSet* GetContent() | |
72 { | |
73 return content_.get(); | |
74 } | |
75 | |
76 void SetStructureDisplayState(size_t structureIndex, bool display); | |
77 | |
78 bool GetStructureDisplayState(size_t structureIndex) const | |
79 { | |
80 return structureVisibility_.at(structureIndex); | |
81 } | |
82 | |
83 ~DicomStructureSetLoader(); | |
84 | |
85 void LoadInstance(const std::string& instanceId, | |
86 const std::vector<std::string>& initiallyVisibleStructures = std::vector<std::string>()); | |
87 | |
88 void LoadInstanceFullVisibility(const std::string& instanceId); | |
89 | |
90 | |
91 virtual IExtractedSlice* ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) ORTHANC_OVERRIDE; | |
92 | |
93 void SetStructuresReady(); | |
94 void SetStructuresUpdated(); | |
95 | |
96 bool AreStructuresReady() const; | |
97 | |
98 /** | |
99 Called by the IInstanceLookupHandler when slice referenced instance information is available. | |
100 When the last referenced slice is received, this method will perform a final check and will warn observers | |
101 */ | |
102 void AddReferencedSlice(const Orthanc::DicomMap& dicom); | |
103 | |
104 private: | |
105 class Slice; | |
106 | |
107 // Only state of LoaderStateMachine | |
108 class LoadStructure; // 1st state | |
109 | |
110 OrthancStone::ILoadersContext& loadersContext_; | |
111 std::unique_ptr<OrthancStone::DicomStructureSet> content_; | |
112 uint64_t revision_; | |
113 std::string instanceId_; | |
114 unsigned int countProcessedInstances_; | |
115 unsigned int countReferencedInstances_; | |
116 | |
117 // will be set to true once the loading is finished | |
118 bool structuresReady_; | |
119 | |
120 /** | |
121 At load time, these strings are used to initialize the structureVisibility_ | |
122 vector. | |
123 | |
124 As a special case, if initiallyVisibleStructures_ contains a single string | |
125 that is '*', ALL structures will be made visible. | |
126 */ | |
127 std::vector<std::string> initiallyVisibleStructures_; | |
128 | |
129 /** | |
130 Contains the "Should this structure be displayed?" flag for all structures. | |
131 Only filled when structures are loaded. | |
132 | |
133 Changing this value directly affects the rendering | |
134 */ | |
135 std::vector<bool> structureVisibility_; | |
136 | |
137 | |
138 boost::shared_ptr<IInstanceLookupHandler> instanceLookupHandler_; | |
139 | |
140 private: | |
141 void RetrieveReferencedSlices(const std::set<std::string>& nonEmptyInstances); | |
142 | |
143 protected: | |
144 DicomStructureSetLoader(OrthancStone::ILoadersContext& loadersContext); | |
145 }; | |
146 } |