Skip to content
Commits on Source (11)
repo: 4a7a53257c7df5a97aea39377b8c9a6e815c9763
node: 84b3128ba48f6f333b4b949794ceac16c3afc820
branch: OrthancWSI-0.4
node: 38d12348a1534ecb5f7c428aa5dd5235b76df338
branch: OrthancWSI-0.5
latesttag: null
latesttagdistance: 102
changessincelatesttag: 103
latesttagdistance: 146
changessincelatesttag: 148
......@@ -14,7 +14,7 @@ Authors
4000 Liege
Belgium
* Osimis <info@osimis.io>
* Osimis S.A. <info@osimis.io>
Rue des Chasseurs Ardennais 3
4031 Liege
Belgium
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -22,11 +22,13 @@
#include "ApplicationToolbox.h"
#include "../Framework/Inputs/OpenSlideLibrary.h"
#include "../Resources/Orthanc/Core/HttpClient.h"
#include "../Resources/Orthanc/Core/Logging.h"
#include "../Resources/Orthanc/Core/MultiThreading/BagOfTasksProcessor.h"
#include "../Resources/Orthanc/Core/SystemToolbox.h"
#include "../Resources/Orthanc/OrthancServer/FromDcmtkBridge.h"
#include <Core/DicomParsing/FromDcmtkBridge.h>
#include <Core/HttpClient.h>
#include <Core/Logging.h>
#include <Core/MultiThreading/BagOfTasksProcessor.h>
#include <Core/OrthancException.h>
#include <Core/SystemToolbox.h>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
......@@ -35,6 +37,16 @@
#include <cassert>
static const char* OPTION_CA_CERTIFICATES = "ca-certificates";
static const char* OPTION_PASSWORD = "password";
static const char* OPTION_PROXY = "proxy";
static const char* OPTION_TIMEOUT = "timeout";
static const char* OPTION_URL = "orthanc";
static const char* OPTION_USERNAME = "username";
static const char* OPTION_VERIFY_PEERS = "verify-peers";
static bool DisplayPerformanceWarning()
{
(void) DisplayPerformanceWarning; // Disable warning about unused function
......@@ -163,6 +175,11 @@ namespace OrthancWSI
bool ok = false;
boost::cmatch what;
// Set white as the default color to avoid compiler warnings
red = 255;
green = 255;
blue = 255;
try
{
if (regex_match(color.c_str(), what, pattern))
......@@ -200,7 +217,7 @@ namespace OrthancWSI
<< path << " " << ORTHANC_WSI_VERSION << std::endl
<< "Copyright (C) 2012-2016 Sebastien Jodogne, "
<< "Medical Physics Department, University Hospital of Liege (Belgium)" << std::endl
<< "Copyright (C) 2017 Osimis S.A. (Belgium)" << std::endl
<< "Copyright (C) 2017-2018 Osimis S.A. (Belgium)" << std::endl
<< "Licensing AGPL: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl.html>." << std::endl
<< "This is free software: you are free to change and redistribute it." << std::endl
<< "There is NO WARRANTY, to the extent permitted by law." << std::endl
......@@ -229,5 +246,70 @@ namespace OrthancWSI
LOG(WARNING) << "Orthanc WSI version: " << version;
}
void AddRestApiOptions(boost::program_options::options_description& section)
{
section.add_options()
(OPTION_USERNAME, boost::program_options::value<std::string>(),
"Username for the target Orthanc server")
(OPTION_PASSWORD, boost::program_options::value<std::string>(),
"Password for the target Orthanc server")
(OPTION_PROXY, boost::program_options::value<std::string>(),
"HTTP proxy to be used")
(OPTION_TIMEOUT, boost::program_options::value<int>()->default_value(0),
"HTTP timeout (in seconds, 0 means no timeout)")
(OPTION_VERIFY_PEERS, boost::program_options::value<bool>()->default_value(true),
"Enable the verification of the peers during HTTPS requests")
(OPTION_CA_CERTIFICATES, boost::program_options::value<std::string>()->default_value(""),
"Path to the CA (certification authority) certificates to validate peers in HTTPS requests")
;
}
void SetupRestApi(Orthanc::WebServiceParameters& parameters,
const boost::program_options::variables_map& options)
{
if (options.count(OPTION_URL))
{
parameters.SetUrl(options[OPTION_URL].as<std::string>());
}
if (options.count(OPTION_USERNAME) &&
options.count(OPTION_PASSWORD))
{
parameters.SetUsername(options[OPTION_USERNAME].as<std::string>());
parameters.SetPassword(options[OPTION_PASSWORD].as<std::string>());
}
if (options.count(OPTION_TIMEOUT))
{
int timeout = options[OPTION_TIMEOUT].as<int>();
if (timeout < 0)
{
LOG(ERROR) << "Timeouts cannot be negative: " << timeout;
throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
}
else
{
Orthanc::HttpClient::SetDefaultTimeout(timeout);
}
if (options.count(OPTION_PROXY))
{
Orthanc::HttpClient::SetDefaultProxy(options[OPTION_PROXY].as<std::string>());
}
}
#if ORTHANC_ENABLE_SSL == 1
if (options.count(OPTION_VERIFY_PEERS) ||
options.count(OPTION_CA_CERTIFICATES))
{
Orthanc::HttpClient::ConfigureSsl(options[OPTION_VERIFY_PEERS].as<bool>(),
options[OPTION_CA_CERTIFICATES].as<std::string>());
}
#endif
}
}
}
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -21,10 +21,12 @@
#pragma once
#include "../Resources/Orthanc/Core/MultiThreading/BagOfTasks.h"
#include <Core/MultiThreading/BagOfTasks.h>
#include <Core/WebServiceParameters.h>
#include <string>
#include <stdint.h>
#include <boost/program_options.hpp>
namespace OrthancWSI
{
......@@ -45,5 +47,10 @@ namespace OrthancWSI
void PrintVersion(const char* path);
void ShowVersionInLog(const char* path);
void AddRestApiOptions(boost::program_options::options_description& section);
void SetupRestApi(Orthanc::WebServiceParameters& parameters,
const boost::program_options::variables_map& options);
}
}
cmake_minimum_required(VERSION 2.8)
project(OrthancWSIApplications)
include(${CMAKE_SOURCE_DIR}/../Resources/CMake/Version.cmake)
#####################################################################
## Parameters of the build
......@@ -11,31 +13,11 @@ SET(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (nece
SET(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
SET(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof")
# Optional components
SET(ENABLE_SSL OFF CACHE BOOL "Include support for SSL")
SET(USE_DCMTK_361 OFF CACHE BOOL "Use forthcoming DCMTK version 3.6.1 in static builds (instead of 3.6.0)")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(TMP ON)
else()
set(TMP OFF)
endif()
# Advanced parameters to fine-tune linking against system libraries
SET(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
SET(USE_SYSTEM_CURL ON CACHE BOOL "Use the system version of LibCurl")
SET(USE_SYSTEM_DCMTK ON CACHE BOOL "Use the system version of DCMTK")
SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
SET(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
SET(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
SET(USE_SYSTEM_LIBTIFF ON CACHE BOOL "Use the system version of libtiff")
SET(USE_SYSTEM_OPENJPEG ON CACHE BOOL "Use the system version of OpenJpeg")
SET(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL")
SET(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of ZLib")
SET(USE_SYSTEM_ORTHANC_SDK ON CACHE BOOL "Use the system version of the Orthanc plugin SDK")
SET(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionaries \"dicom.dic\" and \"private.dic\" (only when using system version of DCMTK)")
#####################################################################
......@@ -43,56 +25,39 @@ SET(DCMTK_DICTIONARY_DIR "" CACHE PATH "Directory containing the DCMTK dictionar
#####################################################################
SET(ORTHANC_WSI_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
SET(ORTHANC_ROOT ${ORTHANC_WSI_DIR}/Resources/Orthanc)
SET(USE_OPENJPEG_JP2 ON)
SET(ENABLE_JPEG OFF) # Disable DCMTK's support for JPEG, that clashes with libtiff
SET(ENABLE_JPEG_LOSSLESS OFF) # Disable DCMTK's support for JPEG-LS
SET(ENABLE_DCMTK_NETWORK OFF) # Disable DCMTK's support for DICOM networking
include(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/DownloadOrthancFramework.cmake)
UNSET(STANDALONE_BUILD CACHE)
SET(STANDALONE_BUILD ON) # Embed DCMTK's dictionaries for static builds
SET(USE_DCMTK_361_PRIVATE_DIC OFF) # No need for private tags
include(CheckIncludeFiles)
include(CheckIncludeFileCXX)
include(CheckLibraryExists)
include(FindPythonInterp)
include(FindPkgConfig)
include(CheckSymbolExists)
include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/AutoGeneratedCode.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
set(ORTHANC_FRAMEWORK_PLUGIN OFF)
include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
SET(ENABLE_CRYPTO_OPTIONS ON)
SET(ENABLE_DCMTK ON)
SET(ENABLE_DCMTK_JPEG OFF) # Disable DCMTK's support for JPEG, that clashes with libtiff
SET(ENABLE_DCMTK_JPEG_LOSSLESS OFF) # Disable DCMTK's support for JPEG-LS
SET(ENABLE_DCMTK_NETWORKING OFF) # Disable DCMTK's support for DICOM networking
SET(ENABLE_JPEG ON)
SET(ENABLE_LOCALE ON) # Enable support for locales (notably in Boost)
SET(ENABLE_PNG ON)
SET(ENABLE_SSL ON)
SET(ENABLE_WEB_CLIENT ON)
SET(ENABLE_ZLIB ON)
SET(HAS_EMBEDDED_RESOURCES ON)
include(${ORTHANC_ROOT}/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/OrthancFrameworkConfiguration.cmake)
include_directories(${ORTHANC_ROOT})
# Third-party components shipped with Orthanc
include(${ORTHANC_ROOT}/Resources/CMake/DcmtkConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/LibCurlConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/LibJpegConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake)
include(${ORTHANC_ROOT}/Resources/CMake/ZlibConfiguration.cmake)
# Include components specific to WSI
include(${ORTHANC_WSI_DIR}/Resources/CMake/Version.cmake)
include(${ORTHANC_WSI_DIR}/Resources/CMake/BoostExtendedConfiguration.cmake)
include(${ORTHANC_WSI_DIR}/Resources/CMake/OpenJpegConfiguration.cmake)
include(${ORTHANC_WSI_DIR}/Resources/CMake/LibTiffConfiguration.cmake)
add_definitions(
-DORTHANC_BUILD_UNIT_TESTS=0 # For FromDcmtkBridge
-DORTHANC_ENABLE_BASE64=1
-DORTHANC_ENABLE_CURL=1
-DORTHANC_ENABLE_DCMTK=1
-DORTHANC_ENABLE_JPEG=0 # Disable DCMTK's support for JPEG
-DORTHANC_ENABLE_LOGGING=1
-DORTHANC_ENABLE_LOGGING_PLUGIN=0
-DORTHANC_ENABLE_LUA=0 # For FromDcmtkBridge
-DORTHANC_ENABLE_MD5=0
-DORTHANC_ENABLE_PKCS11=0
-DORTHANC_ENABLE_PLUGINS=1 # To enable class Orthanc::SharedLibrary
-DORTHANC_ENABLE_PUGIXML=0
-DORTHANC_SANDBOXED=0
-DHAS_ORTHANC_EXCEPTION=1
)
#####################################################################
......@@ -100,7 +65,7 @@ add_definitions(
#####################################################################
if (STATIC_BUILD OR NOT USE_SYSTEM_ORTHANC_SDK)
include_directories(${ORTHANC_ROOT}/Sdk-1.0.0)
include_directories(${CMAKE_SOURCE_DIR}/../Resources/Orthanc/Sdk-1.0.0)
else ()
CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H)
if (NOT HAVE_ORTHANC_H)
......@@ -109,19 +74,6 @@ else ()
endif()
#####################################################################
## Configure optional third-party components
#####################################################################
if (ENABLE_SSL)
set(ENABLE_PKCS11 OFF)
add_definitions(-DORTHANC_ENABLE_SSL=1)
include(${ORTHANC_ROOT}/Resources/CMake/OpenSslConfiguration.cmake)
else()
add_definitions(-DORTHANC_ENABLE_SSL=0)
endif()
#####################################################################
## Create the list of the source files that depend upon the
## precompiled headers
......@@ -158,49 +110,6 @@ set(ORTHANC_WSI_SOURCES
${ORTHANC_WSI_DIR}/Framework/Outputs/TruncatedPyramidWriter.cpp
)
set(ORTHANC_CORE_SOURCES
${ORTHANC_ROOT}/Core/ChunkedBuffer.cpp
${ORTHANC_ROOT}/Core/DicomFormat/DicomArray.cpp
${ORTHANC_ROOT}/Core/DicomFormat/DicomMap.cpp
${ORTHANC_ROOT}/Core/DicomFormat/DicomTag.cpp
${ORTHANC_ROOT}/Core/DicomFormat/DicomValue.cpp
${ORTHANC_ROOT}/Core/Enumerations.cpp
${ORTHANC_ROOT}/Core/HttpClient.cpp
${ORTHANC_ROOT}/Core/Images/IImageWriter.cpp
${ORTHANC_ROOT}/Core/Images/Image.cpp
${ORTHANC_ROOT}/Core/Images/ImageAccessor.cpp
${ORTHANC_ROOT}/Core/Images/ImageBuffer.cpp
${ORTHANC_ROOT}/Core/Images/ImageProcessing.cpp
${ORTHANC_ROOT}/Core/Images/JpegErrorManager.cpp
${ORTHANC_ROOT}/Core/Images/JpegReader.cpp
${ORTHANC_ROOT}/Core/Images/JpegWriter.cpp
${ORTHANC_ROOT}/Core/Images/PngReader.cpp
${ORTHANC_ROOT}/Core/Images/PngWriter.cpp
${ORTHANC_ROOT}/Core/Logging.cpp
${ORTHANC_ROOT}/Core/MultiThreading/BagOfTasksProcessor.cpp
${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp
${ORTHANC_ROOT}/Core/SystemToolbox.cpp
${ORTHANC_ROOT}/Core/TemporaryFile.cpp
${ORTHANC_ROOT}/Core/Toolbox.cpp
${ORTHANC_ROOT}/Core/WebServiceParameters.cpp
${ORTHANC_ROOT}/OrthancServer/FromDcmtkBridge.cpp
${ORTHANC_ROOT}/OrthancServer/ServerEnumerations.cpp
${ORTHANC_ROOT}/OrthancServer/ToDcmtkBridge.cpp
${ORTHANC_ROOT}/Plugins/Engine/SharedLibrary.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomPath.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomTag.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/FullOrthancDataset.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/IOrthancConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancHttpConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/SimplifiedOrthancDataset.cpp
${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp
)
EmbedResources(
${DCMTK_DICTIONARIES}
BRIGHTFIELD_OPTICAL_PATH ${ORTHANC_WSI_DIR}/Resources/BrightfieldOpticalPath.json
......@@ -208,6 +117,10 @@ EmbedResources(
SRGB_ICC_PROFILE ${ORTHANC_WSI_DIR}/Resources/sRGB.icc
)
add_definitions(
-DHAS_ORTHANC_EXCEPTION=1
)
#####################################################################
## Setup precompiled headers for Microsoft Visual Studio
......@@ -216,11 +129,18 @@ EmbedResources(
if (MSVC)
add_definitions(-DORTHANC_USE_PRECOMPILED_HEADERS=1)
set(TMP
${ORTHANC_CORE_SOURCES_INTERNAL}
${ORTHANC_DICOM_SOURCES_INTERNAL}
)
ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
"PrecompiledHeaders.h" "${ORTHANC_WSI_DIR}/Resources/Orthanc/Core/PrecompiledHeaders.cpp" ORTHANC_CORE_SOURCES)
"PrecompiledHeaders.h" "${ORTHANC_ROOT}/Core/PrecompiledHeaders.cpp"
TMP ORTHANC_CORE_PCH)
ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
"PrecompiledHeadersWSI.h" "${ORTHANC_WSI_DIR}/Framework/PrecompiledHeadersWSI.cpp" ORTHANC_WSI_SOURCES)
"PrecompiledHeadersWSI.h" "${ORTHANC_WSI_DIR}/Framework/PrecompiledHeadersWSI.cpp"
ORTHANC_WSI_SOURCES ORTHANC_WSI_PCH)
source_group(ThirdParty\\OrthancCore FILES ${ORTHANC_CORE_SOURCES})
endif()
......@@ -231,23 +151,29 @@ endif()
#####################################################################
add_library(OrthancWSIFramework STATIC
${ORTHANC_CORE_SOURCES}
${ORTHANC_CORE_PCH}
${ORTHANC_CORE_SOURCES_INTERNAL}
${ORTHANC_CORE_SOURCES_DEPENDENCIES}
${ORTHANC_DICOM_SOURCES_INTERNAL}
${ORTHANC_DICOM_SOURCES_DEPENDENCIES}
${ORTHANC_WSI_PCH}
${ORTHANC_WSI_SOURCES}
${AUTOGENERATED_SOURCES}
${BOOST_EXTENDED_SOURCES}
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomPath.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/DicomTag.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/FullOrthancDataset.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/IOrthancConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancHttpConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginConnection.cpp
${ORTHANC_ROOT}/Plugins/Samples/Common/SimplifiedOrthancDataset.cpp
# Mandatory components
${BOOST_SOURCES}
${CURL_SOURCES}
${DCMTK_SOURCES}
${JSONCPP_SOURCES}
${LIBJPEG_SOURCES}
${LIBPNG_SOURCES}
${LIBTIFF_SOURCES}
${OPENJPEG_SOURCES}
${ZLIB_SOURCES}
# Optional components
${OPENSSL_SOURCES}
)
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -25,14 +25,21 @@
#include "../Framework/Inputs/TiledPyramidStatistics.h"
#include "../Framework/Outputs/HierarchicalTiffWriter.h"
#include "../Resources/Orthanc/Core/Logging.h"
#include "../Resources/Orthanc/Core/OrthancException.h"
#include "../Resources/Orthanc/Plugins/Samples/Common/OrthancHttpConnection.h"
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <Plugins/Samples/Common/OrthancHttpConnection.h>
#include "ApplicationToolbox.h"
#include <boost/program_options.hpp>
static const char* OPTION_COLOR = "color";
static const char* OPTION_HELP = "help";
static const char* OPTION_INPUT = "input";
static const char* OPTION_JPEG_QUALITY = "jpeg-quality";
static const char* OPTION_OUTPUT = "output";
static const char* OPTION_REENCODE = "reencode";
static const char* OPTION_VERBOSE = "verbose";
static const char* OPTION_VERSION = "version";
static bool ParseParameters(int& exitStatus,
boost::program_options::variables_map& options,
......@@ -42,32 +49,34 @@ static bool ParseParameters(int& exitStatus,
// Declare the supported parameters
boost::program_options::options_description generic("Generic options");
generic.add_options()
("help", "Display this help and exit")
("version", "Output version information and exit")
("verbose", "Be verbose in logs")
(OPTION_HELP, "Display this help and exit")
(OPTION_VERSION, "Output version information and exit")
(OPTION_VERBOSE, "Be verbose in logs")
;
boost::program_options::options_description source("Options for the source DICOM image");
source.add_options()
("orthanc", boost::program_options::value<std::string>()->default_value("http://localhost:8042/"),
"URL to the REST API of the target Orthanc server")
("username", boost::program_options::value<std::string>(), "Username for the target Orthanc server")
("password", boost::program_options::value<std::string>(), "Password for the target Orthanc server")
;
OrthancWSI::ApplicationToolbox::AddRestApiOptions(source);
boost::program_options::options_description target("Options for the target TIFF image");
target.add_options()
("color", boost::program_options::value<std::string>(), "Color of the background for missing tiles (e.g. \"255,0,0\")")
("reencode", boost::program_options::value<bool>(),
(OPTION_COLOR, boost::program_options::value<std::string>(),
"Color of the background for missing tiles (e.g. \"255,0,0\")")
(OPTION_REENCODE, boost::program_options::value<bool>(),
"Whether to re-encode each tile in JPEG (no transcoding, much slower) (Boolean)")
("jpeg-quality", boost::program_options::value<int>(), "Set quality level for JPEG (0..100)")
(OPTION_JPEG_QUALITY, boost::program_options::value<int>(),
"Set quality level for JPEG (0..100)")
;
boost::program_options::options_description hidden;
hidden.add_options()
("input", boost::program_options::value<std::string>(), "Orthanc identifier of the input series of interest")
("output", boost::program_options::value<std::string>(), "Output TIFF file");
;
(OPTION_INPUT, boost::program_options::value<std::string>(),
"Orthanc identifier of the input series of interest")
(OPTION_OUTPUT, boost::program_options::value<std::string>(),
"Output TIFF file");
boost::program_options::options_description allWithoutHidden;
allWithoutHidden.add(generic).add(source).add(target);
......@@ -76,8 +85,8 @@ static bool ParseParameters(int& exitStatus,
all.add(hidden);
boost::program_options::positional_options_description positional;
positional.add("input", 1);
positional.add("output", 1);
positional.add(OPTION_INPUT, 1);
positional.add(OPTION_OUTPUT, 1);
bool error = false;
......@@ -94,23 +103,23 @@ static bool ParseParameters(int& exitStatus,
}
if (!error &&
options.count("help") == 0 &&
options.count("version") == 0)
options.count(OPTION_HELP) == 0 &&
options.count(OPTION_VERSION) == 0)
{
if (options.count("input") != 1)
if (options.count(OPTION_INPUT) != 1)
{
LOG(ERROR) << "No input series was specified";
error = true;
}
if (options.count("output") != 1)
if (options.count(OPTION_OUTPUT) != 1)
{
LOG(ERROR) << "No output file was specified";
error = true;
}
}
if (error || options.count("help"))
if (error || options.count(OPTION_HELP))
{
std::cout << std::endl
<< "Usage: " << argv[0] << " [OPTION]... [INPUT] [OUTPUT]"
......@@ -131,13 +140,13 @@ static bool ParseParameters(int& exitStatus,
return false;
}
if (options.count("version"))
if (options.count(OPTION_VERSION))
{
OrthancWSI::ApplicationToolbox::PrintVersion(argv[0]);
return false;
}
if (options.count("verbose"))
if (options.count(OPTION_VERBOSE))
{
Orthanc::Logging::EnableInfoLevel(true);
}
......@@ -159,9 +168,9 @@ static Orthanc::ImageAccessor* CreateEmptyTile(const OrthancWSI::IPyramidWriter&
uint8_t green = 255;
uint8_t blue = 255;
if (options.count("color"))
if (options.count(OPTION_COLOR))
{
OrthancWSI::ApplicationToolbox::ParseColor(red, green, blue, options["color"].as<std::string>());
OrthancWSI::ApplicationToolbox::ParseColor(red, green, blue, options[OPTION_COLOR].as<std::string>());
}
OrthancWSI::ImageToolbox::Set(*tile, red, green, blue);
......@@ -174,18 +183,18 @@ static Orthanc::ImageAccessor* CreateEmptyTile(const OrthancWSI::IPyramidWriter&
static void Run(OrthancWSI::ITiledPyramid& source,
const boost::program_options::variables_map& options)
{
OrthancWSI::HierarchicalTiffWriter target(options["output"].as<std::string>(),
OrthancWSI::HierarchicalTiffWriter target(options[OPTION_OUTPUT].as<std::string>(),
source.GetPixelFormat(),
OrthancWSI::ImageCompression_Jpeg,
source.GetTileWidth(),
source.GetTileHeight());
bool reencode = (options.count("reencode") &&
options["reencode"].as<bool>());
bool reencode = (options.count(OPTION_REENCODE) &&
options[OPTION_REENCODE].as<bool>());
if (options.count("jpeg-quality"))
if (options.count(OPTION_JPEG_QUALITY))
{
target.SetJpegQuality(options["jpeg-quality"].as<int>());
target.SetJpegQuality(options[OPTION_JPEG_QUALITY].as<int>());
}
std::auto_ptr<Orthanc::ImageAccessor> empty(CreateEmptyTile(target, options));
......@@ -199,10 +208,14 @@ static void Run(OrthancWSI::ITiledPyramid& source,
for (unsigned int level = 0; level < source.GetLevelCount(); level++)
{
LOG(WARNING) << std::string(reencode ? "Reencoding" : "Transcoding") << " level " << level;
LOG(WARNING) << std::string(reencode ? "Reencoding" : "Transcoding")
<< " level " << level;
unsigned int countX = OrthancWSI::CeilingDivision
(source.GetLevelWidth(level), source.GetTileWidth());
unsigned int countX = OrthancWSI::CeilingDivision(source.GetLevelWidth(level), source.GetTileWidth());
unsigned int countY = OrthancWSI::CeilingDivision(source.GetLevelHeight(level), source.GetTileHeight());
unsigned int countY = OrthancWSI::CeilingDivision
(source.GetLevelHeight(level), source.GetTileHeight());
for (unsigned int tileY = 0; tileY < countY; tileY++)
{
......@@ -253,7 +266,7 @@ static void Run(OrthancWSI::ITiledPyramid& source,
{
LOG(WARNING) << "Cannot transcode a DICOM image that is not encoded using JPEG (it is "
<< OrthancWSI::EnumerationToString(compression)
<< "), please use the --reencode=1 option";
<< "), please use the --" << OPTION_REENCODE << "=1 option";
throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
}
......@@ -286,23 +299,10 @@ int main(int argc, char* argv[])
{
Orthanc::WebServiceParameters params;
if (options.count("orthanc"))
{
params.SetUrl(options["orthanc"].as<std::string>());
}
if (options.count("username"))
{
params.SetUsername(options["username"].as<std::string>());
}
if (options.count("password"))
{
params.SetPassword(options["password"].as<std::string>());
}
OrthancWSI::ApplicationToolbox::SetupRestApi(params, options);
OrthancPlugins::OrthancHttpConnection orthanc(params);
OrthancWSI::DicomPyramid source(orthanc, options["input"].as<std::string>(),
OrthancWSI::DicomPyramid source(orthanc, options[OPTION_INPUT].as<std::string>(),
false /* don't use cached metadata */);
OrthancWSI::TiledPyramidStatistics stats(source);
......@@ -313,9 +313,9 @@ int main(int argc, char* argv[])
{
LOG(ERROR) << "Terminating on exception: " << e.What();
if (options.count("reencode") == 0)
if (options.count(OPTION_REENCODE) == 0)
{
LOG(ERROR) << "Consider using option \"--reencode\"";
LOG(ERROR) << "Consider using option \"--" << OPTION_REENCODE << "\"";
}
exitStatus = -1;
......
This diff is collapsed.
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -23,8 +23,8 @@
#include "PyramidReader.h"
#include "../ImageToolbox.h"
#include "../../Resources/Orthanc/Core/Logging.h"
#include "../../Resources/Orthanc/Core/OrthancException.h"
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <cassert>
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -23,9 +23,9 @@
#include "ReconstructPyramidCommand.h"
#include "../ImageToolbox.h"
#include "../../Resources/Orthanc/Core/Logging.h"
#include "../../Resources/Orthanc/Core/OrthancException.h"
#include "../../Resources/Orthanc/Core/Images/Image.h"
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <Core/Images/Image.h>
#include <cassert>
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -23,7 +23,7 @@
#include "PyramidReader.h"
#include "../Outputs/IPyramidWriter.h"
#include "../../Resources/Orthanc/Core/MultiThreading/BagOfTasks.h"
#include <Core/MultiThreading/BagOfTasks.h>
namespace OrthancWSI
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -22,8 +22,8 @@
#include "../PrecompiledHeadersWSI.h"
#include "TranscodeTileCommand.h"
#include "../../Resources/Orthanc/Core/OrthancException.h"
#include "../../Resources/Orthanc/Core/Logging.h"
#include <Core/OrthancException.h>
#include <Core/Logging.h>
#include <cassert>
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -24,7 +24,7 @@
#include "PyramidReader.h"
#include "../Outputs/IPyramidWriter.h"
#include "../../Resources/Orthanc/Core/MultiThreading/BagOfTasks.h"
#include <Core/MultiThreading/BagOfTasks.h>
namespace OrthancWSI
{
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -22,9 +22,9 @@
#include "PrecompiledHeadersWSI.h"
#include "DicomToolbox.h"
#include "../Resources/Orthanc/Core/Logging.h"
#include "../Resources/Orthanc/Core/OrthancException.h"
#include "../Resources/Orthanc/Core/Toolbox.h"
#include <Core/Logging.h>
#include <Core/OrthancException.h>
#include <Core/Toolbox.h>
#if ORTHANC_ENABLE_DCMTK == 1
# include <dcmtk/dcmdata/dcelem.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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -25,7 +25,7 @@
#include "Targets/FolderTarget.h"
#include "Targets/OrthancTarget.h"
#include "../Resources/Orthanc/Core/OrthancException.h"
#include <Core/OrthancException.h>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
......@@ -138,11 +138,6 @@ namespace OrthancWSI
void DicomizerParameters::SetDicomMaxFileSize(unsigned int size)
{
if (size <= 1024)
{
throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
}
maxDicomFileSize_ = size;
}
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -25,7 +25,7 @@
#include "Outputs/IPyramidWriter.h"
#include "Targets/IFileTarget.h"
#include "DicomToolbox.h"
#include "../Resources/Orthanc/Core/WebServiceParameters.h"
#include <Core/WebServiceParameters.h>
#include <stdint.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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -23,9 +23,9 @@
#include "Enumerations.h"
#include "Jpeg2000Reader.h"
#include "../Resources/Orthanc/Core/OrthancException.h"
#include "../Resources/Orthanc/Core/SystemToolbox.h"
#include "../Resources/Orthanc/Core/Toolbox.h"
#include <Core/OrthancException.h>
#include <Core/SystemToolbox.h>
#include <Core/Toolbox.h>
#include <string.h>
#include <boost/algorithm/string/predicate.hpp>
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -21,7 +21,7 @@
#pragma once
#include "../Resources/Orthanc/Core/Enumerations.h"
#include <Core/Enumerations.h>
#include <stdint.h>
#include <string>
......
......@@ -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 Osimis, Belgium
* Copyright (C) 2017-2018 Osimis S.A., Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
......@@ -25,13 +25,13 @@
#include "Jpeg2000Reader.h"
#include "Jpeg2000Writer.h"
#include "../Resources/Orthanc/Core/OrthancException.h"
#include "../Resources/Orthanc/Core/Images/ImageProcessing.h"
#include "../Resources/Orthanc/Core/Images/PngReader.h"
#include "../Resources/Orthanc/Core/Images/PngWriter.h"
#include "../Resources/Orthanc/Core/Images/JpegReader.h"
#include "../Resources/Orthanc/Core/Images/JpegWriter.h"
#include "../Resources/Orthanc/Core/Logging.h"
#include <Core/OrthancException.h>
#include <Core/Images/ImageProcessing.h>
#include <Core/Images/PngReader.h>
#include <Core/Images/PngWriter.h>
#include <Core/Images/JpegReader.h>
#include <Core/Images/JpegWriter.h>
#include <Core/Logging.h>
#include <string.h>
#include <memory>
......