Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoder/Plugin.cpp @ 2156:2fd8c1fa6076 Orthanc-1.1.0
version in doxygen
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 17 Nov 2016 09:30:22 +0100 |
parents | b1291df2f780 |
children | a3a65de1840f |
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 |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 **/ | |
19 | |
20 | |
21 #include "GdcmDecoderCache.h" | |
1837 | 22 #include "OrthancImageWrapper.h" |
1834 | 23 |
24 #include <orthanc/OrthancCPlugin.h> | |
25 | |
26 static OrthancPluginContext* context_ = NULL; | |
27 static OrthancPlugins::GdcmDecoderCache cache_; | |
28 | |
29 | |
30 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target, | |
31 const void* dicom, | |
32 const uint32_t size, | |
33 uint32_t frameIndex) | |
34 { | |
35 try | |
36 { | |
1837 | 37 std::auto_ptr<OrthancPlugins::OrthancImageWrapper> image; |
38 | |
1834 | 39 #if 0 |
40 // Do not use the cache | |
41 OrthancPlugins::GdcmImageDecoder decoder(dicom, size); | |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1837
diff
changeset
|
42 image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder.Decode(context_, frameIndex))); |
1834 | 43 #else |
1837 | 44 image.reset(cache_.Decode(context_, dicom, size, frameIndex)); |
1834 | 45 #endif |
46 | |
1837 | 47 *target = image->Release(); |
48 | |
1834 | 49 return OrthancPluginErrorCode_Success; |
50 } | |
51 catch (std::runtime_error& e) | |
52 { | |
53 *target = NULL; | |
54 | |
55 std::string s = "Cannot decode image using GDCM: " + std::string(e.what()); | |
56 OrthancPluginLogError(context_, s.c_str()); | |
57 return OrthancPluginErrorCode_Plugin; | |
58 } | |
59 } | |
60 | |
61 | |
62 | |
63 extern "C" | |
64 { | |
65 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
66 { | |
67 context_ = context; | |
68 OrthancPluginLogWarning(context_, "Initializing the advanced decoder of medical images using GDCM"); | |
69 | |
70 | |
71 /* Check the version of the Orthanc core */ | |
72 if (OrthancPluginCheckVersion(context_) == 0) | |
73 { | |
74 char info[1024]; | |
75 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
76 context_->orthancVersion, | |
77 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
78 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
79 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
80 OrthancPluginLogError(context_, info); | |
81 return -1; | |
82 } | |
83 | |
84 OrthancPluginSetDescription(context_, "Advanced decoder of medical images using GDCM."); | |
85 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback); | |
86 | |
87 return 0; | |
88 } | |
89 | |
90 | |
91 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
92 { | |
93 } | |
94 | |
95 | |
96 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
97 { | |
98 return "gdcm-decoder"; | |
99 } | |
100 | |
101 | |
102 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
103 { | |
104 return GDCM_DECODER_VERSION; | |
105 } | |
106 } |