Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoder/Plugin.cpp @ 2774:5bdd19c85d9f
new reserved global properties
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Jul 2018 12:07:52 +0200 |
parents | 50d80af0719e |
children | 4e43e67f8ecf |
rev | line source |
---|---|
1834 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1834 | 4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
1834 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * 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 * General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "GdcmDecoderCache.h" | |
1837 | 23 #include "OrthancImageWrapper.h" |
1834 | 24 |
25 #include <orthanc/OrthancCPlugin.h> | |
26 | |
27 static OrthancPluginContext* context_ = NULL; | |
28 static OrthancPlugins::GdcmDecoderCache cache_; | |
29 | |
30 | |
31 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target, | |
32 const void* dicom, | |
33 const uint32_t size, | |
34 uint32_t frameIndex) | |
35 { | |
36 try | |
37 { | |
1837 | 38 std::auto_ptr<OrthancPlugins::OrthancImageWrapper> image; |
39 | |
1834 | 40 #if 0 |
41 // Do not use the cache | |
42 OrthancPlugins::GdcmImageDecoder decoder(dicom, size); | |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1837
diff
changeset
|
43 image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder.Decode(context_, frameIndex))); |
1834 | 44 #else |
1837 | 45 image.reset(cache_.Decode(context_, dicom, size, frameIndex)); |
1834 | 46 #endif |
47 | |
1837 | 48 *target = image->Release(); |
49 | |
1834 | 50 return OrthancPluginErrorCode_Success; |
51 } | |
52 catch (std::runtime_error& e) | |
53 { | |
54 *target = NULL; | |
55 | |
56 std::string s = "Cannot decode image using GDCM: " + std::string(e.what()); | |
2555
50d80af0719e
removed annoying error log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
57 OrthancPluginLogInfo(context_, s.c_str()); |
1834 | 58 return OrthancPluginErrorCode_Plugin; |
59 } | |
60 } | |
61 | |
62 | |
63 | |
64 extern "C" | |
65 { | |
66 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
67 { | |
68 context_ = context; | |
69 OrthancPluginLogWarning(context_, "Initializing the advanced decoder of medical images using GDCM"); | |
70 | |
71 | |
72 /* Check the version of the Orthanc core */ | |
73 if (OrthancPluginCheckVersion(context_) == 0) | |
74 { | |
75 char info[1024]; | |
76 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
77 context_->orthancVersion, | |
78 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
79 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
80 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
81 OrthancPluginLogError(context_, info); | |
82 return -1; | |
83 } | |
84 | |
85 OrthancPluginSetDescription(context_, "Advanced decoder of medical images using GDCM."); | |
86 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback); | |
87 | |
88 return 0; | |
89 } | |
90 | |
91 | |
92 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
93 { | |
94 } | |
95 | |
96 | |
97 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
98 { | |
99 return "gdcm-decoder"; | |
100 } | |
101 | |
102 | |
103 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
104 { | |
105 return GDCM_DECODER_VERSION; | |
106 } | |
107 } |