Mercurial > hg > orthanc-stl
comparison Sources/Plugin.cpp @ 46:9b2a2fcc9878 nexus
added option to disable Nexus support
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Apr 2024 07:49:45 +0200 |
parents | 967f947014ac |
children | a70fc4846be1 |
comparison
equal
deleted
inserted
replaced
45:967f947014ac | 46:9b2a2fcc9878 |
---|---|
20 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 **/ | 22 **/ |
23 | 23 |
24 | 24 |
25 #if !defined(ORTHANC_ENABLE_NEXUS) | |
26 # error Macro ORTHANC_ENABLE_NEXUS must be defined | |
27 #endif | |
28 | |
25 #include "StructureSetGeometry.h" | 29 #include "StructureSetGeometry.h" |
26 #include "STLToolbox.h" | 30 #include "STLToolbox.h" |
27 #include "VTKToolbox.h" | 31 #include "VTKToolbox.h" |
28 | 32 |
29 #include <EmbeddedResources.h> | 33 #include <EmbeddedResources.h> |
30 | 34 |
31 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | 35 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
32 | 36 |
33 #include <Cache/MemoryStringCache.h> | |
34 #include <DicomParsing/FromDcmtkBridge.h> | 37 #include <DicomParsing/FromDcmtkBridge.h> |
35 #include <Images/ImageProcessing.h> | 38 #include <Images/ImageProcessing.h> |
36 #include <Logging.h> | 39 #include <Logging.h> |
37 #include <SerializationToolbox.h> | 40 #include <SerializationToolbox.h> |
38 #include <SystemToolbox.h> | 41 #include <SystemToolbox.h> |
39 | 42 |
40 #include <vtkNew.h> | 43 #include <vtkNew.h> |
41 | 44 |
42 #include <boost/algorithm/string.hpp> | 45 #include <boost/algorithm/string.hpp> |
43 #include <boost/thread/shared_mutex.hpp> | 46 #include <boost/thread/shared_mutex.hpp> |
47 | |
48 | |
49 #if ORTHANC_ENABLE_NEXUS == 1 | |
50 # include <Cache/MemoryStringCache.h> | |
51 #endif | |
44 | 52 |
45 #define ORTHANC_PLUGIN_NAME "stl" | 53 #define ORTHANC_PLUGIN_NAME "stl" |
46 | 54 |
47 | 55 |
48 // Forward declaration | 56 // Forward declaration |
700 OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), Orthanc::MIME_JSON); | 708 OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), Orthanc::MIME_JSON); |
701 } | 709 } |
702 } | 710 } |
703 | 711 |
704 | 712 |
713 #if ORTHANC_ENABLE_NEXUS == 1 | |
714 | |
705 void ServeNexusAssets(OrthancPluginRestOutput* output, | 715 void ServeNexusAssets(OrthancPluginRestOutput* output, |
706 const char* url, | 716 const char* url, |
707 const OrthancPluginHttpRequest* request) | 717 const OrthancPluginHttpRequest* request) |
708 { | 718 { |
709 if (request->method != OrthancPluginHttpMethod_Get) | 719 if (request->method != OrthancPluginHttpMethod_Get) |
866 OrthancPluginSetHttpHeader(context, output, "Content-Type", "application/octet-stream"); | 876 OrthancPluginSetHttpHeader(context, output, "Content-Type", "application/octet-stream"); |
867 | 877 |
868 OrthancPluginSendHttpStatus(context, output, 206 /* partial content */, part.c_str(), part.size()); | 878 OrthancPluginSendHttpStatus(context, output, 206 /* partial content */, part.c_str(), part.size()); |
869 } | 879 } |
870 | 880 |
881 #endif | |
882 | |
871 | 883 |
872 extern "C" | 884 extern "C" |
873 { | 885 { |
874 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | 886 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
875 { | 887 { |
914 { | 926 { |
915 OrthancPlugins::RegisterRestCallback<EncodeStructureSet>("/stl/encode-rtstruct", true); | 927 OrthancPlugins::RegisterRestCallback<EncodeStructureSet>("/stl/encode-rtstruct", true); |
916 OrthancPlugins::RegisterRestCallback<EncodeNifti>("/stl/encode-nifti", true); | 928 OrthancPlugins::RegisterRestCallback<EncodeNifti>("/stl/encode-nifti", true); |
917 } | 929 } |
918 | 930 |
931 #if ORTHANC_ENABLE_NEXUS == 1 | |
919 nexusCache_.SetMaximumSize(512 * 1024 * 1024); // Cache of 512MB for Nexus | 932 nexusCache_.SetMaximumSize(512 * 1024 * 1024); // Cache of 512MB for Nexus |
920 OrthancPlugins::RegisterRestCallback<ExtractNexusModel>("/instances/([0-9a-f-]+)/nexus", true); | 933 OrthancPlugins::RegisterRestCallback<ExtractNexusModel>("/instances/([0-9a-f-]+)/nexus", true); |
921 OrthancPlugins::RegisterRestCallback<ServeNexusAssets>("/stl/nexus/(.*)", true); | 934 OrthancPlugins::RegisterRestCallback<ServeNexusAssets>("/stl/nexus/(.*)", true); |
935 #endif | |
922 | 936 |
923 OrthancPlugins::OrthancConfiguration globalConfiguration; | 937 OrthancPlugins::OrthancConfiguration globalConfiguration; |
924 OrthancPlugins::OrthancConfiguration configuration; | 938 OrthancPlugins::OrthancConfiguration configuration; |
925 globalConfiguration.GetSection(configuration, "STL"); | 939 globalConfiguration.GetSection(configuration, "STL"); |
926 | 940 |
931 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); | 945 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); |
932 | 946 |
933 std::map<std::string, std::string> dictionary; | 947 std::map<std::string, std::string> dictionary; |
934 dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); | 948 dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); |
935 dictionary["SHOW_NIFTI_BUTTON"] = (configuration.GetBooleanValue("EnableNIfTI", false) ? "true" : "false"); | 949 dictionary["SHOW_NIFTI_BUTTON"] = (configuration.GetBooleanValue("EnableNIfTI", false) ? "true" : "false"); |
950 dictionary["IS_NEXUS_ENABLED"] = (ORTHANC_ENABLE_NEXUS == 1 ? "true" : "false"); | |
936 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); | 951 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); |
937 | 952 |
938 OrthancPlugins::ExtendOrthancExplorer(ORTHANC_PLUGIN_NAME, explorer); | 953 OrthancPlugins::ExtendOrthancExplorer(ORTHANC_PLUGIN_NAME, explorer); |
939 } | 954 } |
940 | 955 |