Mercurial > hg > orthanc-stone
comparison Framework/Loaders/DicomStructureSetLoader.h @ 1416:d959bc8f6c1b loader-injection-feature
Instance lookup is now performed in a separate class through an interface. Another implementation can be injected (SetInstanceLookupHandler)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 11 May 2020 17:37:30 +0200 |
parents | ffe9beb7c5d3 |
children |
comparison
equal
deleted
inserted
replaced
1415:998697c5ec74 | 1416:d959bc8f6c1b |
---|---|
33 class DicomStructureSetLoader : | 33 class DicomStructureSetLoader : |
34 public LoaderStateMachine, | 34 public LoaderStateMachine, |
35 public OrthancStone::IVolumeSlicer, | 35 public OrthancStone::IVolumeSlicer, |
36 public OrthancStone::IObservable | 36 public OrthancStone::IObservable |
37 { | 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 | |
38 private: | 104 private: |
39 class Slice; | 105 class Slice; |
40 | 106 |
41 // States of LoaderStateMachine | 107 // Only state of LoaderStateMachine |
42 class AddReferencedInstance; // 3rd state | |
43 class LookupInstance; // 2nd state | |
44 class LoadStructure; // 1st state | 108 class LoadStructure; // 1st state |
45 | 109 |
46 OrthancStone::ILoadersContext& loadersContext_; | 110 OrthancStone::ILoadersContext& loadersContext_; |
47 std::unique_ptr<OrthancStone::DicomStructureSet> content_; | 111 std::unique_ptr<OrthancStone::DicomStructureSet> content_; |
48 uint64_t revision_; | 112 uint64_t revision_; |
68 | 132 |
69 Changing this value directly affects the rendering | 133 Changing this value directly affects the rendering |
70 */ | 134 */ |
71 std::vector<bool> structureVisibility_; | 135 std::vector<bool> structureVisibility_; |
72 | 136 |
137 | |
138 boost::shared_ptr<IInstanceLookupHandler> instanceLookupHandler_; | |
139 | |
140 private: | |
141 void RetrieveReferencedSlices(const std::set<std::string>& nonEmptyInstances); | |
142 | |
73 protected: | 143 protected: |
74 DicomStructureSetLoader(OrthancStone::ILoadersContext& loadersContext); | 144 DicomStructureSetLoader(OrthancStone::ILoadersContext& loadersContext); |
75 | |
76 public: | |
77 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, StructuresReady, DicomStructureSetLoader); | |
78 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, StructuresUpdated, DicomStructureSetLoader); | |
79 | |
80 static boost::shared_ptr<DicomStructureSetLoader> Create( | |
81 OrthancStone::ILoadersContext& loadersContext); | |
82 | |
83 OrthancStone::DicomStructureSet* GetContent() | |
84 { | |
85 return content_.get(); | |
86 } | |
87 | |
88 void SetStructureDisplayState(size_t structureIndex, bool display); | |
89 | |
90 bool GetStructureDisplayState(size_t structureIndex) const | |
91 { | |
92 return structureVisibility_.at(structureIndex); | |
93 } | |
94 | |
95 ~DicomStructureSetLoader(); | |
96 | |
97 void LoadInstance(const std::string& instanceId, | |
98 const std::vector<std::string>& initiallyVisibleStructures = std::vector<std::string>()); | |
99 | |
100 void LoadInstanceFullVisibility(const std::string& instanceId); | |
101 | |
102 | |
103 virtual IExtractedSlice* ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) ORTHANC_OVERRIDE; | |
104 | |
105 void SetStructuresReady(); | |
106 void SetStructuresUpdated(); | |
107 | |
108 bool AreStructuresReady() const; | |
109 }; | 145 }; |
110 } | 146 } |