Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoder/Plugin.cpp @ 3820:f89eac983c9b transcoding
refactoring DicomUserConnection as DicomAssociation
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Apr 2020 17:45:25 +0200 |
parents | 6110a4995ace |
children | 7e33516965f8 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 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 | |
3768
6110a4995ace
replacing std::auto_ptr by std::unique_ptr in GDCM sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
22 #include "../../../Core/Compatibility.h" |
1834 | 23 #include "GdcmDecoderCache.h" |
1837 | 24 #include "OrthancImageWrapper.h" |
1834 | 25 |
26 #include <orthanc/OrthancCPlugin.h> | |
27 | |
28 static OrthancPluginContext* context_ = NULL; | |
29 static OrthancPlugins::GdcmDecoderCache cache_; | |
30 | |
31 | |
32 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target, | |
33 const void* dicom, | |
34 const uint32_t size, | |
35 uint32_t frameIndex) | |
36 { | |
37 try | |
38 { | |
3768
6110a4995ace
replacing std::auto_ptr by std::unique_ptr in GDCM sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
39 std::unique_ptr<OrthancPlugins::OrthancImageWrapper> image; |
1837 | 40 |
1834 | 41 #if 0 |
42 // Do not use the cache | |
43 OrthancPlugins::GdcmImageDecoder decoder(dicom, size); | |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1837
diff
changeset
|
44 image.reset(new OrthancPlugins::OrthancImageWrapper(context_, decoder.Decode(context_, frameIndex))); |
1834 | 45 #else |
1837 | 46 image.reset(cache_.Decode(context_, dicom, size, frameIndex)); |
1834 | 47 #endif |
48 | |
1837 | 49 *target = image->Release(); |
50 | |
1834 | 51 return OrthancPluginErrorCode_Success; |
52 } | |
53 catch (std::runtime_error& e) | |
54 { | |
55 *target = NULL; | |
56 | |
57 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
|
58 OrthancPluginLogInfo(context_, s.c_str()); |
1834 | 59 return OrthancPluginErrorCode_Plugin; |
60 } | |
61 } | |
62 | |
63 | |
64 | |
65 extern "C" | |
66 { | |
67 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
68 { | |
69 context_ = context; | |
70 OrthancPluginLogWarning(context_, "Initializing the advanced decoder of medical images using GDCM"); | |
71 | |
72 | |
73 /* Check the version of the Orthanc core */ | |
74 if (OrthancPluginCheckVersion(context_) == 0) | |
75 { | |
76 char info[1024]; | |
77 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
78 context_->orthancVersion, | |
79 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
80 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
81 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
82 OrthancPluginLogError(context_, info); | |
83 return -1; | |
84 } | |
85 | |
86 OrthancPluginSetDescription(context_, "Advanced decoder of medical images using GDCM."); | |
87 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback); | |
88 | |
89 return 0; | |
90 } | |
91 | |
92 | |
93 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
94 { | |
95 } | |
96 | |
97 | |
98 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
99 { | |
100 return "gdcm-decoder"; | |
101 } | |
102 | |
103 | |
104 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
105 { | |
106 return GDCM_DECODER_VERSION; | |
107 } | |
108 } |