annotate Framework/Loaders/LoaderCache.cpp @ 1001:e704a53c9d0a

LoaderCache : support for the second set of structure set handling classes
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 20 Sep 2019 11:59:54 +0200
parents d358593820b8
children 29f5f2031310
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #include "LoaderCache.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #include "OrthancSeriesVolumeProgressiveLoader.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #include "OrthancMultiframeVolumeLoader.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 #include "DicomStructureSetLoader.h"
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
26 #include "DicomStructureSetLoader2.h"
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
28 #if ORTHANC_ENABLE_WASM == 1
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
29 # include <unistd.h>
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
30 # include "../Oracle/WebAssemblyOracle.h"
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
31 #else
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
32 # include "../Oracle/ThreadedOracle.h"
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
33 #endif
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
34
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 #include "../Messages/LockingEmitter.h"
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
36 #include "../Toolbox/DicomStructureSet2.h"
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 #include "../Volumes/DicomVolumeImage.h"
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 #include "../Volumes/DicomVolumeImageMPRSlicer.h"
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
39 #include "../Volumes/DicomStructureSetSlicer2.h"
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 #include <Core/OrthancException.h>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 #include <Core/Toolbox.h>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 namespace OrthancStone
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 #if ORTHANC_ENABLE_WASM == 1
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
47 LoaderCache::LoaderCache(WebAssemblyOracle& oracle)
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 : oracle_(oracle)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 #else
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
53 LoaderCache::LoaderCache(ThreadedOracle& oracle, LockingEmitter& lockingEmitter)
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 : oracle_(oracle)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 , lockingEmitter_(lockingEmitter)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader>
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 LoaderCache::GetSeriesVolumeProgressiveLoader(std::string seriesUuid)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 try
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 {
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
65
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 seriesUuid = Orthanc::Toolbox::StripSpaces(seriesUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 Orthanc::Toolbox::ToLowerCase(seriesUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 if (seriesVolumeProgressiveLoaders_.find(seriesUuid) == seriesVolumeProgressiveLoaders_.end())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 {
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
73 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : CACHEMISS --> need to load seriesUUid = " << seriesUuid;
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
74 #if ORTHANC_ENABLE_WASM == 1
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
75 // LOG(TRACE) << "Performing request for series " << seriesUuid << " sbrk(0) = " << sbrk(0);
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
76 #else
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
77 // LOG(TRACE) << "Performing request for series " << seriesUuid;
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
78 #endif
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> loader;
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
81 // LOG(TRACE) << "volumeImage = " << volumeImage.get();
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 #if ORTHANC_ENABLE_WASM == 1
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
84 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, oracle_));
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 loader.reset(new OrthancSeriesVolumeProgressiveLoader(volumeImage, oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 #endif
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
89 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : loader = " << loader.get();
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 loader->LoadSeries(seriesUuid);
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
91 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : loader->LoadSeries successful";
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 seriesVolumeProgressiveLoaders_[seriesUuid] = loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 }
933
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
95 else
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
96 {
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
97 // LOG(TRACE) << "LoaderCache::GetSeriesVolumeProgressiveLoader : returning cached loader for seriesUUid = " << seriesUuid;
f75f6cb69c1b Commented-out traces for debug
Benjamin Golinvaux <bgo@osimis.io>
parents: 930
diff changeset
98 }
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 return seriesVolumeProgressiveLoaders_[seriesUuid];
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 catch (const Orthanc::OrthancException& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 if (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 catch (const std::exception& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124
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: 933
diff changeset
125 boost::shared_ptr<OrthancMultiframeVolumeLoader> LoaderCache::GetMultiframeVolumeLoader(std::string instanceUuid)
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: 933
diff changeset
126 {
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: 933
diff changeset
127 // if the loader is not available, let's trigger its creation
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: 933
diff changeset
128 if(multiframeVolumeLoaders_.find(instanceUuid) == multiframeVolumeLoaders_.end())
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: 933
diff changeset
129 {
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: 933
diff changeset
130 GetMultiframeDicomVolumeImageMPRSlicer(instanceUuid);
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: 933
diff changeset
131 }
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: 933
diff changeset
132 ORTHANC_ASSERT(multiframeVolumeLoaders_.find(instanceUuid) != multiframeVolumeLoaders_.end());
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: 933
diff changeset
133
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: 933
diff changeset
134 return multiframeVolumeLoaders_[instanceUuid];
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: 933
diff changeset
135 }
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: 933
diff changeset
136
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 boost::shared_ptr<DicomVolumeImageMPRSlicer> LoaderCache::GetMultiframeDicomVolumeImageMPRSlicer(std::string instanceUuid)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 try
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 Orthanc::Toolbox::ToLowerCase(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 if (dicomVolumeImageMPRSlicers_.find(instanceUuid) == dicomVolumeImageMPRSlicers_.end())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 boost::shared_ptr<DicomVolumeImage> volumeImage(new DicomVolumeImage);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 boost::shared_ptr<OrthancMultiframeVolumeLoader> loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 #if ORTHANC_ENABLE_WASM == 1
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
153 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, oracle_));
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 loader.reset(new OrthancMultiframeVolumeLoader(volumeImage, oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 loader->LoadInstance(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 multiframeVolumeLoaders_[instanceUuid] = loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 boost::shared_ptr<DicomVolumeImageMPRSlicer> mprSlicer(new DicomVolumeImageMPRSlicer(volumeImage));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 dicomVolumeImageMPRSlicers_[instanceUuid] = mprSlicer;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 return dicomVolumeImageMPRSlicers_[instanceUuid];
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 catch (const Orthanc::OrthancException& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 if (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
170 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
172 else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
175 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
177 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 catch (const std::exception& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
179 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
180 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
182 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
183 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
184 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
185 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
186 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
187 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
188 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
189
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
190 boost::shared_ptr<DicomStructureSetSlicer2> LoaderCache::GetDicomStructureSetSlicer2(std::string instanceUuid)
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
191 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
192 // if the loader is not available, let's trigger its creation
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
193 if (dicomStructureSetSlicers2_.find(instanceUuid) == dicomStructureSetSlicers2_.end())
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
194 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
195 GetDicomStructureSetLoader2(instanceUuid);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
196 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
197 ORTHANC_ASSERT(dicomStructureSetSlicers2_.find(instanceUuid) != dicomStructureSetSlicers2_.end());
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
198
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
199 return dicomStructureSetSlicers2_[instanceUuid];
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
200 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
201
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 boost::shared_ptr<DicomStructureSetLoader> LoaderCache::GetDicomStructureSetLoader(std::string instanceUuid)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204 try
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 // normalize keys a little
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 Orthanc::Toolbox::ToLowerCase(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
209
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 // find in cache
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
211 if (dicomStructureSetLoaders_.find(instanceUuid) == dicomStructureSetLoaders_.end())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
212 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 boost::shared_ptr<DicomStructureSetLoader> loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
216 #if ORTHANC_ENABLE_WASM == 1
930
bf03cb879eb4 Fixed LoaderCache
Benjamin Golinvaux <bgo@osimis.io>
parents: 929
diff changeset
217 loader.reset(new DicomStructureSetLoader(oracle_, oracle_));
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218 #else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 loader.reset(new DicomStructureSetLoader(oracle_, lock.GetOracleObservable()));
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 #endif
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 loader->LoadInstance(instanceUuid);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
224 dicomStructureSetLoaders_[instanceUuid] = loader;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
225 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
226 return dicomStructureSetLoaders_[instanceUuid];
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
227 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 catch (const Orthanc::OrthancException& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 if (e.HasDetails())
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
231 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
232 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What() << " Details: " << e.GetDetails();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
233 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
234 else
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
235 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
236 LOG(ERROR) << "OrthancException in LoaderCache: " << e.What();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
237 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
238 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
239 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
240 catch (const std::exception& e)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
241 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
242 LOG(ERROR) << "std::exception in LoaderCache: " << e.what();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 catch (...)
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 LOG(ERROR) << "Unknown exception in LoaderCache";
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 throw;
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
253 boost::shared_ptr<DicomStructureSetLoader2> LoaderCache::GetDicomStructureSetLoader2(std::string instanceUuid)
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
254 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
255 try
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
256 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
257 // normalize keys a little
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
258 instanceUuid = Orthanc::Toolbox::StripSpaces(instanceUuid);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
259 Orthanc::Toolbox::ToLowerCase(instanceUuid);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
260
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
261 // find in cache
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
262 if (dicomStructureSetLoaders2_.find(instanceUuid) == dicomStructureSetLoaders2_.end())
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
263 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
264 boost::shared_ptr<DicomStructureSetLoader2> loader;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
265 boost::shared_ptr<DicomStructureSet2> structureSet(new DicomStructureSet2());
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
266 boost::shared_ptr<DicomStructureSetSlicer2> rtSlicer(new DicomStructureSetSlicer2(structureSet));
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
267 dicomStructureSetSlicers2_[instanceUuid] = rtSlicer;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
268 dicomStructureSets2_[instanceUuid] = structureSet; // to prevent it from being deleted
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
269 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
270 #if ORTHANC_ENABLE_WASM == 1
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
271 loader.reset(new DicomStructureSetLoader2(*(structureSet.get()), oracle_, oracle_));
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
272 #else
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
273 LockingEmitter::WriterLock lock(lockingEmitter_);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
274 // TODO: clarify lifetimes... this is DANGEROUS!
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
275 loader.reset(new DicomStructureSetLoader2(*(structureSet.get()), oracle_, lock.GetOracleObservable()));
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
276 #endif
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
277 loader->LoadInstance(instanceUuid);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
278 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
279 dicomStructureSetLoaders2_[instanceUuid] = loader;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
280 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
281 return dicomStructureSetLoaders2_[instanceUuid];
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
282 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
283 catch (const Orthanc::OrthancException& e)
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
284 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
285 if (e.HasDetails())
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
286 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
287 LOG(ERROR) << "OrthancException in GetDicomStructureSetLoader2: " << e.What() << " Details: " << e.GetDetails();
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
288 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
289 else
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
290 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
291 LOG(ERROR) << "OrthancException in GetDicomStructureSetLoader2: " << e.What();
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
292 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
293 throw;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
294 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
295 catch (const std::exception& e)
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
296 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
297 LOG(ERROR) << "std::exception in GetDicomStructureSetLoader2: " << e.what();
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
298 throw;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
299 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
300 catch (...)
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
301 {
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
302 LOG(ERROR) << "Unknown exception in GetDicomStructureSetLoader2";
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
303 throw;
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
304 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
305 }
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
306
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
307 void LoaderCache::ClearCache()
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
308 {
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
309 #if ORTHANC_ENABLE_WASM != 1
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
310 LockingEmitter::WriterLock lock(lockingEmitter_);
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
311 #endif
961
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
312
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
313 //#ifndef NDEBUG
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
314 // ISO way of checking for debug builds
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
315 DebugDisplayObjRefCounts();
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
316 //#endif
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
317 seriesVolumeProgressiveLoaders_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
318 multiframeVolumeLoaders_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
319 dicomVolumeImageMPRSlicers_.clear();
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
320 dicomStructureSetLoaders_.clear();
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
321
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
322 // order is important!
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
323 dicomStructureSetLoaders2_.clear();
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
324 dicomStructureSetSlicers2_.clear();
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
325 dicomStructureSets2_.clear();
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
326 }
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
327
961
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
328 template<typename T> void DebugDisplayObjRefCountsInMap(
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
329 const std::string& name, const std::map<std::string, boost::shared_ptr<T> >& myMap)
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
330 {
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
331 LOG(TRACE) << "Map \"" << name << "\" ref counts:";
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
332 size_t i = 0;
963
d358593820b8 removal of C++11 iterator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 961
diff changeset
333 for (typename std::map<std::string, boost::shared_ptr<T> >::const_iterator
d358593820b8 removal of C++11 iterator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 961
diff changeset
334 it = myMap.begin(); it != myMap.end(); ++it)
961
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
335 {
963
d358593820b8 removal of C++11 iterator
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 961
diff changeset
336 LOG(TRACE) << " element #" << i << ": ref count = " << it->second.use_count();
961
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
337 i++;
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
338 }
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
339 }
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
340
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
341 void LoaderCache::DebugDisplayObjRefCounts()
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
342 {
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
343 DebugDisplayObjRefCountsInMap("seriesVolumeProgressiveLoaders_", seriesVolumeProgressiveLoaders_);
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
344 DebugDisplayObjRefCountsInMap("multiframeVolumeLoaders_", multiframeVolumeLoaders_);
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
345 DebugDisplayObjRefCountsInMap("dicomVolumeImageMPRSlicers_", dicomVolumeImageMPRSlicers_);
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
346 DebugDisplayObjRefCountsInMap("dicomStructureSetLoaders_", dicomStructureSetLoaders_);
1001
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
347 DebugDisplayObjRefCountsInMap("dicomStructureSetLoaders2_", dicomStructureSetLoaders2_);
e704a53c9d0a LoaderCache : support for the second set of structure set handling classes
Benjamin Golinvaux <bgo@osimis.io>
parents: 963
diff changeset
348 DebugDisplayObjRefCountsInMap("dicomStructureSetSlicers2_", dicomStructureSetSlicers2_);
961
92e32e263ae9 Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents: 937
diff changeset
349 }
929
408bcc6c1505 Added Loader cache. Not activated yet.
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
350 }