[med-svn] [Git][med-team/orthanc-gdcm][upstream] New upstream version 1.4
Sebastien Jodogne (@jodogne-guest)
gitlab at salsa.debian.org
Thu Jul 8 15:28:11 BST 2021
Sebastien Jodogne pushed to branch upstream at Debian Med / orthanc-gdcm
Commits:
f3ca80fc by jodogne-guest at 2021-07-08T15:59:08+02:00
New upstream version 1.4
- - - - -
22 changed files:
- .hg_archival.txt
- CMakeLists.txt
- NEWS
- Plugin/GdcmDecoderCache.cpp
- Plugin/GdcmDecoderCache.h
- Plugin/GdcmImageDecoder.cpp
- Plugin/GdcmImageDecoder.h
- Plugin/Plugin.cpp
- Resources/CMake/GdcmConfiguration.cmake
- Resources/Orthanc/CMake/AutoGeneratedCode.cmake
- Resources/Orthanc/CMake/Compiler.cmake
- Resources/Orthanc/CMake/DownloadOrthancFramework.cmake
- Resources/Orthanc/CMake/DownloadPackage.cmake
- Resources/Orthanc/LinuxStandardBaseToolchain.cmake
- Resources/Orthanc/MinGW-W64-Toolchain32.cmake
- Resources/Orthanc/MinGW-W64-Toolchain64.cmake
- Resources/Orthanc/MinGWToolchain.cmake
- Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp
- Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h
- Resources/Orthanc/Plugins/OrthancPluginException.h
- Resources/Orthanc/Plugins/OrthancPluginsExports.cmake
- + Resources/RunCppCheck.sh
Changes:
=====================================
.hg_archival.txt
=====================================
@@ -1,6 +1,6 @@
repo: 108d34b53bb89b998dbe89c3bb031241991f13c7
-node: ad9c32ea9eac377df68f81c8a7b670ec7ff2b6b4
-branch: OrthancGdcm-1.2
+node: ef39b0c16e121aa11887e7f3967f849b9dbfa56f
+branch: OrthancGdcm-1.4
latesttag: null
-latesttagdistance: 41
-changessincelatesttag: 45
+latesttagdistance: 52
+changessincelatesttag: 56
=====================================
CMakeLists.txt
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -21,13 +21,13 @@ cmake_minimum_required(VERSION 2.8)
project(OrthancGdcm)
-SET(PLUGIN_VERSION "1.2" CACHE STRING "Version of the plugin")
+SET(PLUGIN_VERSION "1.4" CACHE STRING "Version of the plugin")
if (PLUGIN_VERSION STREQUAL "mainline")
set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "mainline")
set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg")
else()
- set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.8.1")
+ set(ORTHANC_FRAMEWORK_DEFAULT_VERSION "1.9.4")
set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web")
endif()
@@ -50,9 +50,18 @@ set(ORTHANC_SDK_VERSION "1.7.0" CACHE STRING "Version of the Orthanc plugin SDK
# Download and setup the Orthanc framework
include(${CMAKE_SOURCE_DIR}/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake)
-include_directories(${ORTHANC_FRAMEWORK_ROOT})
-
if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
+ if (ORTHANC_FRAMEWORK_USE_SHARED)
+ include(FindBoost)
+ find_package(Boost COMPONENTS thread)
+
+ if (NOT Boost_FOUND)
+ message(FATAL_ERROR "Unable to locate Boost on this system")
+ endif()
+
+ link_libraries(${Boost_LIBRARIES} jsoncpp)
+ endif()
+
link_libraries(${ORTHANC_FRAMEWORK_LIBRARIES})
else()
@@ -63,6 +72,7 @@ else()
set(ENABLE_MODULE_JOBS OFF CACHE INTERNAL "")
include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake)
+ include_directories(${ORTHANC_FRAMEWORK_ROOT})
endif()
=====================================
NEWS
=====================================
@@ -2,6 +2,19 @@ Pending changes in the mainline
===============================
+Version 1.4 (2021-07-06)
+========================
+
+* Prevent transcoding of 1bpp DICOM images, as this might crash GDCM
+
+
+Version 1.3 (2021-06-14)
+========================
+
+* Prevent changing SOP class UID from "MR Image Storage" to "Enhanced
+ MR Image Storage" during the transcoding
+
+
Version 1.2 (2020-12-17)
========================
=====================================
Plugin/GdcmDecoderCache.cpp
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
=====================================
Plugin/GdcmDecoderCache.h
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
=====================================
Plugin/GdcmImageDecoder.cpp
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -297,7 +297,7 @@ namespace OrthancPlugins
}
- static void FixPhotometricInterpretation(OrthancImage& image,
+ static void FixPhotometricInterpretation(const OrthancImage& image,
gdcm::PhotometricInterpretation interpretation)
{
switch (interpretation)
=====================================
Plugin/GdcmImageDecoder.h
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
=====================================
Plugin/Plugin.cpp
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -35,6 +35,7 @@
#include <gdcmTagKeywords.h>
#include <gdcmUIDGenerator.h>
#include <gdcmVersion.h>
+#include <gdcmImageHelper.h>
static OrthancPlugins::GdcmDecoderCache cache_;
@@ -192,6 +193,23 @@ static void AnswerTranscoded(OrthancPluginMemoryBuffer* transcoded /* out */,
const gdcm::Image& image,
const gdcm::ImageReader& reader)
{
+ /**
+ * In GDCM, if "ForceRescaleInterceptSlope" is "false" (the default
+ * value), the SOP Class UID (0008,0016) might be changed from
+ * 1.2.840.10008.5.1.4.1.1.4 (MR Image Storage) to
+ * 1.2.840.10008.5.1.4.1.1.4.1 (Enhanced MR Image Storage), because
+ * of function "ImageHelper::ComputeMediaStorageFromModality()" that
+ * is called by "ImageWriter::ComputeTargetMediaStorage()". But,
+ * changing the SOP Class UID is unexpected if doing transcoding.
+ *
+ * As another side-effect, the DICOM tags "ImagePositionPatient"
+ * (0020,0032) and "ImageOrientationPatient" (0020,0037) are removed
+ * from the root of the dataset, and moved into subsequence "Shared
+ * Functional Groups Sequence" (5200,9229). This leads to issue
+ * LSD-598.
+ **/
+ gdcm::ImageHelper::SetForceRescaleInterceptSlope(true);
+
gdcm::ImageWriter writer;
writer.SetImage(image);
writer.SetFile(reader.GetFile());
@@ -322,16 +340,24 @@ OrthancPluginErrorCode TranscoderCallback(
gdcm::TransferSyntax syntax(gdcm::TransferSyntax::GetTSType(allowedSyntaxes[i]));
if (syntax.IsValid())
{
+ if (reader.GetImage().GetPixelFormat().GetBitsAllocated() == 1u)
+ {
+ // Prevent transcoding of 1-bit images, as this might crash GDCM
+ // https://groups.google.com/g/orthanc-users/c/xIwrkFRceuE/m/jwxy50djAQAJ
+ throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Cannot transcode 1bpp DICOM images");
+ }
+
if (reader.GetImage().GetPixelFormat().GetBitsStored() == 16u &&
syntax == gdcm::TransferSyntax::JPEGExtendedProcess2_4)
{
/**
- * This is a temporary workaround for issue #513 in GDCM:
+ * This is a temporary workaround for issue #513 in GDCM
+ * (will be fixed in GDCM 3.0.9):
* https://sourceforge.net/p/gdcm/bugs/513/
* https://groups.google.com/g/orthanc-users/c/xt9hwpj6mlQ
**/
throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
- "Transcoding 16bit images to 1.2.840.10008.1.2.4.51 might lead to a crash in GDCM");
+ "Transcoding 16bpp images to 1.2.840.10008.1.2.4.51 might lead to a crash in GDCM");
}
gdcm::ImageChangeTransferSyntax change;
=====================================
Resources/CMake/GdcmConfiguration.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
=====================================
Resources/Orthanc/CMake/AutoGeneratedCode.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/CMake/Compiler.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
@@ -188,7 +188,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
add_definitions(
-D_CRT_SECURE_NO_WARNINGS=1
)
- link_libraries(rpcrt4 ws2_32)
+ link_libraries(rpcrt4 ws2_32 iphlpapi) # "iphlpapi" is for "SystemToolbox::GetMacAddresses()"
if (CMAKE_COMPILER_IS_GNUCXX)
# Some additional C/C++ compiler flags for MinGW
=====================================
Resources/Orthanc/CMake/DownloadOrthancFramework.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
@@ -120,6 +120,18 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
set(ORTHANC_FRAMEWORK_MD5 "f8ec7554ef5d23ea4ce474b1e8214de9")
elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.1")
set(ORTHANC_FRAMEWORK_MD5 "db094f96399cbe8b9bbdbce34884c220")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.2")
+ set(ORTHANC_FRAMEWORK_MD5 "8bfa10e66c9931e74111be0bfb1f4548")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.0")
+ set(ORTHANC_FRAMEWORK_MD5 "cea0b02ce184671eaf1bd668beefbf28")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.1")
+ set(ORTHANC_FRAMEWORK_MD5 "08eebc66ef93c3b40115c38501db5fbd")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.2")
+ set(ORTHANC_FRAMEWORK_MD5 "3ea66c09f64aca990016683b6375734e")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.3")
+ set(ORTHANC_FRAMEWORK_MD5 "9b86e6f00e03278293cd15643cc0233f")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.4")
+ set(ORTHANC_FRAMEWORK_MD5 "6d5ca4a73ac7d42445041ca79de1624d")
# Below this point are development snapshots that were used to
# release some plugin, before an official release of the Orthanc
@@ -137,6 +149,9 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "4a3ba4bf4ba7")
# PostgreSQL 3.3 (framework pre-1.8.2)
set(ORTHANC_FRAMEWORK_MD5 "2d82bddf06f9cfe82095495cb3b8abde")
+ elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "23ad1b9c7800")
+ # For "Toolbox::ReadJson()" and "Toolbox::Write{...}Json()" (pre-1.9.0)
+ set(ORTHANC_FRAMEWORK_MD5 "9af92080e57c60dd288eba46ce606c00")
endif()
endif()
endif()
@@ -421,6 +436,8 @@ endif()
if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
+ set(ORTHANC_FRAMEWORK_USE_SHARED ON CACHE BOOL "Whether to use the shared library or the static library")
+ set(ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional libraries to link against, separated by whitespaces, typically needed if using the static library (a common minimal value is \"boost_filesystem boost_iostreams boost_locale boost_regex boost_thread jsoncpp pugixml uuid\")")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
CMAKE_COMPILER_IS_GNUCXX) # MinGW
@@ -437,113 +454,75 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
- if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR
- ORTHANC_FRAMEWORK_STATIC)
- include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
+ if (ORTHANC_FRAMEWORK_USE_SHARED)
+ list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
+ list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
+ else()
+ list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
+ list(GET CMAKE_FIND_LIBRARY_SUFFIXES 1 Suffix)
+ endif()
+
+ # The "OrthancFramework" library must be the first one to be included
+ if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
+ set(ORTHANC_FRAMEWORK_LIBRARIES ${Prefix}OrthancFramework${Suffix})
+ else ()
+ set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix})
+ endif()
+
+ if (NOT ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES STREQUAL "")
+ # https://stackoverflow.com/a/5272993/881731
+ string(REPLACE " " ";" tmp ${ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES})
+ list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${tmp})
+ endif()
+
+ # Look for the version of the mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
+ if (CMAKE_CROSSCOMPILING)
+ set(JSONCPP_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}/..)
else()
- # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
find_path(JSONCPP_INCLUDE_DIR json/reader.h
+ ${ORTHANC_FRAMEWORK_ROOT}/..
/usr/include/jsoncpp
/usr/local/include/jsoncpp
)
+ endif()
- message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
- include_directories(${JSONCPP_INCLUDE_DIR})
- link_libraries(jsoncpp)
-
- CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
- if (NOT HAVE_JSONCPP_H)
- message(FATAL_ERROR "Please install the libjsoncpp-dev package")
- endif()
-
- # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
- # (same as variable JSONCPP_CXX11 in the source code of Orthanc)
- if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
- file(STRINGS
- "${JSONCPP_INCLUDE_DIR}/json/version.h"
- JSONCPP_VERSION_MAJOR1 REGEX
- ".*define JSONCPP_VERSION_MAJOR.*")
+ message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
+ include_directories(${JSONCPP_INCLUDE_DIR})
- if (NOT JSONCPP_VERSION_MAJOR1)
- message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
- endif()
-
- string(REGEX REPLACE
- ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
- JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
- message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
-
- if (JSONCPP_VERSION_MAJOR GREATER 0)
- message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
- if (CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
- elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- endif()
- endif()
- else()
- message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
- endif()
+ CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
+ if (NOT HAVE_JSONCPP_H)
+ message(FATAL_ERROR "Please install the libjsoncpp-dev package")
+ endif()
- # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
- include(FindBoost)
- find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS})
+ # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
+ # (same as variable JSONCPP_CXX11 in the source code of Orthanc)
+ if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
+ file(STRINGS
+ "${JSONCPP_INCLUDE_DIR}/json/version.h"
+ JSONCPP_VERSION_MAJOR1 REGEX
+ ".*define JSONCPP_VERSION_MAJOR.*")
- if (NOT Boost_FOUND)
- message(FATAL_ERROR "Unable to locate Boost on this system")
+ if (NOT JSONCPP_VERSION_MAJOR1)
+ message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
endif()
- include_directories(${Boost_INCLUDE_DIRS})
- link_libraries(${Boost_LIBRARIES})
-
- # Optional component - Lua
- if (ENABLE_LUA)
- include(FindLua)
-
- if (NOT LUA_FOUND)
- message(FATAL_ERROR "Please install the liblua-dev package")
+ string(REGEX REPLACE
+ ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
+ JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
+ message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
+
+ if (JSONCPP_VERSION_MAJOR GREATER 0)
+ message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
-
- include_directories(${LUA_INCLUDE_DIR})
- link_libraries(${LUA_LIBRARIES})
- endif()
-
- # Optional component - SQLite
- if (ENABLE_SQLITE)
- CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
- if (NOT HAVE_SQLITE_H)
- message(FATAL_ERROR "Please install the libsqlite3-dev package")
- endif()
- link_libraries(sqlite3)
- endif()
-
- # Optional component - Pugixml
- if (ENABLE_PUGIXML)
- CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H)
- if (NOT HAVE_PUGIXML_H)
- message(FATAL_ERROR "Please install the libpugixml-dev package")
- endif()
- link_libraries(pugixml)
- endif()
-
- # Optional component - DCMTK
- if (ENABLE_DCMTK)
- include(FindDCMTK)
- include_directories(${DCMTK_INCLUDE_DIRS})
- link_libraries(${DCMTK_LIBRARIES})
- endif()
-
- # Optional component - OpenSSL
- if (ENABLE_SSL)
- include(FindOpenSSL)
- if (NOT ${OPENSSL_FOUND})
- message(FATAL_ERROR "Unable to find OpenSSL")
- endif()
- include_directories(${OPENSSL_INCLUDE_DIR})
- link_libraries(${OPENSSL_LIBRARIES})
endif()
+ else()
+ message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
endif()
-
+
# Look for Orthanc framework shared library
include(CheckCXXSymbolExists)
@@ -563,28 +542,17 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
-
- if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
- set(ORTHANC_FRAMEWORK_LIBRARIES OrthancFramework)
- else()
- if (MSVC)
- set(Suffix ".lib")
- set(Prefix "")
- else()
- list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
- list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
- endif()
- set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix})
- endif()
- set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
- set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}")
-
- check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
- if (NOT HAVE_ORTHANC_FRAMEWORK)
- message(FATAL_ERROR "Cannot find the Orthanc framework")
+ if (ORTHANC_FRAMEWORK_USE_SHARED)
+ set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
+ set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}")
+
+ check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
+ if (NOT HAVE_ORTHANC_FRAMEWORK)
+ message(FATAL_ERROR "Cannot find the Orthanc framework")
+ endif()
+
+ unset(CMAKE_REQUIRED_INCLUDES)
+ unset(CMAKE_REQUIRED_LIBRARIES)
endif()
-
- unset(CMAKE_REQUIRED_INCLUDES)
- unset(CMAKE_REQUIRED_LIBRARIES)
endif()
=====================================
Resources/Orthanc/CMake/DownloadPackage.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/LinuxStandardBaseToolchain.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/MinGW-W64-Toolchain32.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/MinGW-W64-Toolchain64.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/MinGWToolchain.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
=====================================
Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -24,9 +24,33 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/move/unique_ptr.hpp>
#include <boost/thread.hpp>
+
+
#include <json/reader.h>
+#include <json/version.h>
#include <json/writer.h>
+#if !defined(JSONCPP_VERSION_MAJOR) || !defined(JSONCPP_VERSION_MINOR)
+# error Cannot access the version of JsonCpp
+#endif
+
+
+/**
+ * We use deprecated "Json::Reader", "Json::StyledWriter" and
+ * "Json::FastWriter" if JsonCpp < 1.7.0. This choice is rather
+ * arbitrary, but if Json >= 1.9.0, gcc generates explicit deprecation
+ * warnings (clang was warning in earlier versions). For reference,
+ * these classes seem to have been deprecated since JsonCpp 1.4.0 (on
+ * February 2015) by the following changeset:
+ * https://github.com/open-source-parsers/jsoncpp/commit/8df98f6112890d6272734975dd6d70cf8999bb22
+ **/
+#if (JSONCPP_VERSION_MAJOR >= 2 || \
+ (JSONCPP_VERSION_MAJOR == 1 && JSONCPP_VERSION_MINOR >= 8))
+# define JSONCPP_USE_DEPRECATED 0
+#else
+# define JSONCPP_USE_DEPRECATED 1
+#endif
+
#if !ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 2, 0)
static const OrthancPluginErrorCode OrthancPluginErrorCode_NullPointer = OrthancPluginErrorCode_Plugin;
@@ -202,10 +226,7 @@ namespace OrthancPlugins
ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
}
- const char* tmp = reinterpret_cast<const char*>(buffer_.data);
-
- Json::Reader reader;
- if (!reader.parse(tmp, tmp + buffer_.size, target))
+ if (!ReadJson(target, buffer_.data, buffer_.size))
{
LogError("Cannot convert some memory buffer to JSON");
ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
@@ -292,12 +313,102 @@ namespace OrthancPlugins
}
+ static bool ReadJsonInternal(Json::Value& target,
+ const void* buffer,
+ size_t size,
+ bool collectComments)
+ {
+#if JSONCPP_USE_DEPRECATED == 1
+ Json::Reader reader;
+ return reader.parse(reinterpret_cast<const char*>(buffer),
+ reinterpret_cast<const char*>(buffer) + size, target, collectComments);
+#else
+ Json::CharReaderBuilder builder;
+ builder.settings_["collectComments"] = collectComments;
+
+ const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
+ assert(reader.get() != NULL);
+
+ JSONCPP_STRING err;
+ if (reader->parse(reinterpret_cast<const char*>(buffer),
+ reinterpret_cast<const char*>(buffer) + size, &target, &err))
+ {
+ return true;
+ }
+ else
+ {
+ LogError("Cannot parse JSON: " + std::string(err));
+ return false;
+ }
+#endif
+ }
+
+
+ bool ReadJson(Json::Value& target,
+ const std::string& source)
+ {
+ return ReadJson(target, source.empty() ? NULL : source.c_str(), source.size());
+ }
+
+
+ bool ReadJson(Json::Value& target,
+ const void* buffer,
+ size_t size)
+ {
+ return ReadJsonInternal(target, buffer, size, true);
+ }
+
+
+ bool ReadJsonWithoutComments(Json::Value& target,
+ const std::string& source)
+ {
+ return ReadJsonWithoutComments(target, source.empty() ? NULL : source.c_str(), source.size());
+ }
+
+
+ bool ReadJsonWithoutComments(Json::Value& target,
+ const void* buffer,
+ size_t size)
+ {
+ return ReadJsonInternal(target, buffer, size, false);
+ }
+
+
+ void WriteFastJson(std::string& target,
+ const Json::Value& source)
+ {
+#if JSONCPP_USE_DEPRECATED == 1
+ Json::FastWriter writer;
+ target = writer.write(source);
+#else
+ Json::StreamWriterBuilder builder;
+ builder.settings_["indentation"] = "";
+ target = Json::writeString(builder, source);
+#endif
+ }
+
+
+ void WriteStyledJson(std::string& target,
+ const Json::Value& source)
+ {
+#if JSONCPP_USE_DEPRECATED == 1
+ Json::StyledWriter writer;
+ target = writer.write(source);
+#else
+ Json::StreamWriterBuilder builder;
+ builder.settings_["indentation"] = " ";
+ target = Json::writeString(builder, source);
+#endif
+ }
+
+
bool MemoryBuffer::RestApiPost(const std::string& uri,
const Json::Value& body,
bool applyPlugins)
{
- Json::FastWriter writer;
- return RestApiPost(uri, writer.write(body), applyPlugins);
+ std::string s;
+ WriteFastJson(s, body);
+ return RestApiPost(uri, s, applyPlugins);
}
@@ -305,8 +416,9 @@ namespace OrthancPlugins
const Json::Value& body,
bool applyPlugins)
{
- Json::FastWriter writer;
- return RestApiPut(uri, writer.write(body), applyPlugins);
+ std::string s;
+ WriteFastJson(s, body);
+ return RestApiPut(uri, s, applyPlugins);
}
@@ -315,8 +427,8 @@ namespace OrthancPlugins
{
Clear();
- Json::FastWriter writer;
- std::string s = writer.write(tags);
+ std::string s;
+ WriteFastJson(s, tags);
Check(OrthancPluginCreateDicom(GetGlobalContext(), &buffer_, s.c_str(), NULL, flags));
}
@@ -327,8 +439,8 @@ namespace OrthancPlugins
{
Clear();
- Json::FastWriter writer;
- std::string s = writer.write(tags);
+ std::string s;
+ WriteFastJson(s, tags);
Check(OrthancPluginCreateDicom(GetGlobalContext(), &buffer_, s.c_str(), pixelData.GetObject(), flags));
}
@@ -390,8 +502,7 @@ namespace OrthancPlugins
ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError);
}
- Json::Reader reader;
- if (!reader.parse(str_, target))
+ if (!ReadJson(target, str_))
{
LogError("Cannot convert some memory buffer to JSON");
ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
@@ -1190,19 +1301,16 @@ namespace OrthancPlugins
#endif /* HAS_ORTHANC_PLUGIN_FIND_MATCHER == 1 */
void AnswerJson(const Json::Value& value,
- OrthancPluginRestOutput* output
- )
+ OrthancPluginRestOutput* output)
{
- Json::StyledWriter writer;
- std::string bodyString = writer.write(value);
-
+ std::string bodyString;
+ WriteStyledJson(bodyString, value);
OrthancPluginAnswerBuffer(GetGlobalContext(), output, bodyString.c_str(), bodyString.size(), "application/json");
}
void AnswerString(const std::string& answer,
const char* mimeType,
- OrthancPluginRestOutput* output
- )
+ OrthancPluginRestOutput* output)
{
OrthancPluginAnswerBuffer(GetGlobalContext(), output, answer.c_str(), answer.size(), mimeType);
}
@@ -1324,8 +1432,9 @@ namespace OrthancPlugins
const Json::Value& body,
bool applyPlugins)
{
- Json::FastWriter writer;
- return RestApiPost(result, uri, writer.write(body), applyPlugins);
+ std::string s;
+ WriteFastJson(s, body);
+ return RestApiPost(result, uri, s, applyPlugins);
}
@@ -1357,8 +1466,9 @@ namespace OrthancPlugins
const Json::Value& body,
bool applyPlugins)
{
- Json::FastWriter writer;
- return RestApiPut(result, uri, writer.write(body), applyPlugins);
+ std::string s;
+ WriteFastJson(s, body);
+ return RestApiPut(result, uri, s, applyPlugins);
}
@@ -2020,8 +2130,7 @@ namespace OrthancPlugins
}
else
{
- Json::FastWriter writer;
- content_ = writer.write(content);
+ WriteFastJson(content_, content);
}
}
@@ -2041,8 +2150,7 @@ namespace OrthancPlugins
}
else
{
- Json::FastWriter writer;
- serialized_ = writer.write(serialized);
+ WriteFastJson(serialized_, serialized);
hasSerialized_ = true;
}
}
@@ -2618,10 +2726,18 @@ namespace OrthancPlugins
delete *it;
}
+ size_ = 0;
content_.clear();
}
- void Flatten(std::string& target) const
+ /**
+ * Since Orthanc 1.9.3, this function also clears the content of
+ * the ChunkedBuffer in order to mimic the behavior of the
+ * original class "Orthanc::ChunkedBuffer". This prevents the
+ * forgetting of calling "Clear()" in order to reduce memory
+ * consumption.
+ **/
+ void Flatten(std::string& target)
{
target.resize(size_);
@@ -2637,10 +2753,14 @@ namespace OrthancPlugins
memcpy(&target[pos], (*it)->c_str(), s);
pos += s;
}
+
+ delete *it;
}
- assert(size_ == 0 ||
- pos == target.size());
+ assert(pos == target.size());
+
+ size_ = 0;
+ content_.clear();
}
void AddChunk(const void* data,
@@ -2671,7 +2791,7 @@ namespace OrthancPlugins
return headers_;
}
- const ChunkedBuffer& GetBody() const
+ ChunkedBuffer& GetBody()
{
return body_;
}
@@ -2902,8 +3022,7 @@ namespace OrthancPlugins
std::string body;
Execute(answerHeaders, body);
- Json::Reader reader;
- if (!reader.parse(body, answerBody))
+ if (!ReadJson(answerBody, body))
{
LogError("Cannot convert HTTP answer body to JSON");
ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
=====================================
Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -476,6 +476,26 @@ namespace OrthancPlugins
#endif
+ bool ReadJson(Json::Value& target,
+ const std::string& source);
+
+ bool ReadJson(Json::Value& target,
+ const void* buffer,
+ size_t size);
+
+ bool ReadJsonWithoutComments(Json::Value& target,
+ const std::string& source);
+
+ bool ReadJsonWithoutComments(Json::Value& target,
+ const void* buffer,
+ size_t size);
+
+ void WriteFastJson(std::string& target,
+ const Json::Value& source);
+
+ void WriteStyledJson(std::string& target,
+ const Json::Value& source);
+
bool RestApiGet(Json::Value& result,
const std::string& uri,
bool applyPlugins);
=====================================
Resources/Orthanc/Plugins/OrthancPluginException.h
=====================================
@@ -2,7 +2,7 @@
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2020 Osimis S.A., Belgium
+ * Copyright (C) 2017-2021 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
=====================================
Resources/Orthanc/Plugins/OrthancPluginsExports.cmake
=====================================
@@ -1,7 +1,7 @@
# Orthanc - A Lightweight, RESTful DICOM Store
# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
# Department, University Hospital of Liege, Belgium
-# Copyright (C) 2017-2020 Osimis S.A., Belgium
+# Copyright (C) 2017-2021 Osimis S.A., Belgium
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
=====================================
Resources/RunCppCheck.sh
=====================================
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -ex
+
+CPPCHECK=cppcheck
+
+if [ $# -ge 1 ]; then
+ CPPCHECK=$1
+fi
+
+cat <<EOF > /tmp/cppcheck-suppressions.txt
+unusedFunction
+EOF
+
+${CPPCHECK} --enable=all --quiet --std=c++11 \
+ --suppressions-list=/tmp/cppcheck-suppressions.txt \
+ -DHAS_ORTHANC_EXCEPTION=1 \
+ -DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1 \
+ -DORTHANC_ENABLE_BASE64=1 \
+ -DORTHANC_ENABLE_CIVETWEB=0 \
+ -DORTHANC_ENABLE_CURL=1 \
+ -DORTHANC_ENABLE_DCMTK=1 \
+ -DORTHANC_ENABLE_DCMTK_JPEG=1 \
+ -DORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS=1 \
+ -DORTHANC_ENABLE_GLEW=1 \
+ -DORTHANC_ENABLE_JPEG=1 \
+ -DORTHANC_ENABLE_LOCALE=1 \
+ -DORTHANC_ENABLE_LOGGING=1 \
+ -DORTHANC_ENABLE_LOGGING_STDIO=1 \
+ -DORTHANC_ENABLE_MD5=1 \
+ -DORTHANC_ENABLE_MONGOOSE=0 \
+ -DORTHANC_ENABLE_OPENGL=1 \
+ -DORTHANC_ENABLE_PKCS11=0 \
+ -DORTHANC_ENABLE_PNG=1 \
+ -DORTHANC_ENABLE_PUGIXML=0 \
+ -DORTHANC_ENABLE_SDL=1 \
+ -DORTHANC_ENABLE_SSL=1 \
+ -DORTHANC_ENABLE_THREADS=1 \
+ -DORTHANC_ENABLE_WASM=1 \
+ -DORTHANC_ENABLE_ZLIB=1 \
+ -DORTHANC_SANDBOXED=0 \
+ -D__GNUC__ \
+ -D__cplusplus=201103 \
+ -D__linux__ \
+ -DEM_ASM \
+ -UNDEBUG \
+ -I/home/jodogne/Subversion/orthanc/OrthancFramework/Sources \
+ -I/home/jodogne/Subversion/orthanc/OrthancServer/Plugins/Include/ \
+ \
+ ../Plugin \
+ \
+ 2>&1
View it on GitLab: https://salsa.debian.org/med-team/orthanc-gdcm/-/commit/f3ca80fc3f2bf5c4c03166019cd3b3b2c7a6413d
--
View it on GitLab: https://salsa.debian.org/med-team/orthanc-gdcm/-/commit/f3ca80fc3f2bf5c4c03166019cd3b3b2c7a6413d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210708/ff8c58db/attachment-0001.htm>
More information about the debian-med-commit
mailing list