diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61478a057aff60b437b7346ed10b2c2138c63ca9..034c32ab08cc767208cc65c9e84613f26e25489d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -168,52 +168,52 @@ macos-xdk-build: - git checkout -f -q %CI_COMMIT_SHA% # - Win10 -windows-10-prepare: - extends: .windows-prepare - tags: - - windows10 - script: - - call ./CI/dev_env.bat x64 xdk 10 - - clcache.exe -s - - ctest -C Release -V -S CI/prepare_superbuild.cmake - - clcache.exe -s +#~ windows-10-prepare: + #~ extends: .windows-prepare + #~ tags: + #~ - windows10 + #~ script: + #~ - call ./CI/dev_env.bat x64 xdk 10 + #~ - clcache.exe -s + #~ - ctest -C Release -V -S CI/prepare_superbuild.cmake + #~ - clcache.exe -s -windows-10-build: - extends: .windows-build - tags: - - windows10 - script: - - call ./CI/dev_env.bat x64 otb 10 - - clcache.exe -s - - ctest -V -S CI/main_superbuild.cmake - - clcache.exe -s - - ctest -V -S CI/main_packages.cmake - dependencies: - - windows-10-prepare +#~ windows-10-build: + #~ extends: .windows-build + #~ tags: + #~ - windows10 + #~ script: + #~ - call ./CI/dev_env.bat x64 otb 10 + #~ - clcache.exe -s + #~ - ctest -V -S CI/main_superbuild.cmake + #~ - clcache.exe -s + #~ - ctest -V -S CI/main_packages.cmake + #~ dependencies: + #~ - windows-10-prepare # - Win8.1 -windows-8-prepare: - extends: .windows-prepare - tags: - - windows8 - script: - - call ./CI/dev_env.bat x86 xdk 8.1 - - clcache.exe -s - - ctest -C Release -V -S CI/prepare_superbuild.cmake - - clcache.exe -s +#~ windows-8-prepare: + #~ extends: .windows-prepare + #~ tags: + #~ - windows8 + #~ script: + #~ - call ./CI/dev_env.bat x86 xdk 8.1 + #~ - clcache.exe -s + #~ - ctest -C Release -V -S CI/prepare_superbuild.cmake + #~ - clcache.exe -s -windows-8-build: - extends: .windows-build - tags: - - windows8 - script: - - call ./CI/dev_env.bat x86 otb 8.1 - - clcache.exe -s - - ctest -V -S CI/main_superbuild.cmake - - clcache.exe -s - - ctest -V -S CI/main_packages.cmake - dependencies: - - windows-8-prepare +#~ windows-8-build: + #~ extends: .windows-build + #~ tags: + #~ - windows8 + #~ script: + #~ - call ./CI/dev_env.bat x86 otb 8.1 + #~ - clcache.exe -s + #~ - ctest -V -S CI/main_superbuild.cmake + #~ - clcache.exe -s + #~ - ctest -V -S CI/main_packages.cmake + #~ dependencies: + #~ - windows-8-prepare #------------------------- QA related jobs ------------------------------------- ubuntu-xdk-qa-code-coverage: @@ -289,8 +289,8 @@ deploy: - ubuntu-xdk-build - centos-xdk-build - macos-xdk-build - - windows-8-build - - windows-10-build +# - windows-8-build +# - windows-10-build release-container: image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7 diff --git a/CMake/OTBCheckTargetSystemArch.cmake b/CMake/OTBCheckTargetSystemArch.cmake index a15ac1e0364b6b99f7816f3c4c3950d2defd1a52..522bdc148f83279cc52e1e630910627c3993e4ff 100644 --- a/CMake/OTBCheckTargetSystemArch.cmake +++ b/CMake/OTBCheckTargetSystemArch.cmake @@ -44,10 +44,10 @@ macro(OTB_CHECK_TARGET_SYSTEM_ARCH _RESULT1 _RESULT2) OUTPUT_VARIABLE ov OUTPUT_STRIP_TRAILING_WHITESPACE ) - + set(${_RESULT1} "${ov}") set(${_RESULT2} FALSE) - if("${ov}" STREQUAL "x86_64") + if("${ov}" MATCHES "(x86_64|amd64)") set(${_RESULT2} TRUE) endif() endif() diff --git a/CMake/OTBSetStandardCompilerFlags.cmake b/CMake/OTBSetStandardCompilerFlags.cmake index 6a7cad037a8930553b177ba94e29e87a9079cc1d..0065ead5b4df5296c1a2d5f2b803ee9573668fbe 100644 --- a/CMake/OTBSetStandardCompilerFlags.cmake +++ b/CMake/OTBSetStandardCompilerFlags.cmake @@ -190,41 +190,19 @@ macro(check_compiler_platform_flags) endif() endif() - if(WIN32) - # Some libraries (e.g. vxl libs) have no dllexport markup, so we can - # build full shared libraries only with the GNU toolchain. For non - # gnu compilers on windows, only Common is shared. This allows for - # plugin type applications to use a dll for OTBCommon which will contain - # the static for Modified time. - if(CMAKE_COMPILER_IS_GNUCXX) - # CMake adds --enable-all-exports on Cygwin (since Cygwin is - # supposed to be UNIX-like), but we need to add it explicitly for - # a native windows build with the MinGW tools. - if(MINGW) - set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS - "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") - set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS - "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") - set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-auto-import") - endif() - else() - if(MSVC) - set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} /MANIFEST:NO") - endif() - # if CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is on, then - # BUILD_SHARED_LIBS works as it would on other systems - if(NOT CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS) - if(BUILD_SHARED_LIBS) - set(OTB_LIBRARY_BUILD_TYPE "SHARED") - else() - set(OTB_LIBRARY_BUILD_TYPE "STATIC") - endif() - # turn off BUILD_SHARED_LIBS as OTB_LIBRARY_BUILD_TYPE - # is used on the libraries that have markup. - set(BUILD_SHARED_LIBS OFF) - endif() - endif() + # CMake adds --enable-all-exports on Cygwin (since Cygwin is + # supposed to be UNIX-like), but we need to add it explicitly for + # a native windows build with the MinGW tools. + if(WIN32 AND MINGW AND CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS + "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS + "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-auto-import") + elseif(MSVC) + set(OTB_REQUIRED_LINK_FLAGS "${OTB_REQUIRED_LINK_FLAGS} /MANIFEST:NO") endif() + #----------------------------------------------------------------------------- #OTB requires special compiler flags on some platforms. if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/CMakeLists.txt b/CMakeLists.txt index 256b63ce38b97cbf568db835ed361fa371d9a004..3771a7d600e721fc9e1ba5e00a3b2b6cbf32eb89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,7 +220,7 @@ option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON) set(OTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) if(MSVC) - option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Build OTB with shared libraries." ON) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF CACHE INTERNAL "" ) set(OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS}) else() set(OTB_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF) diff --git a/Data/Baseline/OTB/Images/obTuWatershedSegmentationFilterLabelImage.1.tif b/Data/Baseline/OTB/Images/obTuWatershedSegmentationFilterLabelImage.1.tif new file mode 100644 index 0000000000000000000000000000000000000000..51d4c7edcfb4f437a81b3b303ac52bcc201dff7c --- /dev/null +++ b/Data/Baseline/OTB/Images/obTuWatershedSegmentationFilterLabelImage.1.tif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49831ab756458243d99367e06884eab40737b9dd113ed09628bdc638a07705f2 +size 827613 diff --git a/Data/Input/ADS40RoiSmall.png.aux.xml b/Data/Input/ADS40RoiSmall.png.aux.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ed238186380d66d34dd11447a9b4a9c74d552eb --- /dev/null +++ b/Data/Input/ADS40RoiSmall.png.aux.xml @@ -0,0 +1,10 @@ + + + + 255 + 120.1091003418 + 23 + 48.85195761071 + + + diff --git a/Examples/BasicFilters/HillShadingExample.cxx b/Examples/BasicFilters/HillShadingExample.cxx index 053767bcadd06682e64890f2fb3c2fdf8036963f..6ad5838e076cc84b458eea3a0007f35b2934985f 100644 --- a/Examples/BasicFilters/HillShadingExample.cxx +++ b/Examples/BasicFilters/HillShadingExample.cxx @@ -30,6 +30,7 @@ #include "otbDEMToImageGenerator.h" #include "otbHillShadingFilter.h" +#include "itkBinaryFunctorImageFilter.h" #include "itkScalarToRGBColormapImageFilter.h" #include "otbReliefColormapFunctor.h" #include "itkMultiplyImageFilter.h" diff --git a/Examples/DisparityMap/StereoReconstructionExample.cxx b/Examples/DisparityMap/StereoReconstructionExample.cxx index d553c5e1071391d148addb916bd9964d5363ca31..4cd4963700d824cea574a9937ff85832264a80af 100644 --- a/Examples/DisparityMap/StereoReconstructionExample.cxx +++ b/Examples/DisparityMap/StereoReconstructionExample.cxx @@ -48,7 +48,13 @@ #include "otbImageFileWriter.h" #include "otbBCOInterpolateImageFunction.h" #include "itkUnaryFunctorImageFilter.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkVectorCastImageFilter.h" +#else +#include "otbCastImageFilter.h" +#endif + #include "otbImageList.h" #include "otbImageListToVectorImageFilter.h" #include "itkRescaleIntensityImageFilter.h" @@ -93,7 +99,11 @@ int main(int argc, char* argv[]) using DisplacementType = itk::Vector; using DisplacementFieldType = otb::Image; +#if ITK_VERSION_MAJOR < 5 using DisplacementFieldCastFilterType = itk::VectorCastImageFilter; +#else + using DisplacementFieldCastFilterType = otb::CastImageFilter; +#endif using WarpFilterType = otb::StreamingWarpImageFilter; diff --git a/Examples/IO/DEMHandlerExample.cxx b/Examples/IO/DEMHandlerExample.cxx index a133e2eff49e8bf0e3f3fe443dcafdf42027aa9d..4ce83de75a1e0f8e8061139c9593788233171e64 100644 --- a/Examples/IO/DEMHandlerExample.cxx +++ b/Examples/IO/DEMHandlerExample.cxx @@ -34,6 +34,9 @@ // library. #include "otbDEMHandler.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif int main(int argc, char* argv[]) { diff --git a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx index 66dbf8336aa4be5a8245bd9d3e4f3de64cfd692e..6bc8eace465ab2ae215f377d9a5494551d56bfc2 100644 --- a/Examples/Iterators/ImageSliceIteratorWithIndex.cxx +++ b/Examples/Iterators/ImageSliceIteratorWithIndex.cxx @@ -102,6 +102,10 @@ #include "otbImageFileReader.h" #include "otbImageFileWriter.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + int main(int argc, char* argv[]) { // Verify the number of parameters on the command line. diff --git a/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx index f72fd72c28f20681a917d23082eb26db5037be6d..6fd07e96b4f9bd2422ca6b43b6e50b71b8defd19 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx @@ -22,6 +22,10 @@ #include "itkMacro.h" #include "otbDEMHandler.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + int otbDEMHandlerTest(int argc, char * argv[]) { if(argc!=9) diff --git a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx index af1a1d0402b965650d28747d95a3cb235903be37..9f4dafcf3921204260006b000db295c5a29bcaec 100644 --- a/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx +++ b/Modules/Applications/AppClassification/app/otbMultiImageSamplingRate.cxx @@ -238,7 +238,7 @@ private: // constant case 1: { - std::vector parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.constant.nb"),' '); + auto parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.constant.nb"),' '); std::vector countList; for (unsigned int i=0 ; i parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.percent.p"),' '); + auto parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.percent.p"),' '); std::vector percentList; for (unsigned int i=0 ; i parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.total.v"),' '); + auto parts = itksys::SystemTools::SplitString(this->GetParameterString("strategy.total.v"),' '); std::vector totalList; for (unsigned int i=0 ; i words = itksys::SystemTools::SplitString(line,sep); + auto words = itksys::SystemTools::SplitString(line,sep); if (nbCols == 0) { // detect separator and feature size diff --git a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx index 3e2d3c361c11570cf22c45720e1f373247049b63..9c994f830a4462fb41d9e2fc7c6dff56d8fc4ccb 100644 --- a/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx +++ b/Modules/Applications/AppProjection/app/otbGridBasedImageResampling.cxx @@ -29,8 +29,12 @@ #include "otbConcatenateVectorImageFilter.h" #include "otbMultiToMonoChannelExtractROI.h" #include "otbImageToVectorImageCastFilter.h" -#include "itkVectorCastImageFilter.h" +#if ITK_VERSION_MAJOR < 5 +#include "itkVectorCastImageFilter.h" +#else +#include "otbCastImageFilter.h" +#endif namespace otb { @@ -56,10 +60,15 @@ public: typedef itk::Vector DisplacementType; typedef otb::Image DisplacementFieldType; +#if ITK_VERSION_MAJOR < 5 typedef itk::VectorCastImageFilter DisplacementFieldCastFilterType; - +#else + typedef otb::CastImageFilter + DisplacementFieldCastFilterType; +#endif typedef otb::StreamingWarpImageFilter DisplacementType; typedef otb::Image DisplacementFieldType; +#if ITK_VERSION_MAJOR < 5 typedef itk::VectorCastImageFilter - DisplacementFieldCastFilterType; + DisplacementFieldCastFilterType; +#else + typedef otb::CastImageFilter + DisplacementFieldCastFilterType; +#endif typedef itk::InverseDisplacementFieldImageFilter InverseDisplacementFieldFilterType; diff --git a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx index 5e6eee5bc6bdf2f5d73aaa1852edb187254a726d..98b718327c4a9ef189b958cfad3ea609a3630548 100644 --- a/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx +++ b/Modules/Applications/AppStereo/app/otbStereoRectificationGridGenerator.cxx @@ -25,7 +25,13 @@ // Elevation handler #include "otbWrapperElevationParametersHandler.h" #include "itkInverseDisplacementFieldImageFilter.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkVectorCastImageFilter.h" +#else +#include "otbCastImageFilter.h" +#endif + #include "itkVectorIndexSelectionCastImageFilter.h" #include "otbImageList.h" #include "otbImageListToVectorImageFilter.h" @@ -52,9 +58,15 @@ public: typedef itk::Vector DisplacementType; typedef otb::Image DisplacementFieldType; +#if ITK_VERSION_MAJOR < 5 typedef itk::VectorCastImageFilter DisplacementFieldCastFilterType; + DisplacementFieldType> DisplacementFieldCastFilterType; +#else + typedef otb::CastImageFilter + DisplacementFieldCastFilterType; +#endif typedef itk::InverseDisplacementFieldImageFilter InverseDisplacementFieldFilterType; diff --git a/Modules/Core/Common/include/otbCastImageFilter.h b/Modules/Core/Common/include/otbCastImageFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..4b3ad0d22912e80133f0c5422571deaf208fb783 --- /dev/null +++ b/Modules/Core/Common/include/otbCastImageFilter.h @@ -0,0 +1,115 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef otbCastImageFilter_h +#define otbCastImageFilter_h + +#if ITK_VERSION_MAJOR >= 5 +#include "itkUnaryFunctorImageFilter.h" +#include "itkProgressReporter.h" + +#include + +namespace otb +{ + +/** \class CastImageFilter + * + * \brief Casts input pixels to output pixel type. + * + * This filter is templated over the input image type + * and the output image type. + * + * A typical use is to cast a + \code + itk::Image + \endcode + * to a + \code + itk::Image + \endcode + * + * This filter can also be used to cast a + \code + itk::VectorImage + \endcode + * to a + \code + itk::VectorImage + \endcode + * + * This class is copied from the itkCastImageFilter, but it doesn't have + * a static assertion requiring the input and output pixel dimension to match, + * thus this filter can be used to convert to and from variableLengthVector. + * + * If you need to perform a dimensionaly reduction, you may want + * to use the ExtractImageFilter instead of the CastImageFilter. + * + * \ingroup OTBCommon + */ +template< typename TInputImage, typename TOutputImage > +class ITK_TEMPLATE_EXPORT CastImageFilter: + public itk::InPlaceImageFilter< TInputImage, TOutputImage > +{ +public: + ITK_DISALLOW_COPY_AND_ASSIGN(CastImageFilter); + + /** Standard class type aliases. */ + using Self = CastImageFilter; + + using Superclass = itk::InPlaceImageFilter< TInputImage, TOutputImage >; + + using Pointer = itk::SmartPointer< Self >; + using ConstPointer = itk::SmartPointer< const Self >; + + + using OutputImageRegionType = typename Superclass::OutputImageRegionType; + + using InputPixelType = typename TInputImage::PixelType; + using OutputPixelType = typename TOutputImage::PixelType; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(CastImageFilter, InPlaceImageFilter); + +protected: + CastImageFilter(); + virtual ~CastImageFilter() = default; + + void GenerateOutputInformation() override; + + void GenerateData() override; + + void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override; + + template + void DynamicThreadedGenerateDataDispatched(const OutputImageRegionType & outputRegionForThread, std::true_type isConvertible); + + template + void DynamicThreadedGenerateDataDispatched(const OutputImageRegionType & outputRegionForThread, std::false_type isConvertible); +}; +} // end namespace otb + +#endif + +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbCastImageFilter.hxx" +#endif + +#endif // ITK_VERSION_MAJOR diff --git a/Modules/Core/Common/include/otbCastImageFilter.hxx b/Modules/Core/Common/include/otbCastImageFilter.hxx new file mode 100644 index 0000000000000000000000000000000000000000..75c16faa695a89c82945cf98d1f31c14297807bd --- /dev/null +++ b/Modules/Core/Common/include/otbCastImageFilter.hxx @@ -0,0 +1,178 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef itkCastImageFilter_hxx +#define itkCastImageFilter_hxx + +#if ITK_VERSION_MAJOR >= 5 + +#include "otbCastImageFilter.h" +#include "itkProgressReporter.h" +#include "itkImageAlgorithm.h" + +namespace otb +{ + + +template< typename TInputImage, typename TOutputImage > +CastImageFilter< TInputImage, TOutputImage > +::CastImageFilter() +{ + this->SetNumberOfRequiredInputs(1); + this->InPlaceOff(); + this->DynamicMultiThreadingOn(); +} + +template< typename TInputImage, typename TOutputImage > +void +CastImageFilter< TInputImage, TOutputImage > +::GenerateData() +{ + if ( this->GetInPlace() && this->CanRunInPlace() ) + { + // nothing to do, so avoid iterating over all the pixels + // for nothing! Allocate the output, generate a fake progress and exit + this->AllocateOutputs(); + itk::ProgressReporter progress(this, 0, 1); + return; + } + //else do normal Before+Threaded+After + Superclass::GenerateData(); +} + + +template< typename TInputImage, typename TOutputImage > +void +CastImageFilter< TInputImage, TOutputImage > +::GenerateOutputInformation() + { + // do not call the superclass' implementation of this method since + // this filter allows the input the output to be of different dimensions + + // get pointers to the input and output + TOutputImage *outputPtr = this->GetOutput(); + const TInputImage *inputPtr = this->GetInput(); + + if ( !outputPtr || !inputPtr ) + { + return; + } + + // Set the output image largest possible region. Use a RegionCopier + // so that the input and output images can have different dimensions. + OutputImageRegionType outputLargestPossibleRegion; + this->CallCopyInputRegionToOutputRegion( outputLargestPossibleRegion, + inputPtr->GetLargestPossibleRegion() ); + outputPtr->SetLargestPossibleRegion(outputLargestPossibleRegion); + + itk::ImageToImageFilterDetail::ImageInformationCopier + informationCopier; + informationCopier(outputPtr, inputPtr); + + } + + +template< typename TInputImage, typename TOutputImage > +void +CastImageFilter< TInputImage, TOutputImage > +::DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) +{ + DynamicThreadedGenerateDataDispatched(outputRegionForThread, + std::is_convertible()); +} + +template< typename TInputImage, typename TOutputImage > +template +void +CastImageFilter< TInputImage, TOutputImage > +::DynamicThreadedGenerateDataDispatched(const OutputImageRegionType & outputRegionForThread, std::true_type) +{ + const TInputImage *inputPtr = this->GetInput(); + TOutputImage *outputPtr = this->GetOutput(0); + + // Define the portion of the input to walk for this thread, using + // the CallCopyOutputRegionToInputRegion method allows for the input + // and output images to be different dimensions + typename TInputImage::RegionType inputRegionForThread; + + this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread); + + itk::ImageAlgorithm::Copy( inputPtr, outputPtr, inputRegionForThread, outputRegionForThread ); +} + + +template< typename TInputImage, typename TOutputImage > +template +void +CastImageFilter< TInputImage, TOutputImage > +::DynamicThreadedGenerateDataDispatched(const OutputImageRegionType & outputRegionForThread, std::false_type) +{ + // Implementation for non-implicit convertible pixels which are + // itk-array-like. + + //static_assert( OutputPixelType::Dimension == InputPixelType::Dimension, "Vector dimensions are required to match!" ); + static_assert( std::is_convertible::value, "Component types are required to be convertible." ); + + const typename OutputImageRegionType::SizeType ®ionSize = outputRegionForThread.GetSize(); + + if( regionSize[0] == 0 ) + { + return; + } + const TInputImage *inputPtr = this->GetInput(); + TOutputImage *outputPtr = this->GetOutput(0); + + // Define the portion of the input to walk for this thread, using + // the CallCopyOutputRegionToInputRegion method allows for the input + // and output images to be different dimensions + typename TInputImage::RegionType inputRegionForThread; + + this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread); + + // Define the iterators + itk::ImageScanlineConstIterator< TInputImage > inputIt(inputPtr, inputRegionForThread); + itk::ImageScanlineIterator< TOutputImage > outputIt(outputPtr, outputRegionForThread); + + inputIt.GoToBegin(); + outputIt.GoToBegin(); + while ( !inputIt.IsAtEnd() ) + { + while ( !inputIt.IsAtEndOfLine() ) + { + const InputPixelType &inputPixel = inputIt.Get(); + OutputPixelType value; + for ( unsigned int k = 0; k < OutputPixelType::Dimension; k++ ) + { + value[k] = static_cast< typename OutputPixelType::ValueType >( inputPixel[k] ); + } + outputIt.Set( value ); + + ++inputIt; + ++outputIt; + } + inputIt.NextLine(); + outputIt.NextLine(); + } + +} + +} // end namespace otb + +#endif + +#endif // ITK_VERSION_MAJOR diff --git a/Modules/Core/Common/include/otbFunctionToImageFilter.hxx b/Modules/Core/Common/include/otbFunctionToImageFilter.hxx index 7a35c8dd2f9ff97e1b5cd67afdaa7340f6771b35..5fa0e694aa38e9ae44b46828da81e129935d95e6 100644 --- a/Modules/Core/Common/include/otbFunctionToImageFilter.hxx +++ b/Modules/Core/Common/include/otbFunctionToImageFilter.hxx @@ -22,6 +22,7 @@ #ifndef otbFunctionToImageFilter_hxx #define otbFunctionToImageFilter_hxx +#include "otbMacro.h" // for OTB_DISABLE_DYNAMIC_MT; #include "otbFunctionToImageFilter.h" #include "itkImageRegionConstIterator.h" #include "itkProgressReporter.h" @@ -36,6 +37,7 @@ template FunctionToImageFilter ::FunctionToImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->InPlaceOff(); m_PixelFunction = FunctionType::New(); } diff --git a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h index 047f6fe0927ba2eb66be9e57ad2586c059ef882f..2e8c18bdba841044c3fd03b2cb47054306808eb1 100644 --- a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h +++ b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.h @@ -26,7 +26,13 @@ #include "itkImageRegionSplitter.h" #include "itkIndex.h" #include "itkSize.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkFastMutexLock.h" +#include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -176,7 +182,11 @@ private: mutable bool m_IsUpToDate; // Lock to ensure thread-safety +#if ITK_VERSION_MAJOR < 5 itk::SimpleFastMutexLock m_Lock; +#else + std::mutex m_Lock; +#endif }; } // end namespace otb diff --git a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.hxx b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.hxx index c29956a9d1cc2e96ed699341f9a4a4afe8fc3776..da1876ecc0e67172aedd4bd7de38f2d4f913ce6f 100644 --- a/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.hxx +++ b/Modules/Core/Common/include/otbImageRegionAdaptativeSplitter.hxx @@ -41,13 +41,16 @@ ImageRegionAdaptativeSplitter this->SetRequestedNumberOfSplits(requestedNumber); // Check if we need to compute split map agagin - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif if(!m_IsUpToDate) { // Do so if we need to this->EstimateSplitMap(); } - m_Lock.Unlock(); // Return the size of the split map return m_StreamVector.size(); @@ -62,13 +65,16 @@ ImageRegionAdaptativeSplitter this->SetImageRegion(region); // Check if we need to compute split map agagin - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif if(!m_IsUpToDate) { // Do so if we need to this->EstimateSplitMap(); } - m_Lock.Unlock(); // Return the requested split return m_StreamVector.at(i); diff --git a/Modules/Core/Common/include/otbMacro.h b/Modules/Core/Common/include/otbMacro.h index f83adbe0b6937d40ff5d358f7b46b894526c0444..a63b3b5a5811a0e9c11def915d16f9443ba625ed 100644 --- a/Modules/Core/Common/include/otbMacro.h +++ b/Modules/Core/Common/include/otbMacro.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) + * Copyright (C) 2018 CS Systemes d'Information (CS SI) * * This file is part of Orfeo Toolbox * @@ -30,6 +31,7 @@ #include "itkMacro.h" #include "itkObject.h" +#include "itkThreadSupport.h" #include "otbConfigure.h" #include "otbLogger.h" @@ -42,7 +44,61 @@ namespace otb { } // end namespace otb - this is here for documentation purposes +/* ITK 5.0 uses a different threading model compared to ITK 4.x. + * This has a significant impact on OTB as we make heavy use of itk filters. + * DynamicThreadedGenerateData() is the newer variant without threadId, + * and is the preferred signature, which is called by default. This + * variant can split the requested region into different number of + * pieces depending on current multi-processing load, which allows + * better load balancing. The non-dynamic (also known as classic) + * ThreadedGenerateData() signature has threadId, and number of pieces + * to be split into is known in advance. It is activated by calling + * this->DynamicMultiThreadingOff(); in derived class constructor. + * + * OTB uses ThreadedGenerateData() with threadId and thus required + * to call this->DynamicMultiThreadingOff(); in filter's constructor. + * + * OTB_DISABLE_DYNAMIC_MT is a simple macro that insert this + * function call *IF* itk version used is 5.0 or above. + * This macro expands to empty when OTB is built with ITK 4.x and + * this ease from ITK 4.x to ITK 5.x. Ideally ThreadedGenerateData() function + * everywhere in OTB must be replace with DynamicThreadedGenerateData(). + * This for sure is not a glorified sed command. Usage of function parameter + * threadId (and progress reporter) must be removed as well. + * + * It also leads us into a situation that OTB will no longer work with ITK 4.x. + * We cannot break that until ITK 5.0 is available on all platforms and is well tested. + * As time of writing this patch ITK 5.0 is in alpha release. + * Eventually OTB can move up in direction where it is requires ITK 5.0 or. + * But until things are resolved this macro based compatibility must stay. + * + * Finally please note that OTB_DISABLE_DYNAMIC_MT does not disable multithreading. + * Method or macro name can sometimes cause confusion when reading code. + * + * sample run-time exception: + * ========================= + * 2018-06-04 15:30:09 (DEBUG): Caught itk::ExceptionObject during application execution: + * 2018-06-04 15:30:09 (DEBUG): /usr/src/ports/itk/Modules/Core/Common/src/itkPoolMultiThreader.cxx:202: + * itk::ERROR: PoolMultiThreader(0xabad1dea): Exception occurred during SingleMethodExecute + * /home/rashad/local/include/ITK-5.0/itkImageSource.hxx:276: + * itk::ERROR: ShiftScaleImageFilter(0xabad1deaff): Subclass should override this method!!! + * If old behavior is desired invoke this->DynamicMultiThreadingOff(); before Update() is called. The best place is in class constructor. + */ +#if ITK_VERSION_MAJOR < 5 +#define OTB_DISABLE_DYNAMIC_MT +#else +#define OTB_DISABLE_DYNAMIC_MT this->DynamicMultiThreadingOff(); +#endif +/* +//ITK_THREAD_RETURN_TYPE and ITK_THREAD_RETURN_VALUE bas been changed in ITK5 (master) +// we need to re-exposed to the global namespace to keep the +// use of these items consistent. +#if ITK_VERSION_MAJOR > 4 +#define ITK_THREAD_RETURN_TYPE itk::ITK_THREAD_RETURN_TYPE +#define ITK_THREAD_RETURN_VALUE itk::ITK_THREAD_RETURN_DEFAULT_VALUE +#endif +*/ #define otbFileContext(x) \ << "file " __FILE__ ", line " << __LINE__<<", " x diff --git a/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.hxx b/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.hxx index 1784ac381fdedc47cb36496508d7729f40fae3c9..acb8ccb19de3b0cbfee995a50097d25ac1198f11 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.hxx +++ b/Modules/Core/Common/include/otbUnaryFunctorNeighborhoodVectorImageFilter.hxx @@ -22,6 +22,7 @@ #define otbUnaryFunctorNeighborhoodVectorImageFilter_hxx #include "otbUnaryFunctorNeighborhoodVectorImageFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" #include "itkProgressReporter.h" @@ -36,6 +37,7 @@ template UnaryFunctorNeighborhoodVectorImageFilter ::UnaryFunctorNeighborhoodVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->InPlaceOff(); for ( unsigned int i = 0; i < InputImageDimension; ++i ) diff --git a/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.hxx b/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.hxx index aee8a122564e0d486c0623ec00a3f5952503c407..2329b37500ab668653e70289e98e907e9464894e 100644 --- a/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.hxx +++ b/Modules/Core/Common/include/otbUnaryFunctorWithIndexWithOutputSizeImageFilter.hxx @@ -24,6 +24,7 @@ #include "otbUnaryFunctorWithIndexWithOutputSizeImageFilter.h" #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" +#include "otbMacro.h" // for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -34,6 +35,7 @@ template UnaryFunctorWithIndexWithOutputSizeImageFilter ::UnaryFunctorWithIndexWithOutputSizeImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); } template diff --git a/Modules/Core/Common/src/otbConfigurationManager.cxx b/Modules/Core/Common/src/otbConfigurationManager.cxx index 63d94a1540d4934bea54fa607633587c20ceb3c2..96e9c1c149a961b8ea79b760038337bfed462c10 100644 --- a/Modules/Core/Common/src/otbConfigurationManager.cxx +++ b/Modules/Core/Common/src/otbConfigurationManager.cxx @@ -23,7 +23,12 @@ #include "otbMacro.h" #include "otbLogger.h" +#if ITK_VERSION_MAJOR < 5 #include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif + #include "itksys/SystemTools.hxx" #ifdef _OPENMP @@ -110,9 +115,13 @@ int ConfigurationManager::InitOpenMPThreads() { int ret = 1; #ifdef _OPENMP +#if ITK_VERSION_MAJOR < 5 ret = itk::MultiThreader::GetGlobalDefaultNumberOfThreads(); +#else + ret = itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(); +#endif //ITK_VERSION_MAJOR omp_set_num_threads(ret); -#endif +#endif //_OPENMP return ret; } diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx index 20685d1651d1bc4d249ab6d862acdc518fcde3e9..915d5d94ca6a62cfd57c9bda59dce5e87b6614f8 100644 --- a/Modules/Core/Common/src/otbLogger.cxx +++ b/Modules/Core/Common/src/otbLogger.cxx @@ -24,7 +24,12 @@ #include "itkStdStreamLogOutput.h" #include #include "gdal.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif #include #include @@ -93,10 +98,17 @@ void Logger::LogSetupInformation() this->Info(oss.str()); oss.str(""); oss.clear(); - + +#if ITK_VERSION_MAJOR < 5 oss<<"OTB will use at most "<< itk::MultiThreader::GetGlobalDefaultNumberOfThreads()<< " threads"<Info(oss.str()); oss.str(""); oss.clear(); diff --git a/Modules/Core/ImageBase/include/otbExtractROI.hxx b/Modules/Core/ImageBase/include/otbExtractROI.hxx index 932ebe73ae7de73687331bd0c4f40fab5f55e47a..d117d1f04089da89b6005ac6f549384675b7880c 100644 --- a/Modules/Core/ImageBase/include/otbExtractROI.hxx +++ b/Modules/Core/ImageBase/include/otbExtractROI.hxx @@ -35,6 +35,7 @@ template ExtractROI ::ExtractROI() //: ExtractROIBase< itk::Image , itk::Image >() { + OTB_DISABLE_DYNAMIC_MT; } /** diff --git a/Modules/Core/ImageBase/include/otbExtractROIBase.hxx b/Modules/Core/ImageBase/include/otbExtractROIBase.hxx index 0f4395c1e925df4b15f427666851c8348a508281..2696be8a4d9510253d3ecf6b7433977be8595839 100644 --- a/Modules/Core/ImageBase/include/otbExtractROIBase.hxx +++ b/Modules/Core/ImageBase/include/otbExtractROIBase.hxx @@ -41,6 +41,7 @@ ExtractROIBase m_SizeX(0), m_SizeY(0) { + OTB_DISABLE_DYNAMIC_MT; } /** diff --git a/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.hxx b/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.hxx index 5de4891097534ce12d7ec5e79ab807c38bacfed9..d2028c24a873406b08205848847cb0d0fa069431 100644 --- a/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.hxx +++ b/Modules/Core/ImageBase/include/otbMultiChannelExtractROI.hxx @@ -42,6 +42,7 @@ MultiChannelExtractROI m_LastChannel(0), m_ChannelsKind(0) { + OTB_DISABLE_DYNAMIC_MT; ClearChannels(); } diff --git a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.hxx b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.hxx index 21f8b5b6692efae86810a06f81eb544a2832eb9f..5bdc52ae291e3898fd621db5bcbde7c75913a302 100644 --- a/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.hxx +++ b/Modules/Core/ImageBase/include/otbMultiToMonoChannelExtractROI.hxx @@ -34,7 +34,7 @@ MultiToMonoChannelExtractROI ::MultiToMonoChannelExtractROI() : ExtractROIBase, Image >(), m_Channel(1) { - + OTB_DISABLE_DYNAMIC_MT; } /** diff --git a/Modules/Core/ImageBase/test/otbImagePCAShapeModelEstimatorTest.cxx b/Modules/Core/ImageBase/test/otbImagePCAShapeModelEstimatorTest.cxx index c1cdff6be1ce9d9a0f83b87fe759364a0eb5dd89..4ffcec0d98e33979a35350db9f0921943084ccf3 100644 --- a/Modules/Core/ImageBase/test/otbImagePCAShapeModelEstimatorTest.cxx +++ b/Modules/Core/ImageBase/test/otbImagePCAShapeModelEstimatorTest.cxx @@ -33,6 +33,10 @@ #include "itkImagePCAShapeModelEstimator.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + //Data definitions #define IMGWIDTH 2 #define IMGHEIGHT 2 diff --git a/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.hxx b/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.hxx index 906a4fe69d43f57a0915ed083d1b9bb3100bd3d1..e8e4a045ee2e898cee6fdfcfc6db1f535f889fe3 100644 --- a/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.hxx +++ b/Modules/Core/LabelMap/include/otbLabelImageToLabelMapWithAdjacencyFilter.hxx @@ -22,6 +22,7 @@ #ifndef otbLabelImageToLabelMapWithAdjacencyFilter_hxx #define otbLabelImageToLabelMapWithAdjacencyFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbLabelImageToLabelMapWithAdjacencyFilter.h" #include "itkNumericTraits.h" #include "itkProgressReporter.h" @@ -34,6 +35,7 @@ template LabelImageToLabelMapWithAdjacencyFilter ::LabelImageToLabelMapWithAdjacencyFilter() { + OTB_DISABLE_DYNAMIC_MT; m_BackgroundValue = itk::NumericTraits::NonpositiveMin(); } diff --git a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h index 5040c40f7976726e8bb6c4ea0f16bf4f60f0a88b..abc544888c582cc6ba98a8ea0e6f72e4794c3897 100644 --- a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h +++ b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.h @@ -22,6 +22,8 @@ #ifndef otbShapeAttributesLabelMapFilter_h #define otbShapeAttributesLabelMapFilter_h +#include "itkConfigure.h" + #include "otbLabelMapFeaturesFunctorImageFilter.h" #include "otbImage.h" #include "otbPolygon.h" @@ -29,12 +31,39 @@ #include "otbFlusserPathFunction.h" #include "otbSimplifyPathFunctor.h" - namespace otb { namespace Functor { +/** \class OffsetLexicographicCompare + * \brief Order Offset instances lexicographically. + * + * This is a comparison functor suitable for storing Offset instances + * in an STL container. The ordering is total and unique but has + * little geometric meaning. + * This class is copied from ITK 4.12.0 for compatability with ITK 4, 5( alpha2), ITK5 (master) + * \ingroup OTBLabelMap + */ +template< unsigned int VOffsetDimension > +class OffsetLexicographicCompare +{ +public: + bool operator()(itk::Offset< VOffsetDimension > const & l, + itk::Offset< VOffsetDimension > const & r) const + { + for ( unsigned int i = 0; i < VOffsetDimension; ++i ) { + if ( l[i] < r[i] ) { + return true; + } + else if ( l[i] > r[i] ) { + return false; + } + } + return false; + } +}; + /** \class ShapeAttributesLabelObjectFunctor * \brief Functor to compute shape attributes of one LabelObject. * @@ -71,6 +100,7 @@ public: itkStaticConstMacro(ImageDimension, unsigned int, TLabelObject::ImageDimension); typedef itk::ImageRegion< TLabelObject::ImageDimension > RegionType; typedef itk::Offset< TLabelObject::ImageDimension > OffsetType; + typedef otb::Functor::OffsetLexicographicCompare OffsetLexicographicCompare; /** Constructor */ ShapeAttributesLabelObjectFunctor(); @@ -148,9 +178,10 @@ private: typedef itk::Offset<3> Offset3Type; typedef itk::Vector Spacing2Type; typedef itk::Vector Spacing3Type; - typedef std::map MapIntercept2Type; - typedef std::map MapIntercept3Type; - + typedef otb::Functor::OffsetLexicographicCompare<2> OffsetLexicographicCompare2; + typedef otb::Functor::OffsetLexicographicCompare<3> OffsetLexicographicCompare3; + typedef std::map MapIntercept2Type; + typedef std::map MapIntercept3Type; template double PerimeterFromInterceptCount( TMapIntercept & intercepts, const TSpacing & spacing ); #if ! defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION) diff --git a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.hxx b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.hxx index 085c130b1fe4309500145476d29716adfd788f06..80e0209631bed913847056d6b76f49984dd6f2c1 100644 --- a/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.hxx +++ b/Modules/Core/LabelMap/include/otbShapeAttributesLabelMapFilter.hxx @@ -36,6 +36,10 @@ #include "otbMacro.h" #include +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { namespace Functor { @@ -735,7 +739,7 @@ ShapeAttributesLabelObjectFunctor } // a data structure to store the number of intercepts on each direction - typedef typename std::map MapInterceptType; + typedef typename std::map MapInterceptType; MapInterceptType intercepts; // int nbOfDirections = (int)std::pow( 2.0, (int)ImageDimension ) - 1; // intecepts.resize(nbOfDirections + 1); // code begins at position 1 diff --git a/Modules/Core/Metadata/include/otbNoDataHelper.h b/Modules/Core/Metadata/include/otbNoDataHelper.h index 98cfc7caf166c43f3fffdfe2205c8ca5ff24153a..29d2257a985813cd6bb1b1e649fb13c24f513c47 100644 --- a/Modules/Core/Metadata/include/otbNoDataHelper.h +++ b/Modules/Core/Metadata/include/otbNoDataHelper.h @@ -26,6 +26,10 @@ #include #include "OTBMetadataExport.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace itk { class MetaDataDictionary; diff --git a/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx index 6d4f47301a330df7b44676a988aa97beae2c3085..7d4a9a0687c2ab61268de7247751fde1979bd2fb 100644 --- a/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx @@ -39,8 +39,12 @@ #include "otbCosmoImageMetadataInterfaceFactory.h" #include "otbRadarsat2ImageMetadataInterfaceFactory.h" +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" #include "itkMutexLockHolder.h" +#else +#include +#endif #include #include @@ -100,12 +104,20 @@ ImageMetadataInterfaceFactory ::RegisterBuiltInFactories() { static bool firstTime = true; - + + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif { // This helper class makes sure the Mutex is unlocked // in the event an exception is thrown. + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(mutex); + #else + std::lock_guard mutexHolder(mutex); + #endif if (firstTime) { itk::ObjectFactoryBase::RegisterFactory(IkonosImageMetadataInterfaceFactory::New()); diff --git a/Modules/Core/Metadata/src/otbOpticalImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbOpticalImageMetadataInterfaceFactory.cxx index abda05f537648c0eec3d37fb15dc3b6a81f8e0c3..2a0a48c72ca8efe30df17030789c5fe36e13b585 100644 --- a/Modules/Core/Metadata/src/otbOpticalImageMetadataInterfaceFactory.cxx +++ b/Modules/Core/Metadata/src/otbOpticalImageMetadataInterfaceFactory.cxx @@ -32,8 +32,12 @@ #include "otbPleiadesImageMetadataInterfaceFactory.h" #include "otbSpot6ImageMetadataInterfaceFactory.h" +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" #include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -80,11 +84,19 @@ OpticalImageMetadataInterfaceFactory { static bool firstTime = true; + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif { // This helper class makes sure the Mutex is unlocked // in the event an exception is thrown. + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(mutex); + #else + std::lock_guard mutexHolder(mutex); + #endif if (firstTime) { itk::ObjectFactoryBase::RegisterFactory(IkonosImageMetadataInterfaceFactory::New()); diff --git a/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx index 8ddf2b79c71b09ecfea1ff7abbb8dd29819700c1..65540719c47c638aba06a6a341a798aaf60f1e70 100644 --- a/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx +++ b/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx @@ -29,8 +29,12 @@ #include "otbCosmoImageMetadataInterfaceFactory.h" #include "otbRadarsat2ImageMetadataInterfaceFactory.h" +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" #include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -77,11 +81,19 @@ SarImageMetadataInterfaceFactory { static bool firstTime = true; + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif { // This helper class makes sure the Mutex is unlocked // in the event an exception is thrown. + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(mutex); + #else + std::lock_guard mutexHolder(mutex); + #endif if (firstTime) { itk::ObjectFactoryBase::RegisterFactory(TerraSarImageMetadataInterfaceFactory::New()); diff --git a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h index dc3a5bb291e530a022d26c2e924d43dd16e21666..7ad69e0d8fb63f52d019c7404fea4a825c5a6723 100644 --- a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h +++ b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.h @@ -22,6 +22,13 @@ #define otbObjectListToObjectListFilter_h #include "otbObjectListSource.h" +#include "otbMacro.h" //for ITK_THREAD_RETURN_TYPE in ITK5 + +#if ITK_VERSION_MAJOR < 5 +#include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif namespace otb { @@ -101,7 +108,11 @@ protected: /** Static function used as a "callback" by the MultiThreader. The threading * library will call this routine for each thread, which will delegate the * control to ThreadedGenerateData(). */ +#if ITK_VERSION_MAJOR >= 5 + static itk::ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg); +#else static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg); +#endif /** Internal structure used for passing image data into the threading library */ struct ThreadStruct diff --git a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.hxx b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.hxx index a61230303c598eb0b9bc111703ed7d89ba185870..19d29155a969210c7446215adfe992a4271c9cca 100644 --- a/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.hxx +++ b/Modules/Core/ObjectList/include/otbObjectListToObjectListFilter.hxx @@ -146,7 +146,11 @@ ObjectListToObjectListFilter } template +#if ITK_VERSION_MAJOR >= 5 +itk::ITK_THREAD_RETURN_TYPE +#else ITK_THREAD_RETURN_TYPE +#endif ObjectListToObjectListFilter ::ThreaderCallback(void *arg) { @@ -155,9 +159,15 @@ ObjectListToObjectListFilter unsigned int total, start, stop; unsigned int requestedElements; +#if ITK_VERSION_MAJOR < 5 threadId = ((itk::MultiThreader::ThreadInfoStruct *) (arg))->ThreadID; threadCount = ((itk::MultiThreader::ThreadInfoStruct *) (arg))->NumberOfThreads; str = (ThreadStruct *) (((itk::MultiThreader::ThreadInfoStruct *) (arg))->UserData); +#else + threadId = ((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->ThreadID; + threadCount = ((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->NumberOfThreads; + str = (ThreadStruct *) (((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->UserData); +#endif requestedElements = str->Filter->GetInput()->Size(); total = str->Filter->SplitRequestedRegion(threadId, threadCount, requestedElements, start, stop); @@ -179,7 +189,11 @@ ObjectListToObjectListFilter // few threads idle. // } +#if ITK_VERSION_MAJOR >= 5 + return itk::ITK_THREAD_RETURN_DEFAULT_VALUE; +#else return ITK_THREAD_RETURN_VALUE; +#endif } /** diff --git a/Modules/Core/PointSet/include/otbImageToPointSetFilter.h b/Modules/Core/PointSet/include/otbImageToPointSetFilter.h index 9e00f51e765c646be14a5ad3dd589f393dda2917..deb213af8091a911e8514d36151dbf4cdf0bc556 100644 --- a/Modules/Core/PointSet/include/otbImageToPointSetFilter.h +++ b/Modules/Core/PointSet/include/otbImageToPointSetFilter.h @@ -104,7 +104,11 @@ protected: /** Static function used as a "callback" by the MultiThreader. The threading * library will call this routine for each thread, which will delegate the * control to ThreadedGenerateData(). */ + #if ITK_VERSION_MAJOR >= 5 + static itk::ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg); + #else static ITK_THREAD_RETURN_TYPE ThreaderCallback(void *arg); + #endif /** Internal structure used for passing image data into the threading library */ struct ThreadStruct diff --git a/Modules/Core/PointSet/include/otbImageToPointSetFilter.hxx b/Modules/Core/PointSet/include/otbImageToPointSetFilter.hxx index 2b8e32ae45afd3b82d7ec7bd69fe736f14840299..3704afe0c082999473d85dfc64b6143bfb98823b 100644 --- a/Modules/Core/PointSet/include/otbImageToPointSetFilter.hxx +++ b/Modules/Core/PointSet/include/otbImageToPointSetFilter.hxx @@ -22,7 +22,13 @@ #define otbImageToPointSetFilter_hxx #include "otbImageToPointSetFilter.h" +//#include "itkMultiThreader.h" //itk5 - itk4 compat +#if ITK_VERSION_MAJOR < 5 +#include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif namespace otb { @@ -271,7 +277,11 @@ ImageToPointSetFilter } template +#if ITK_VERSION_MAJOR >= 5 +itk::ITK_THREAD_RETURN_TYPE +#else ITK_THREAD_RETURN_TYPE +#endif ImageToPointSetFilter ::ThreaderCallback(void *arg) { @@ -279,9 +289,15 @@ ImageToPointSetFilter unsigned int total, threadCount; itk::ThreadIdType threadId; +#if ITK_VERSION_MAJOR < 5 threadId = ((itk::MultiThreader::ThreadInfoStruct *) (arg))->ThreadID; threadCount = ((itk::MultiThreader::ThreadInfoStruct *) (arg))->NumberOfThreads; str = (ThreadStruct *) (((itk::MultiThreader::ThreadInfoStruct *) (arg))->UserData); +#else + threadId = ((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->ThreadID; + threadCount = ((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->NumberOfThreads; + str = (ThreadStruct *) (((itk::MultiThreaderBase::ThreadInfoStruct *) (arg))->UserData); +#endif // execute the actual method with appropriate output region // first find out how many pieces extent can be split into. @@ -300,7 +316,11 @@ ImageToPointSetFilter // few threads idle. // } +#if ITK_VERSION_MAJOR >= 5 + return itk::ITK_THREAD_RETURN_DEFAULT_VALUE; +#else return ITK_THREAD_RETURN_VALUE; +#endif } template diff --git a/Modules/Core/PointSet/include/otbPointSetFunction.h b/Modules/Core/PointSet/include/otbPointSetFunction.h index 818a3ce98163bcb965660788206e304a0d12a068..cf892398f59787b4ef5d56cfc0cf94f07854d547 100644 --- a/Modules/Core/PointSet/include/otbPointSetFunction.h +++ b/Modules/Core/PointSet/include/otbPointSetFunction.h @@ -49,22 +49,22 @@ public: itkTypeMacro(PointSetFunction, itk::SpatialFunction); /** PointSet Type typedef Support*/ - typedef TPointSet PointSetType; - typedef typename PointSetType::ConstPointer PointSetPointerType; - - /** TOutput typedef suppoty*/ + typedef TPointSet PointSetType; + typedef typename PointSetType::Pointer PointSetPointer; + typedef typename PointSetType::ConstPointer PointSetConstPointer; + /** TOutput typedef support*/ typedef TOutput OutputType; /** Set the input image (reimplemented since we need to set the detector input) */ itkGetConstObjectMacro(PointSet, PointSetType); - void SetPointSet(PointSetType * PointSet) + void SetPointSet(PointSetPointer PointSet) { m_PointSet = PointSet; } /** SetPointSet() to maintain the const correctness of the pointset*/ - void SetPointSet(PointSetPointerType PointSet) + void SetPointSet(PointSetConstPointer PointSet) { m_PointSet = PointSet; } @@ -79,7 +79,7 @@ private: PointSetFunction(const Self &) = delete; void operator =(const Self&) = delete; - PointSetPointerType m_PointSet; + PointSetConstPointer m_PointSet; }; diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h index c26c96044720c3843813d1dce06c158c2c3ceaf8..90f76e742a1bb44e303c6a9ddab381942ce71bd7 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.h @@ -24,7 +24,13 @@ #include "itkMacro.h" #include "itkImageToImageFilter.h" #include "otbStreamingManager.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkFastMutexLock.h" +#include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -194,7 +200,11 @@ private: unsigned long m_ObserverID; /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ - itk::SimpleFastMutexLock m_Lock; +#if ITK_VERSION_MAJOR < 5 + mutable itk::SimpleFastMutexLock m_Lock; +#else + mutable std::mutex m_Lock; +#endif }; } // end namespace otb diff --git a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.hxx b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.hxx index cdcee4f18e9891a68b3b060d6c4a275b85b3482e..8850082892f6120080421f2ed2649cecb81729a8 100644 --- a/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.hxx +++ b/Modules/Core/Streaming/include/otbStreamingImageVirtualWriter.hxx @@ -300,9 +300,12 @@ const bool & StreamingImageVirtualWriter ::GetAbortGenerateData() const { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif bool ret = Superclass::GetAbortGenerateData(); - m_Lock.Unlock(); if (ret) return otb::Utils::TrueConstant; return otb::Utils::FalseConstant; } @@ -312,9 +315,12 @@ void StreamingImageVirtualWriter ::SetAbortGenerateData(bool val) { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif Superclass::SetAbortGenerateData(val); - m_Lock.Unlock(); } } // end namespace otb diff --git a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.hxx b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.hxx index fd5f6c99fb5b4fc9e343caf741d9eff772adcc92..fa3b445d9a0a593d3f2d33cfb499e94b71338cbe 100644 --- a/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.hxx +++ b/Modules/Feature/Density/include/otbPointSetToDensityImageFilter.hxx @@ -24,7 +24,7 @@ #include "otbPointSetToDensityImageFilter.h" #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { /**--------------------------------------------------------- @@ -34,6 +34,7 @@ template PointSetToDensityImageFilter ::PointSetToDensityImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius = 1; } diff --git a/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h b/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h index 92bd29716175e0f25dfaf0bb3ca891f52b281e64..1c7e5f14d991b6046a4578822ed9f2fb90cc8545 100644 --- a/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbHorizontalSobelVectorImageFilter.h @@ -88,6 +88,7 @@ public: protected: HorizontalSobelVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } diff --git a/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.hxx b/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.hxx index 8e325a93c988653e07d737f11d628e4b6ad24db6..d453eba8b60c0f6c6fb0bb870306ab34d15bc359 100644 --- a/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.hxx +++ b/Modules/Feature/Edge/include/otbLineCorrelationDetectorImageFilter.hxx @@ -41,6 +41,7 @@ template ::LineCorrelationDetectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->m_Radius.Fill(1); this->m_LengthLine = 1; this->m_WidthLine = 0; diff --git a/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.hxx b/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.hxx index fa70430f64426718877a38b69cd97dc8c8fb6bde..0c99cd954a9807c5669c84c31bab89d7bf13b9d3 100644 --- a/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.hxx +++ b/Modules/Feature/Edge/include/otbLineRatioDetectorImageFilter.hxx @@ -42,6 +42,7 @@ template ::LineRatioDetectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->m_Radius.Fill(1); this->m_LengthLine = 1; this->m_WidthLine = 0; diff --git a/Modules/Feature/Edge/include/otbLineSegmentDetector.hxx b/Modules/Feature/Edge/include/otbLineSegmentDetector.hxx index 5ddfa10103d7a8cf50e98b7430cdf27b4c29347d..a29d25e238c4f6fc4d6abfbcde26041b3ce89b51 100644 --- a/Modules/Feature/Edge/include/otbLineSegmentDetector.hxx +++ b/Modules/Feature/Edge/include/otbLineSegmentDetector.hxx @@ -37,6 +37,10 @@ #include "itkMatrix.h" #include "itkSymmetricEigenAnalysis.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + extern "C" double dlngam_(double *x); extern "C" double dbetai_(double *x, double *a, double *b); diff --git a/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.hxx b/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.hxx index a91f9a4b0f57a20482c4899de81e5353fbd3a27e..725010a535af77808f26ca36f7ff6d9b0913fdf3 100644 --- a/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.hxx +++ b/Modules/Feature/Edge/include/otbPersistentVectorizationImageFilter.hxx @@ -58,14 +58,22 @@ PersistentVectorizationImageFilter { // Compute the min max and handle mini-pipeline m_MinMaxFilter->SetInput(this->GetInput()); +#if ITK_VERSION_MAJOR < 5 m_MinMaxFilter->GraftOutput(this->GetOutput()); m_MinMaxFilter->Update(); this->GraftOutput(m_MinMaxFilter->GetOutput()); +#else // MinMaxFilter does not produce an output in ITK5 + m_MinMaxFilter->Update(); +#endif for (PixelType label = m_MinMaxFilter->GetMinimum() + 1; label <= m_MinMaxFilter->GetMaximum(); ++label) { ImageToEdgePathFilterPointerType edgeFilter = ImageToEdgePathFilterType::New(); +#if ITK_VERSION_MAJOR < 5 edgeFilter->SetInput(m_MinMaxFilter->GetOutput()); +#else // MinMaxFilter does not produce an output in ITK5 + edgeFilter->SetInput(this->GetInput()); +#endif edgeFilter->SetForegroundValue(label); edgeFilter->Update(); m_PathList->PushBack(edgeFilter->GetOutput()); diff --git a/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.hxx b/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.hxx index e468505fec46d3d332ffd01184c5346817db22ba..b519c9083d7b7efc9b2830498fe86191330009c4 100644 --- a/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.hxx +++ b/Modules/Feature/Edge/include/otbPixelSuppressionByDirectionImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbPixelSuppressionByDirectionImageFilter_hxx #define otbPixelSuppressionByDirectionImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbPixelSuppressionByDirectionImageFilter.h" #include "itkDataObject.h" @@ -42,7 +43,7 @@ namespace otb template PixelSuppressionByDirectionImageFilter::PixelSuppressionByDirectionImageFilter() { - +OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); m_AngularBeam = static_cast(0.); diff --git a/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h b/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h index 94a31c6fb7a4fb658077d5f2febc80a36013d712..d44347366fd780cb916e2d41136df0aa5203555d 100644 --- a/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h +++ b/Modules/Feature/Edge/include/otbSobelVectorImageFilter.h @@ -97,6 +97,7 @@ public: protected: SobelVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; typename Superclass::RadiusType radius = {{1, 1}}; this->SetRadius( radius ); } diff --git a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.hxx b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.hxx index 77f930626b1f7cf0155c741448340213c7dddc63..4bbf74f0714b51eb3080b3beb5211cfaf57b17c4 100644 --- a/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.hxx +++ b/Modules/Feature/Edge/include/otbTouziEdgeDetectorImageFilter.hxx @@ -41,6 +41,7 @@ namespace otb template TouziEdgeDetectorImageFilter::TouziEdgeDetectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); } diff --git a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.hxx b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.hxx index 64027caab9eb281236da1a9c64a431da1c2856df..46cc283e9f363ae9069e7fb90fbd45e0e39c3df5 100644 --- a/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.hxx +++ b/Modules/Feature/Moments/include/otbRadiometricMomentsImageFilter.hxx @@ -37,6 +37,7 @@ template RadiometricMomentsImageFilter ::RadiometricMomentsImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); m_Radius.Fill(1); } diff --git a/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.hxx b/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.hxx index 91270169145685ff3658f67e58a57853f1474234..04e4101ffe3db645a9f949461e0e807e4e53cdba 100644 --- a/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.hxx +++ b/Modules/Feature/Textures/include/otbSFSTexturesImageFilter.hxx @@ -27,7 +27,7 @@ #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" #include "otbMath.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -35,6 +35,7 @@ template SFSTexturesImageFilter ::SFSTexturesImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(6); diff --git a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.hxx b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.hxx index 52d68d939babbc230859ccfef1786dafc14b9694..51753ef89568f066b16494042e6955f6a60a2b59 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.hxx +++ b/Modules/Feature/Textures/include/otbScalarImageToAdvancedTexturesFilter.hxx @@ -28,7 +28,7 @@ #include "itkProgressReporter.h" #include "itkNumericTraits.h" #include - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { template @@ -43,6 +43,7 @@ ScalarImageToAdvancedTexturesFilter , m_SubsampleFactor() , m_SubsampleOffset() { + OTB_DISABLE_DYNAMIC_MT; // There are 10 outputs corresponding to the 9 textures indices this->SetNumberOfRequiredOutputs(10); diff --git a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.hxx b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.hxx index 9c842f44b3c6e781acecfe559a64adcc12b4a2b9..abd11d8bc15272ea2912c3ac2f9f15de2e3edc91 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.hxx +++ b/Modules/Feature/Textures/include/otbScalarImageToHigherOrderTexturesFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbScalarImageToHigherOrderTexturesFilter_hxx #define otbScalarImageToHigherOrderTexturesFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbScalarImageToHigherOrderTexturesFilter.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkImageRegionIterator.h" @@ -40,9 +41,10 @@ ScalarImageToHigherOrderTexturesFilter m_SubsampleOffset() { // There are 10 outputs corresponding to the 8 textures indices + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredOutputs(10); - // Create the 11 outputs + // Create the 10 outputs this->SetNthOutput(0, OutputImageType::New()); this->SetNthOutput(1, OutputImageType::New()); this->SetNthOutput(2, OutputImageType::New()); diff --git a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx index ce6aba7c14ade35db426d287401e9601ae0e62ef..6c7d692cc28d02c6d6b14bf51ade39fc6af67d2d 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx +++ b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx @@ -27,6 +27,7 @@ #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" #include "itkNumericTraits.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -37,6 +38,7 @@ ScalarImageToPanTexTextureFilter m_InputImageMinimum(0), m_InputImageMaximum(255) { + OTB_DISABLE_DYNAMIC_MT; // There are 1 output corresponding to the Pan Tex texture indice this->SetNumberOfRequiredOutputs(1); diff --git a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.hxx b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.hxx index 3ff20537907398eeea656b0563204ed3a657ab8d..c6439e892bd8cc3426ee84bcd768d02a49d9adcc 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.hxx +++ b/Modules/Feature/Textures/include/otbScalarImageToTexturesFilter.hxx @@ -30,6 +30,7 @@ #include "itkNumericTraits.h" #include #include +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -45,6 +46,7 @@ ScalarImageToTexturesFilter , m_SubsampleFactor() , m_SubsampleOffset() { + OTB_DISABLE_DYNAMIC_MT; // There are 8 outputs corresponding to the 8 textures indices this->SetNumberOfRequiredOutputs(8); diff --git a/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h b/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h index 8faf7c6bd786277f85264fd3720698398a94ed99..24582dee91d7cf2f9b0d80256bc5fa1dbf62a38b 100644 --- a/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h +++ b/Modules/Filtering/ChangeDetection/include/otbCBAMIChangeDetector.h @@ -83,7 +83,7 @@ public: itkTypeMacro(CBAMIChangeDetector, SuperClass); protected: - CBAMIChangeDetector() {} + CBAMIChangeDetector() {OTB_DISABLE_DYNAMIC_MT;} ~CBAMIChangeDetector() override {} private: diff --git a/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h b/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h index e39ba7a48215595cde566879a27cb65622bb20fc..eb98b0532f1837bfdad8ff6af0d73ca50707c215 100644 --- a/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h +++ b/Modules/Filtering/ChangeDetection/include/otbCorrelationChangeDetector.h @@ -82,7 +82,7 @@ public: itkTypeMacro(CorrelationChangeDetector, SuperClass); protected: - CorrelationChangeDetector() {} + CorrelationChangeDetector() {OTB_DISABLE_DYNAMIC_MT;} ~CorrelationChangeDetector() override {} private: diff --git a/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h index 3b60293e6d75d83fcdc45d4e5564e194298c3abb..b507b8cb913f99b6172a027e914746455f9aad72 100644 --- a/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbJoinHistogramMIImageFilter.h @@ -23,6 +23,7 @@ #include "otbBinaryFunctorNeighborhoodJoinHistogramImageFilter.h" #include "otbJoinHistogramMI.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -83,7 +84,10 @@ public: itkTypeMacro(JoinHistogramMIImageFilter, SuperClass); protected: - JoinHistogramMIImageFilter() {} + JoinHistogramMIImageFilter() + { + OTB_DISABLE_DYNAMIC_MT; + } ~JoinHistogramMIImageFilter() override {} private: diff --git a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.hxx b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.hxx index df648c556126dfcefb7fa6a4de781ed36564d7fa..7590da8353dd6fb848a7f6b601d6e7208f7a56c4 100644 --- a/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.hxx +++ b/Modules/Filtering/ChangeDetection/include/otbKullbackLeiblerProfileImageFilter.hxx @@ -27,6 +27,10 @@ #include "otbKullbackLeiblerProfileImageFilter.h" #include "otbMath.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { diff --git a/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h b/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h index 5bc8d44f4e2b591be883c1130c45ffa6959175e2..b99a6d5ea41cdad4f6ec4a3aeb7043bf3f1f7b37 100644 --- a/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h +++ b/Modules/Filtering/ChangeDetection/include/otbMeanDifferenceImageFilter.h @@ -81,7 +81,7 @@ public: itkTypeMacro(MeanDifferenceImageFilter, SuperClass); protected: - MeanDifferenceImageFilter() {} + MeanDifferenceImageFilter() {OTB_DISABLE_DYNAMIC_MT;} ~MeanDifferenceImageFilter() override {} private: diff --git a/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.hxx b/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.hxx index 73fe6bde5d5525aca9815814dc44113b5550f331..9d5ec1b9ff8e39e4468aa64d5db1b28964e6ed59 100644 --- a/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.hxx +++ b/Modules/Filtering/ChangeDetection/include/otbMultivariateAlterationDetectorImageFilter.hxx @@ -36,6 +36,7 @@ template MultivariateAlterationDetectorImageFilter ::MultivariateAlterationDetectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); m_CovarianceEstimator = CovarianceEstimatorType::New(); } diff --git a/Modules/Filtering/Contrast/include/otbApplyGainFilter.hxx b/Modules/Filtering/Contrast/include/otbApplyGainFilter.hxx index 4912bfa2057d230bd8cd710a49b90510ef30ff95..e39cd6984519a521837d61fc514ba1af099947cf 100644 --- a/Modules/Filtering/Contrast/include/otbApplyGainFilter.hxx +++ b/Modules/Filtering/Contrast/include/otbApplyGainFilter.hxx @@ -25,6 +25,7 @@ #include "itkImageRegionIterator.h" #include "itkImageRegionConstIteratorWithIndex.h" #include "itkContinuousIndex.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include @@ -34,6 +35,7 @@ template ApplyGainFilter < TInputImage , TLut , TOutputImage > ::ApplyGainFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); m_Min = std::numeric_limits< InputPixelType >::quiet_NaN(); m_Max = std::numeric_limits< InputPixelType >::quiet_NaN(); diff --git a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.hxx b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.hxx index 356df1b960ede8692a97f43c77df6ac9f99b968c..fd0f1ebd672cd69ef31a1ef3b78d240d76929b2e 100644 --- a/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.hxx +++ b/Modules/Filtering/Contrast/include/otbCLHistogramEqualizationFilter.hxx @@ -37,6 +37,7 @@ m_ApplyGainFilter ( ApplyGainFilter::New() ) , m_StreamingImageFilter ( StreamingImageFilter::New() ) , m_BufferFilter ( BufferFilter::New() ) { + OTB_DISABLE_DYNAMIC_MT; m_Min = std::numeric_limits< InputPixelType >::quiet_NaN(); m_Max = std::numeric_limits< InputPixelType >::quiet_NaN(); m_NbBin = 256; diff --git a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.hxx b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.hxx index 3dbe3798779e70d1b553b5586a7e34f6e3c80f1d..76c1cb7ab1c26d6ed3b1ab481f0db01baa9f28d8 100644 --- a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.hxx +++ b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.hxx @@ -23,7 +23,7 @@ #include "otbComputeGainLutFilter.h" #include "itkImageRegionIterator.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include #include @@ -34,6 +34,7 @@ template < class TInputImage, class TOutputImage > ComputeGainLutFilter < TInputImage , TOutputImage > ::ComputeGainLutFilter() { + OTB_DISABLE_DYNAMIC_MT; m_NbBin = 256; m_NbPixel = 0; m_Min = std::numeric_limits< double >::quiet_NaN(); diff --git a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.hxx b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.hxx index a5ad85c009f99621a80c499f7c22805d2b0135ad..ed48ea1002a9ed1a4660010e081556442f96224e 100644 --- a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.hxx +++ b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.hxx @@ -22,9 +22,9 @@ #define otbComputeHistoFilter_hxx #include "otbComputeHistoFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include - namespace otb { @@ -32,6 +32,7 @@ template ComputeHistoFilter < TInputImage , TOutputImage > ::ComputeHistoFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredOutputs(2); this->SetNthOutput( 0, this->MakeOutput(0) ); this->SetNthOutput( 1, this->MakeOutput(1) ); diff --git a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.hxx b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.hxx index 302b1a054335fc8d40f20455bd3587e16f6ac669..1be48ea140e650ab2afdca022a3fc36093da8d67 100644 --- a/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.hxx +++ b/Modules/Filtering/Convolution/include/otbConvolutionImageFilter.hxx @@ -38,6 +38,7 @@ template ::ConvolutionImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); m_Filter.SetSize(3 * 3); m_Filter.Fill(1); diff --git a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.hxx b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.hxx index 867632e82b1a04e213cfd4597fdc3b17f8dc65da..e6271cf38e8c02d6f9b75aeaa74cee1272715a22 100644 --- a/Modules/Filtering/DEM/include/otbDEMToImageGenerator.hxx +++ b/Modules/Filtering/DEM/include/otbDEMToImageGenerator.hxx @@ -25,6 +25,10 @@ #include "otbMacro.h" #include "itkProgressReporter.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { @@ -32,6 +36,7 @@ template DEMToImageGenerator ::DEMToImageGenerator() { + OTB_DISABLE_DYNAMIC_MT; m_DEMHandler = DEMHandlerType::Instance(); m_OutputSpacing[0] = 0.0001; m_OutputSpacing[1] = -0.0001; diff --git a/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.hxx b/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.hxx index 7f9d5d39f51012af6e1f83b6261571cb9a467ea1..e98b32b9a1a00e968fdb353cf3f54fedc4ebd878 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.hxx +++ b/Modules/Filtering/DimensionalityReduction/include/otbEstimateInnerProductPCAImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbEstimateInnerProductPCAImageFilter_hxx #define otbEstimateInnerProductPCAImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbEstimateInnerProductPCAImageFilter.h" #include diff --git a/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h b/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h index 2ba6e47035f7db5ce2a26028aa8dc18390b0dae1..76684fa322095fab8dfc2b8b9a282f77e6d668ad 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h +++ b/Modules/Filtering/DimensionalityReduction/include/otbLocalActivityVectorImageFilter.h @@ -108,7 +108,7 @@ public: itkTypeMacro(LocalActivityVectorImageFilter, ImageToImageFilter); protected: - LocalActivityVectorImageFilter() { } + LocalActivityVectorImageFilter() { OTB_DISABLE_DYNAMIC_MT; } ~LocalActivityVectorImageFilter() override { } private: diff --git a/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.hxx b/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.hxx index 2cc202cdbd5338c36b589bec0f74d998669f6fdb..306df488419b98c7dc785d77ae30b3fa4a35d500 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.hxx +++ b/Modules/Filtering/DimensionalityReduction/include/otbMaximumAutocorrelationFactorImageFilter.hxx @@ -39,6 +39,7 @@ template MaximumAutocorrelationFactorImageFilter ::MaximumAutocorrelationFactorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_CovarianceEstimator = CovarianceEstimatorType::New(); m_CovarianceEstimatorH = CovarianceEstimatorType::New(); m_CovarianceEstimatorV = CovarianceEstimatorType::New(); diff --git a/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.hxx b/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.hxx index 699f09e3f1f00a38ff04b36bf8c16ff3959780ef..c90e1452bfc870ad3ada0a0ffa4a1cd3f5d350c1 100644 --- a/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.hxx +++ b/Modules/Filtering/DimensionalityReduction/include/otbNormalizeInnerProductPCAImageFilter.hxx @@ -36,6 +36,7 @@ template NormalizeInnerProductPCAImageFilter ::NormalizeInnerProductPCAImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); this->InPlaceOff(); diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.hxx index b6e7fc40442e4e35ac9d4c34aa2faf9cc4508b4e..f97c9af451ab69cc8e4639cf4c172a3f71bce598 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodImageFilter.hxx @@ -25,7 +25,7 @@ #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" #include "itkProgressReporter.h" - +#include "otbMacro.h" namespace otb { @@ -37,6 +37,7 @@ template ::BinaryFunctorNeighborhoodImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); m_Radius.Fill(3); } diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.hxx index ac4d49dc4ffa94a9706a6f24ace5874bf1cf00a5..c3aab5f5144c27190fd956c1f19549ce6bf69f43 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryFunctorNeighborhoodVectorImageFilter.hxx @@ -21,6 +21,8 @@ #ifndef otbBinaryFunctorNeighborhoodVectorImageFilter_hxx #define otbBinaryFunctorNeighborhoodVectorImageFilter_hxx +#include "otbMath.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbBinaryFunctorNeighborhoodVectorImageFilter.h" #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" @@ -37,6 +39,7 @@ template ::BinaryFunctorNeighborhoodVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); this->InPlaceOff(); m_Radius = 3; diff --git a/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.hxx index c6cc7a66253b40af09a9dd667b202b89b84cc4b1..5b119e3ec84176b5ef20de8c4bef55012a2a137e 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbBinaryImageToDensityImageFilter.hxx @@ -36,6 +36,7 @@ template BinaryImageToDensityImageFilter ::BinaryImageToDensityImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_NeighborhoodRadius.Fill(1); m_CountFunction = CountFunctionType::New(); } diff --git a/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.hxx index 9b5da23ba1f5d8f1877f0f8a3f4e748adc55add6..7c3935de3b1d47b69e08adde4ff373295b11e8f2 100644 --- a/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbBoxAndWhiskerImageFilter.hxx @@ -24,7 +24,7 @@ #include #include - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkConstNeighborhoodIterator.h" #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" @@ -39,6 +39,7 @@ template BoxAndWhiskerImageFilter ::BoxAndWhiskerImageFilter () { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); this->InPlaceOn(); diff --git a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.hxx index b3d8f1ca317216c52c6f656a1087527741012a62..7834378f064373a87c08a8f0d03e26bdb61baaf8 100644 --- a/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbClampImageFilter.hxx @@ -23,6 +23,7 @@ #define otbClampImageFilter_hxx #include "otbClampImageFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIterator.h" #include "itkNumericTraits.h" #include @@ -39,6 +40,7 @@ template ClampImageFilter ::ClampImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Lower = std::numeric_limits < OutputPixelValueType >::lowest(); m_Upper = std::numeric_limits < OutputPixelValueType >::max(); } diff --git a/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.hxx index 073ba588d1fb0c135b859402241627b92cce6507..52f95dd1eb5012b0311bc92be1354dd340afe13c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbConcatenateVectorImageFilter.hxx @@ -22,6 +22,7 @@ #define otbConcatenateVectorImageFilter_hxx #include "otbConcatenateVectorImageFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" @@ -35,6 +36,7 @@ ConcatenateVectorImageFilter ::ConcatenateVectorImageFilter() { this->SetNumberOfRequiredInputs(2); + OTB_DISABLE_DYNAMIC_MT; } /** * Destructor. diff --git a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.hxx b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.hxx index 37cfd2dc5fa6e5ce180eec0f3c525e6c29248744..d101f5b7c5b91395afe0fc3807fd503a8f5275d1 100644 --- a/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbEuclideanDistanceMetricWithMissingValuePow2.hxx @@ -26,6 +26,10 @@ #include "otbEuclideanDistanceMetricWithMissingValuePow2.h" #include "itkMeasurementVectorTraits.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { namespace Statistics { diff --git a/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.hxx index 9fc4bd2113d794b23e6c77ae1c754bf45c8544e3..c04aed753ca11094b2f47869833be74829e78dd9 100644 --- a/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbFunctionWithNeighborhoodToImageFilter.hxx @@ -35,6 +35,7 @@ template FunctionWithNeighborhoodToImageFilter ::FunctionWithNeighborhoodToImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->InPlaceOff(); this->SetNumberOfRequiredInputs(1); m_Radius.Fill(1); diff --git a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.hxx index a954d9854c037de296f241447effe8331f72fa67..c4069692daa3948074bbabb91c392dd3c8be8d24 100644 --- a/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbGridResampleImageFilter.hxx @@ -47,6 +47,7 @@ GridResampleImageFilter m_Interpolator(), m_ReachableOutputRegion() { + OTB_DISABLE_DYNAMIC_MT; // Set linear interpolator as default m_Interpolator = dynamic_cast(DefaultInterpolatorType::New().GetPointer()); diff --git a/Modules/Filtering/ImageManipulation/include/otbInPlacePassFilter.h b/Modules/Filtering/ImageManipulation/include/otbInPlacePassFilter.h index 153a728bb33b0fb90b0f61a13e5e5e4b4dc831b0..1f01a7286d0c24be7e7dfa83474693c3d122f159 100644 --- a/Modules/Filtering/ImageManipulation/include/otbInPlacePassFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbInPlacePassFilter.h @@ -63,6 +63,7 @@ public: protected: InPlacePassFilter() { + OTB_DISABLE_DYNAMIC_MT; this->InPlaceOn(); } diff --git a/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.hxx index ff54cc6607e10a858a3be33d5c74bd4663dd677e..13b03f292f6fd1b7f6623e53aaed16d9e994b02d 100644 --- a/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbMatrixImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbMatrixImageFilter_hxx #define otbMatrixImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbMatrixImageFilter.h" #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" @@ -34,6 +35,7 @@ namespace otb template MatrixImageFilter::MatrixImageFilter() : m_MatrixByVector(false) { + OTB_DISABLE_DYNAMIC_MT; } template diff --git a/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.hxx b/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.hxx index cff87ef48c6bea8a12e7a4abb78c2e76d5f0002d..ca596c08a58cb4a939b81a80618018b2ca2fd39c 100644 --- a/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbNRIBandImagesToOneNComplexBandsImage.hxx @@ -21,6 +21,7 @@ #ifndef otbNRIBandImagesToOneNComplexBandsImage_hxx #define otbNRIBandImagesToOneNComplexBandsImage_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbNRIBandImagesToOneNComplexBandsImage.h" #include "itkImageRegionIterator.h" @@ -28,9 +29,6 @@ #include "itkProgressReporter.h" #include "itkVariableLengthVector.h" - - - namespace otb { @@ -41,6 +39,7 @@ template NRIBandImagesToOneNComplexBandsImage::NRIBandImagesToOneNComplexBandsImage() { //this->SetNumberOfThreads(1); + OTB_DISABLE_DYNAMIC_MT; } /** diff --git a/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h index 30f85bb57096b6abf40d6aec4fca60ac83adf669..95772783b2b073acc7209d5c05b0680421d573b0 100644 --- a/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbPrintableImageFilter.h @@ -119,7 +119,7 @@ protected: **/ template > -class ITK_EXPORT PrintableImageFilter : +class PrintableImageFilter : public itk::ImageToImageFilter > { public: diff --git a/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.hxx index fa99a2aea0b768ba791be57bd738f7116945fc17..10269baa5fd86710cd12f1fb42388ef40307c625 100644 --- a/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbSpectralAngleDistanceImageFilter.hxx @@ -36,6 +36,7 @@ template SpectralAngleDistanceImageFilter ::SpectralAngleDistanceImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_ReferencePixel = 0; } diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.hxx index a6950f65096b65d1ce005f49abed7415d78dee2b..eceb8a9e580c3d7fce59e43c2c4c546864393cf6 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingInnerProductVectorImageFilter.hxx @@ -36,6 +36,7 @@ template PersistentInnerProductVectorImageFilter ::PersistentInnerProductVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; // first output is a copy of the image, DataObject created by // superclass // diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.hxx index f6719ab12e8ae6e41d5e374c0d45aa9c2b93f7f2..3012201250c6cac291053b9584dfc8f1b27b1985 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingMatrixTransposeMatrixImageFilter.hxx @@ -35,6 +35,7 @@ template PersistentMatrixTransposeMatrixImageFilter ::PersistentMatrixTransposeMatrixImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); // first output is a copy of the image, DataObject created by diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h index 01710c3a0b44adc8499d5e323525b83c69097787..76189ac4179f83ab35615d8580d5a2946aa4e35f 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.h @@ -21,17 +21,16 @@ #ifndef otbStreamingShrinkImageFilter_h #define otbStreamingShrinkImageFilter_h - #include "otbPersistentImageFilter.h" #include "otbPersistentFilterStreamingDecorator.h" - +#include "OTBImageManipulationExport.h" #include "otbStreamingManager.h" #include "otbMacro.h" namespace otb { -class ITK_EXPORT StreamingShrinkImageRegionSplitter : public itk::ImageRegionSplitter<2> +class OTBImageManipulation_EXPORT StreamingShrinkImageRegionSplitter : public itk::ImageRegionSplitter<2> { public: /** Standard class typedefs. */ diff --git a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.hxx index 0da76af598d870d2697e632d769af261ca31fe6a..af2ca4ee73786e0dc25103e72c603938d9088631 100644 --- a/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbStreamingShrinkImageFilter.hxx @@ -64,6 +64,7 @@ PersistentShrinkImageFilter ::PersistentShrinkImageFilter() : m_ShrinkFactor(10) { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredOutputs(1); } diff --git a/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.hxx index 88146169b03b189da140cd6772aa263973c22802..c444821a8e4a0329a74f8caba58960f0901f2785 100644 --- a/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbThresholdVectorImageFilter.hxx @@ -22,6 +22,7 @@ #ifndef otbThresholdVectorImageFilter_hxx #define otbThresholdVectorImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbThresholdVectorImageFilter.h" #include "itkImageRegionIterator.h" #include "itkNumericTraits.h" @@ -38,6 +39,7 @@ template ThresholdVectorImageFilter ::ThresholdVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_OutsideValue = itk::NumericTraits::Zero; m_Lower = itk::NumericTraits::NonpositiveMin(); m_Upper = itk::NumericTraits::max(); diff --git a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.hxx index 6257269507d214f300af75dae45bf53ebefd887e..834d50ee2b52f7fdfece1d3abbc43fd1f4f44a66 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbTileImageFilter.hxx @@ -23,13 +23,16 @@ #include "otbTileImageFilter.h" #include "itkImageRegionIterator.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { template TileImageFilter ::TileImageFilter() -{} +{ + OTB_DISABLE_DYNAMIC_MT; +} template TileImageFilter diff --git a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.hxx b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.hxx index ce4281b448e0b2f027eb971a626319f9ff3d715d..fbe290f0b4ce67f399bb94514814b66edc80b332 100644 --- a/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbTwoNRIBandsImageToNComplexBandsImage.hxx @@ -21,6 +21,7 @@ #ifndef otbTwoNRIBandsImageToNComplexBandsImage_hxx #define otbTwoNRIBandsImageToNComplexBandsImage_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbTwoNRIBandsImageToNComplexBandsImage.h" #include "itkImageRegionIterator.h" @@ -40,6 +41,7 @@ namespace otb template TwoNRIBandsImageToNComplexBandsImage::TwoNRIBandsImageToNComplexBandsImage() { + OTB_DISABLE_DYNAMIC_MT; //this->SetNumberOfThreads(1); } diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.hxx index 273a267e7e9d673eb20b9d18e64a8f264c886628..fd7246c43b0ebc571cc5cfde900a3ffec1771868 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodImageFilter.hxx @@ -27,7 +27,7 @@ #include "itkProgressReporter.h" #include "itkZeroFluxNeumannBoundaryCondition.h" #include "itkNeighborhoodAlgorithm.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { /** @@ -37,6 +37,7 @@ template UnaryFunctorNeighborhoodImageFilter ::UnaryFunctorNeighborhoodImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); m_Radius.Fill(1); } diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.hxx index 20ae4caf80ce36e47f1b9e1ef8b287310b789aa0..69040bf10e893bf93599645f7d9edffef119b367 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorNeighborhoodWithOffsetImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbUnaryFunctorNeighborhoodWithOffsetImageFilter_hxx #define otbUnaryFunctorNeighborhoodWithOffsetImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbUnaryFunctorNeighborhoodWithOffsetImageFilter.h" #include "itkImageRegionIterator.h" #include "itkNeighborhoodAlgorithm.h" @@ -37,6 +38,7 @@ template UnaryFunctorNeighborhoodWithOffsetImageFilter ::UnaryFunctorNeighborhoodWithOffsetImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); m_Radius.Fill(1); m_Offset.Fill(1); diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.hxx index c125b284f6ae7174fd64070f165ddb632465960d..9fc82fbd3752af4ff6273ba6e0e2ccbb96f5d2c4 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryFunctorWithIndexImageFilter.hxx @@ -24,6 +24,7 @@ #include "otbUnaryFunctorWithIndexImageFilter.h" #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -34,6 +35,7 @@ template UnaryFunctorWithIndexImageFilter ::UnaryFunctorWithIndexImageFilter() { +OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); } template diff --git a/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.hxx index f38dbb9f745aeaf23a55c61f62bf776ae69ca6fe..b7b87986fdc5d8bbe6f95972bd56fe8cdb00dd30 100644 --- a/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbUnaryImageFunctorWithVectorImageFilter.hxx @@ -22,6 +22,7 @@ #define otbUnaryImageFunctorWithVectorImageFilter_hxx #include "otbUnaryImageFunctorWithVectorImageFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" @@ -35,6 +36,7 @@ template UnaryImageFunctorWithVectorImageFilter ::UnaryImageFunctorWithVectorImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->InPlaceOff(); } diff --git a/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.hxx b/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.hxx index 3481e47f130adc46b8b2c30fff6b893c56056c38..1eebac82586d6a9a8c666c8416c9713ec3c7b2ce 100644 --- a/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.hxx +++ b/Modules/Filtering/ImageManipulation/include/otbVectorImageTo3DScalarImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbVectorImageTo3DScalarImageFilter_hxx #define otbVectorImageTo3DScalarImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbVectorImageTo3DScalarImageFilter.h" #include "itkImageRegionConstIterator.h" #include "itkImageSliceIteratorWithIndex.h" @@ -33,7 +34,9 @@ namespace otb template VectorImageTo3DScalarImageFilter ::VectorImageTo3DScalarImageFilter() -{} +{ + OTB_DISABLE_DYNAMIC_MT; +} /** Generate output information */ template void diff --git a/Modules/Filtering/ImageManipulation/otb-module.cmake b/Modules/Filtering/ImageManipulation/otb-module.cmake index 8d908064ec2b99150f2f24dff3ed21691076b348..577800116de253b72023445b2be5241a4356682e 100644 --- a/Modules/Filtering/ImageManipulation/otb-module.cmake +++ b/Modules/Filtering/ImageManipulation/otb-module.cmake @@ -26,6 +26,7 @@ band, evaluating a ImageFunction onto a source image, generating an image from D data.") otb_module(OTBImageManipulation +ENABLE_SHARED DEPENDS OTBBoostAdapters OTBCommon diff --git a/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.hxx b/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.hxx index f372ad59f92ffd2a8f1139560c2e53b2a7e34dbd..97f73331bf867746bd20346007885e400f417507 100644 --- a/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.hxx +++ b/Modules/Filtering/ImageNoise/include/otbFrostImageFilter.hxx @@ -30,7 +30,7 @@ #include "itkNeighborhoodAlgorithm.h" #include "itkOffset.h" #include "itkProgressReporter.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -40,6 +40,7 @@ namespace otb template FrostImageFilter::FrostImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); m_Deramp = 2; } diff --git a/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.hxx b/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.hxx index 2d4b0d663ecababaf6eba2a46bf9f0440a356b43..6dca5adb37dfd982ed49b24570ac62fefcd52d89 100644 --- a/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.hxx +++ b/Modules/Filtering/ImageNoise/include/otbGammaMAPImageFilter.hxx @@ -30,7 +30,7 @@ #include "itkNeighborhoodAlgorithm.h" #include "itkOffset.h" #include "itkProgressReporter.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -40,6 +40,7 @@ namespace otb template GammaMAPImageFilter::GammaMAPImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); SetNbLooks(1.0); } diff --git a/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.hxx b/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.hxx index 68eaf1006210d9120ca45cb3eeadf86b8bbf76c9..522d9d1395fdc0971490f934aadd51d2e08fb0d9 100644 --- a/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.hxx +++ b/Modules/Filtering/ImageNoise/include/otbKuanImageFilter.hxx @@ -30,7 +30,7 @@ #include "itkNeighborhoodAlgorithm.h" #include "itkOffset.h" #include "itkProgressReporter.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -40,6 +40,7 @@ namespace otb template KuanImageFilter::KuanImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); SetNbLooks(1.0); } diff --git a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.hxx b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.hxx index 1c4fbadf5e6fda0202f4f6748b8ab1dec7cafa8c..86f2526c2767a65a2e1c05d869ed89e3edd1bdfb 100644 --- a/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.hxx +++ b/Modules/Filtering/ImageNoise/include/otbLeeImageFilter.hxx @@ -23,6 +23,7 @@ #include "otbLeeImageFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkDataObject.h" #include "itkConstNeighborhoodIterator.h" #include "itkNeighborhoodInnerProduct.h" @@ -40,6 +41,7 @@ namespace otb template LeeImageFilter::LeeImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); SetNbLooks(1.0); } diff --git a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.hxx b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.hxx index 8ac27050327da7d5287ae93287df6d47eb9b774d..3d9ed9a79f8528a2cb5324b9d82faa8465a286f3 100644 --- a/Modules/Filtering/MathParser/include/otbBandMathImageFilter.hxx +++ b/Modules/Filtering/MathParser/include/otbBandMathImageFilter.hxx @@ -42,6 +42,7 @@ BandMathImageFilter { //This number will be incremented each time an image //is added over the one minimumrequired + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs( 1 ); this->InPlaceOff(); diff --git a/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.hxx b/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.hxx index 5c0e60b3a32606bed9d4c4a792b80f81e21a58e8..ca0047fef3ea210de916596d778606e37dcb379a 100644 --- a/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.hxx +++ b/Modules/Filtering/MathParser/include/otbMaskMuParserFilter.hxx @@ -35,6 +35,7 @@ namespace otb template MaskMuParserFilter::MaskMuParserFilter() { + OTB_DISABLE_DYNAMIC_MT; m_UnderflowCount = 0; m_OverflowCount = 0; m_ThreadUnderflow.SetSize(1); diff --git a/Modules/Filtering/MathParser/include/otbParser.h b/Modules/Filtering/MathParser/include/otbParser.h index 96038c266c8cd5386728620ffa03f12ab607a70a..aa03751f9d2149dc814deedb4b9ed6d8e19b396f 100644 --- a/Modules/Filtering/MathParser/include/otbParser.h +++ b/Modules/Filtering/MathParser/include/otbParser.h @@ -25,6 +25,7 @@ #include "itkObjectFactory.h" #include "otb_muparser.h" +#include "OTBMathParserExport.h" namespace otb { @@ -41,7 +42,7 @@ class ParserImpl; * * \ingroup OTBMathParser */ -class ITK_EXPORT Parser : public itk::LightObject +class OTBMathParser_EXPORT Parser : public itk::LightObject { public: /** Standard class typedefs. */ diff --git a/Modules/Filtering/MathParser/otb-module.cmake b/Modules/Filtering/MathParser/otb-module.cmake index bc4f899c0e62a043cbe795fba2efc6f3278ff0b6..b1acb5cc315843ae9a9b626e24f3eb2106e995e5 100644 --- a/Modules/Filtering/MathParser/otb-module.cmake +++ b/Modules/Filtering/MathParser/otb-module.cmake @@ -23,6 +23,7 @@ expression to the pixels of an image. Note that classes based on MuParserX have better capabilities than the ones based on MuParser.") otb_module(OTBMathParser +ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx b/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx index 26c714c100eb76f3ca66ede72befd489d2b9b2c7..2719b6f56218b0bcabcdea38a843d11c6cd89bd0 100644 --- a/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx +++ b/Modules/Filtering/MathParser/test/otbBandMathImageFilter.cxx @@ -29,6 +29,9 @@ #include "otbBandMathImageFilter.h" #include "otbImageFileWriter.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif int otbBandMathImageFilter( int itkNotUsed(argc), char* itkNotUsed(argv) []) { diff --git a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx index 6092926c7d22d861d0a88a811de26f9f537d016c..081544d013a9a9234cd479f951d2cd7333727269 100644 --- a/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx +++ b/Modules/Filtering/MathParserX/include/otbBandMathXImageFilter.hxx @@ -48,7 +48,7 @@ BandMathXImageFilter //This number will be incremented each time an image //is added over the one minimumrequired this->SetNumberOfRequiredInputs( 1 ); - + OTB_DISABLE_DYNAMIC_MT; m_UnderflowCount = 0; m_OverflowCount = 0; m_ThreadUnderflow.SetSize(1); diff --git a/Modules/Filtering/MathParserX/include/otbParserX.h b/Modules/Filtering/MathParserX/include/otbParserX.h index 8530f76b8ccf394a72d49d5e8bbd7376655c076c..d47730be472c9b05293941fe7d2cb1ae8849968c 100644 --- a/Modules/Filtering/MathParserX/include/otbParserX.h +++ b/Modules/Filtering/MathParserX/include/otbParserX.h @@ -40,6 +40,7 @@ #else #include "mpParser.h" #endif +#include "OTBMathParserXExport.h" namespace otb { @@ -56,7 +57,7 @@ class ParserXImpl; * * \ingroup OTBMathParserX */ -class ITK_EXPORT ParserX : public itk::LightObject +class OTBMathParserX_EXPORT ParserX : public itk::LightObject { public: /** Standard class typedefs. */ diff --git a/Modules/Filtering/MathParserX/otb-module.cmake b/Modules/Filtering/MathParserX/otb-module.cmake index 4a601e111e0b5cc09410525869b86b80563c3d08..a49a2862643c468f3bfddfd2400a1f0366766d96 100644 --- a/Modules/Filtering/MathParserX/otb-module.cmake +++ b/Modules/Filtering/MathParserX/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "TODO") otb_module(OTBMathParserX +ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx b/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx index 161c812d97868ba85373ebcad5636ccbb2ca8f64..1be3767f89baf610ed1c084cb530ea0102076fd5 100644 --- a/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx +++ b/Modules/Filtering/MathParserX/test/otbBandMathXImageFilter.cxx @@ -31,7 +31,9 @@ #include "itkImageRegionIteratorWithIndex.h" - +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif int otbBandMathXImageFilter( int itkNotUsed(argc), char* itkNotUsed(argv) []) { diff --git a/Modules/Filtering/Path/include/otbCompacityPathFunction.hxx b/Modules/Filtering/Path/include/otbCompacityPathFunction.hxx index 3360698d5ba7a523cca4adc4b6c38cc040a709e2..7994ca8a053dadfff3ad1eb5787bf5e665bcb72d 100644 --- a/Modules/Filtering/Path/include/otbCompacityPathFunction.hxx +++ b/Modules/Filtering/Path/include/otbCompacityPathFunction.hxx @@ -45,7 +45,6 @@ CompacityPathFunction { VertexListPointer vertexList; VertexType cindex; - VertexType IndexOut; int nbPath; RealType Surface = 0.0; RealType Perimeter = 0.0; diff --git a/Modules/Filtering/Path/include/otbOrientationPathFunction.hxx b/Modules/Filtering/Path/include/otbOrientationPathFunction.hxx index cb604d60ef9150f03e2af85b8a2ca8e1205a666a..ff4eac938c5bdc3f8ea2f798fad7f9b8e0c65432 100644 --- a/Modules/Filtering/Path/include/otbOrientationPathFunction.hxx +++ b/Modules/Filtering/Path/include/otbOrientationPathFunction.hxx @@ -46,7 +46,6 @@ OrientationPathFunction { VertexListPointer vertexList; VertexType cindex; - VertexType IndexOut; int nbPath; RealType Theta; diff --git a/Modules/Filtering/Path/test/otbImageToEdgePathFilter.cxx b/Modules/Filtering/Path/test/otbImageToEdgePathFilter.cxx index 688bd0fca736b92ca78a9acc4f90c4d90550df8b..d49188156f3a41d611406920f52dcef1ba550e86 100644 --- a/Modules/Filtering/Path/test/otbImageToEdgePathFilter.cxx +++ b/Modules/Filtering/Path/test/otbImageToEdgePathFilter.cxx @@ -59,12 +59,10 @@ int otbImageToEdgePathFilter(int itkNotUsed(argc), char * argv[]) PathType * outputPath = pathFilter->GetOutput(); - typedef PathType::VertexType VertexType; typedef PathType::VertexListType VertexListType; typedef VertexListType::ConstPointer VertexListTypePointer; VertexListTypePointer vertexList; - VertexType cindex; VertexListTypePointer ptrVertexList = outputPath->GetVertexList(); diff --git a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.hxx b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.hxx index d3e1d6e60a9685044e04bbd321b059cf4f79901c..e5d3eacbc4fd867a389488edc96499ce321edf37 100644 --- a/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.hxx +++ b/Modules/Filtering/Polarimetry/include/otbMultiChannelsPolarimetricSynthesisFilter.hxx @@ -27,6 +27,7 @@ #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" #include "otbMath.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -46,6 +47,7 @@ MultiChannelsPolarimetricSynthesisFilter m_EmissionH(false), m_EmissionV(false) { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->InPlaceOff(); m_ArchitectureType = PolarimetricData::New(); diff --git a/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h b/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h index 549375d5cd25d48f5cea3f436cc92d3e0266b84e..d93b00964a20bef245185c8001240a98155d6560 100644 --- a/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h +++ b/Modules/Filtering/Polarimetry/include/otbPolarimetricData.h @@ -23,6 +23,7 @@ #include "itkDataObject.h" #include "itkObjectFactory.h" +#include "OTBPolarimetryExport.h" namespace otb { @@ -51,7 +52,7 @@ typedef enum * \ingroup OTBPolarimetry */ -class ITK_EXPORT PolarimetricData : public itk::DataObject +class OTBPolarimetry_EXPORT PolarimetricData : public itk::DataObject { public: diff --git a/Modules/Filtering/Polarimetry/otb-module.cmake b/Modules/Filtering/Polarimetry/otb-module.cmake index 036edbb60f9253a61e11a60a63a1b2ba50ff835b..6d67952659c5cb187a67dfc4383c115888f14903 100644 --- a/Modules/Filtering/Polarimetry/otb-module.cmake +++ b/Modules/Filtering/Polarimetry/otb-module.cmake @@ -26,6 +26,7 @@ representations of a polarisation state, to perform polarimetry synthesis, and s on.") otb_module(OTBPolarimetry +ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.hxx b/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.hxx index 22ffe1ad8d2acc41b601c7d5f5736deab2f797d9..2de1e47fe4c56f7135edd05a9c6d45903fb48a75 100644 --- a/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.hxx +++ b/Modules/Filtering/Projection/include/otbGCPsToRPCSensorModelImageFilter.hxx @@ -248,7 +248,6 @@ GCPsToRPCSensorModelImageFilter rsTransform->SetInputKeywordList(m_Keywordlist); rsTransform->InstantiateTransform(); - ContinuousIndexType idFix, idOut; Continuous3DIndexType idOut3D, idTrans3D; Point2DType sensorPoint; @@ -274,10 +273,6 @@ GCPsToRPCSensorModelImageFilter groundPointTemp = rsTransform->TransformPoint(sensorPointTemp); - // Compute Euclidian distance - idFix[0] = sensorPoint[0]; - idFix[1] = sensorPoint[1]; - idOut3D[0] = groundPoint[0]; idOut3D[1] = groundPoint[1]; idOut3D[2] = groundPoint[2]; diff --git a/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.hxx b/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.hxx index 67704d57afab90778056ffff297446a67d428da2..972e90fcf97387f87c9e71da7d1fc6ebf2c75c1e 100644 --- a/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.hxx +++ b/Modules/Filtering/Projection/include/otbVectorDataTransformFilter.hxx @@ -26,6 +26,10 @@ #include #include "otbStopwatch.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { diff --git a/Modules/Filtering/Projection/test/otbGCPsToRPCSensorModelImageFilterCheckRpcModel.cxx b/Modules/Filtering/Projection/test/otbGCPsToRPCSensorModelImageFilterCheckRpcModel.cxx index a7f96117e0790366160dace88340ecdc6e7fb131..3dc4058c842d1b6c51e4343e960e581c60e0b654 100644 --- a/Modules/Filtering/Projection/test/otbGCPsToRPCSensorModelImageFilterCheckRpcModel.cxx +++ b/Modules/Filtering/Projection/test/otbGCPsToRPCSensorModelImageFilterCheckRpcModel.cxx @@ -26,6 +26,10 @@ #include "otbMacro.h" #include +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + int otbGCPsToRPCSensorModelImageFilterCheckRpcModel(int argc, char * argv[]) { // Look for tolerance value diff --git a/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.hxx b/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.hxx index 8a64b7c86048b21e50c3bd6b5bf9e3c6b47c23b6..5d9c3d405cfb1ea15b7d750a4eaf6be1f2c94350 100644 --- a/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.hxx +++ b/Modules/Filtering/Smoothing/include/otbMeanShiftSmoothingImageFilter.hxx @@ -47,6 +47,7 @@ MeanShiftSmoothingImageFilterSetNumberOfRequiredOutputs(4); this->SetNthOutput(0, OutputImageType::New()); this->SetNthOutput(1, OutputSpatialImageType::New()); diff --git a/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.hxx b/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.hxx index 188d892c8945c1212303f5761c21b1b5865353fa..f3ec171f4688244b0ecf82cf0a02474cb26a57d2 100644 --- a/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbNormalizeVectorImageFilter.hxx @@ -29,6 +29,7 @@ template < class TInputImage, class TOutputImage > NormalizeVectorImageFilter< TInputImage, TOutputImage > ::NormalizeVectorImageFilter () { + OTB_DISABLE_DYNAMIC_MT; m_IsGivenMean = false; m_IsGivenStdDev = false; diff --git a/Modules/Filtering/Statistics/include/otbPatternSampler.h b/Modules/Filtering/Statistics/include/otbPatternSampler.h index 45daa2f5094203ebf80d155a6481e743442cf5cf..ab847cee5923153809c9bceca89a589870c17f61 100644 --- a/Modules/Filtering/Statistics/include/otbPatternSampler.h +++ b/Modules/Filtering/Statistics/include/otbPatternSampler.h @@ -22,6 +22,7 @@ #define otbPatternSampler_h #include "otbSamplerBase.h" +#include "OTBStatisticsExport.h" #include namespace otb @@ -36,7 +37,7 @@ namespace otb * * \ingroup OTBStatistics */ -class ITK_EXPORT PatternSampler : public SamplerBase +class OTBStatistics_EXPORT PatternSampler : public SamplerBase { public: typedef PatternSampler Self; diff --git a/Modules/Filtering/Statistics/include/otbPeriodicSampler.h b/Modules/Filtering/Statistics/include/otbPeriodicSampler.h index f70a019f2f5f52e1df30ea996e2b55728f1b9e71..79a2e6b2cd5b9efa0b88919a4a075cd5873f0e5a 100644 --- a/Modules/Filtering/Statistics/include/otbPeriodicSampler.h +++ b/Modules/Filtering/Statistics/include/otbPeriodicSampler.h @@ -22,6 +22,7 @@ #define otbPeriodicSampler_h #include "otbSamplerBase.h" +#include "OTBStatisticsExport.h" namespace otb { @@ -35,7 +36,7 @@ namespace otb * * \ingroup OTBStatistics */ -class ITK_EXPORT PeriodicSampler : public SamplerBase +class OTBStatistics_EXPORT PeriodicSampler : public SamplerBase { public: typedef PeriodicSampler Self; diff --git a/Modules/Filtering/Statistics/include/otbRandomSampler.h b/Modules/Filtering/Statistics/include/otbRandomSampler.h index 6d0a8411a31d6ff831c0768b87c2928fdfa7a626..1355b80f423378ea8bf049afa444415f48fcc004 100644 --- a/Modules/Filtering/Statistics/include/otbRandomSampler.h +++ b/Modules/Filtering/Statistics/include/otbRandomSampler.h @@ -22,6 +22,7 @@ #define otbRandomSampler_h #include "otbSamplerBase.h" +#include "OTBStatisticsExport.h" namespace otb { @@ -36,7 +37,7 @@ namespace otb * * \ingroup OTBStatistics */ -class ITK_EXPORT RandomSampler : public SamplerBase +class OTBStatistics_EXPORT RandomSampler : public SamplerBase { public: typedef RandomSampler Self; diff --git a/Modules/Filtering/Statistics/include/otbSamplerBase.h b/Modules/Filtering/Statistics/include/otbSamplerBase.h index 1dc0f328da30d576a78c1c439e5cc0c1bf88af00..2bdd0fa6e5b6a45670bfff91bd60c46abe587610 100644 --- a/Modules/Filtering/Statistics/include/otbSamplerBase.h +++ b/Modules/Filtering/Statistics/include/otbSamplerBase.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "itkObjectFactory.h" +#include "OTBStatisticsExport.h" namespace otb { @@ -34,7 +35,7 @@ namespace otb * * \ingroup OTBStatistics */ -class ITK_EXPORT SamplerBase : public itk::Object +class OTBStatistics_EXPORT SamplerBase : public itk::Object { public: typedef SamplerBase Self; diff --git a/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.hxx index fc9d29ac02c5e86b6328e1f05ee6525b641d9372..5d123624cf408006293f4086aa95255a86aaffa7 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingCompareImageFilter.hxx @@ -35,6 +35,7 @@ PersistentCompareImageFilter ::PersistentCompareImageFilter() : m_SquareOfDifferences(1), m_AbsoluteValueOfDifferences(1), m_ThreadMinRef(1), m_ThreadMaxRef(1), m_Count(1), m_DiffCount(1), m_PhysicalSpaceCheck(true) { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs( 2 ); // first output is a copy of the image, DataObject created by // superclass diff --git a/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.hxx index 7faf8fe79552fd323fc194e80b314254e76e1d73..f3aead936a76661c3126b4c04d0813c698c143bd 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingHistogramVectorImageFilter.hxx @@ -47,9 +47,8 @@ PersistentHistogramVectorImageFilter // // allocate the data objects for the outputs which are // just decorators around pixel types and histogram list - + OTB_DISABLE_DYNAMIC_MT; m_Size.Fill(255); - HistogramListPointerType output = static_cast(this->MakeOutput(1).GetPointer()); this->itk::ProcessObject::SetNthOutput(1, output.GetPointer()); } diff --git a/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.hxx index a3f5fde6741caff765f03d6ce173ed69519a5cad..0e4c8e5fead75421c2acb71a361b9719db9b58ed 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingMinMaxImageFilter.hxx @@ -35,6 +35,7 @@ template PersistentMinMaxImageFilter ::PersistentMinMaxImageFilter() { + OTB_DISABLE_DYNAMIC_MT; // TODO : SetNumberOfRequiredOutputs // first output is a copy of the image, DataObject created by diff --git a/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.hxx index 311b01e316aecc6f704606e96547d381ad8299bb..81a9d90b4f396a150308a69685aa0c6a09d09889 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingMinMaxVectorImageFilter.hxx @@ -38,6 +38,7 @@ PersistentMinMaxVectorImageFilter : m_NoDataFlag(false), m_NoDataValue(itk::NumericTraits::Zero) { + OTB_DISABLE_DYNAMIC_MT; // first output is a copy of the image, DataObject created by // superclass // diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.hxx index 1ea91025fc08cf0924e5c23e0c15dc080e6b7f88..fad7a7dd58c3d83a8ff726befc6ce7e0b4960cda 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsImageFilter.hxx @@ -27,6 +27,10 @@ #include "itkProgressReporter.h" #include "otbMacro.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { @@ -40,7 +44,8 @@ PersistentStatisticsImageFilter m_ThreadMax(1), m_IgnoreInfiniteValues(true), m_IgnoreUserDefinedValue(false) - { +{ + OTB_DISABLE_DYNAMIC_MT; // first output is a copy of the image, DataObject created by // superclass // diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.hxx index 7a0ecf30e80eaedea6c10e81622acb62b6f78ea7..592c17c66f50d8fd0960b17c84294052be0f3cc8 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsMapFromLabelImageFilter.hxx @@ -42,6 +42,7 @@ PersistentStreamingStatisticsMapFromLabelImageFilter(this->MakeOutput(1).GetPointer()); this->itk::ProcessObject::SetNthOutput(1, output.GetPointer()); diff --git a/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.hxx b/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.hxx index cf1d13ff7502f4860176619e9334b45659b70037..144ef641d6e4c13fa23c5fa1f758ba849ff58d52 100644 --- a/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbStreamingStatisticsVectorImageFilter.hxx @@ -27,6 +27,10 @@ #include "itkProgressReporter.h" #include "otbMacro.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { @@ -41,6 +45,7 @@ PersistentStreamingStatisticsVectorImageFilter m_IgnoreUserDefinedValue(false), m_UserIgnoredValue(itk::NumericTraits::Zero) { + OTB_DISABLE_DYNAMIC_MT; // first output is a copy of the image, DataObject created by // superclass diff --git a/Modules/Filtering/Statistics/include/otbVarianceImageFilter.hxx b/Modules/Filtering/Statistics/include/otbVarianceImageFilter.hxx index 4a36287a0b878b608c5a125581dc330e61119a37..2ea6eaeb0080b28b54be7a597e7167cbd785b675 100644 --- a/Modules/Filtering/Statistics/include/otbVarianceImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbVarianceImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbVarianceImageFilter_hxx #define otbVarianceImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbVarianceImageFilter.h" #include "itkConstNeighborhoodIterator.h" @@ -37,6 +38,7 @@ template VarianceImageFilter ::VarianceImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Radius.Fill(1); } diff --git a/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.hxx b/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.hxx index 9b411cdfeebf9f40ca215837c5dc2ca205f69f8f..7a28b2335637864d109094438037d934a61c12b7 100644 --- a/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbVectorImageToIntensityImageFilter.hxx @@ -36,7 +36,7 @@ template VectorImageToIntensityImageFilter ::VectorImageToIntensityImageFilter() { - + OTB_DISABLE_DYNAMIC_MT; } template diff --git a/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.hxx b/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.hxx index c92ea88fe76846b9807ee62647f2fc9ad3d1e237..34a781d83d6ba18e4afc09f28d0e3b396ca50e3f 100644 --- a/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.hxx +++ b/Modules/Filtering/Statistics/include/otbVectorImageToMatrixImageFilter.hxx @@ -35,6 +35,7 @@ template PersistentVectorImageToMatrixFilter ::PersistentVectorImageToMatrixFilter() { + OTB_DISABLE_DYNAMIC_MT; // first output is a copy of the image, DataObject created by // superclass // diff --git a/Modules/Filtering/Statistics/otb-module.cmake b/Modules/Filtering/Statistics/otb-module.cmake index 855eb0b37dfcba94ccdc0ecf071849612d7c16af..934b57c10bc936c370ea3622003aa0b3c660f84d 100644 --- a/Modules/Filtering/Statistics/otb-module.cmake +++ b/Modules/Filtering/Statistics/otb-module.cmake @@ -26,6 +26,7 @@ of the input sample list, and so on. The other part works on images and labelMap and allows the calculation of classical statistics (min max mean histogram).") otb_module(OTBStatistics +ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Filtering/VectorDataManipulation/include/otbPolygonCompacityFunctor.h b/Modules/Filtering/VectorDataManipulation/include/otbPolygonCompacityFunctor.h index 8bf3100e00364007507c2f7384d555a20a8fd792..ad4355f049fcbcfde609bf0f05f2d6a4567d302d 100644 --- a/Modules/Filtering/VectorDataManipulation/include/otbPolygonCompacityFunctor.h +++ b/Modules/Filtering/VectorDataManipulation/include/otbPolygonCompacityFunctor.h @@ -23,6 +23,10 @@ #include "otbMath.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { diff --git a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h index 6fe5288153396f8db77d8d053c17470b590c1a3c..e0da51af594bb4a48eaf807ae71c9efb5e87cded 100644 --- a/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h +++ b/Modules/Filtering/Wavelet/include/otbSubsampleImageFilter.h @@ -25,6 +25,7 @@ #include "itkImageToImageFilter.h" #include "itkImage.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; //Just to get the forward/inverse definitions #include "otbWaveletOperatorBase.h" @@ -103,6 +104,7 @@ public: protected: SubsampleImageFilter () { + OTB_DISABLE_DYNAMIC_MT; m_SubsampleFactor.Fill(1); } ~SubsampleImageFilter() override {} diff --git a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.hxx b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.hxx index 62c13ef8629f95ce7420364888a16123f5426c6d..b764bfbd068e07d38c24b3efdfab4b8eeff350ee 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.hxx +++ b/Modules/Filtering/Wavelet/include/otbWaveletFilterBank.hxx @@ -39,6 +39,7 @@ template WaveletFilterBank ::WaveletFilterBank () { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1); this->SetNumberOfRequiredInputs(1); @@ -608,6 +609,7 @@ template WaveletFilterBank ::WaveletFilterBank () { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(1 << InputImageDimension); m_UpSampleFilterFactor = 0; diff --git a/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h b/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h index 1c4e492afb9502144c27a6d042a0bb6ec255f81a..2528f5656eccdc69cc8bf728ef21ffe258d2e765 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h +++ b/Modules/Filtering/Wavelet/include/otbWaveletGenerator.h @@ -26,6 +26,7 @@ #include #include "itkLightObject.h" #include "itkObjectFactory.h" +#include "OTBWaveletExport.h" namespace otb { @@ -61,7 +62,7 @@ enum Wavelet { * \ingroup OTBWavelet */ template -class ITK_EXPORT WaveletGenerator +class OTBWavelet_EXPORT WaveletGenerator : public itk::LightObject { public: diff --git a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.hxx b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.hxx index 3925a187f945352135de8be2533ee6e9d0b0ddc2..3400df31d0489a4cb8ecb6e0c54bc43ecdeddf24 100644 --- a/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.hxx +++ b/Modules/Filtering/Wavelet/include/otbWaveletsBandsListToWaveletsSynopsisImageFilter.hxx @@ -33,7 +33,9 @@ namespace otb template WaveletsBandsListToWaveletsSynopsisImageFilter ::WaveletsBandsListToWaveletsSynopsisImageFilter() : m_DecimationRatio(2) -{} +{ +OTB_DISABLE_DYNAMIC_MT; +} /** Destructor */ template diff --git a/Modules/Filtering/Wavelet/otb-module.cmake b/Modules/Filtering/Wavelet/otb-module.cmake index 405672597ae8fe5cfbfb8daa94189bd733cbc515..6e881c5df52ea980f59929797446b72643d0dfbe 100644 --- a/Modules/Filtering/Wavelet/otb-module.cmake +++ b/Modules/Filtering/Wavelet/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains classes for wavelet analysis.") otb_module(OTBWavelet +ENABLE_SHARED DEPENDS OTBCommon OTBITK diff --git a/Modules/Filtering/Wavelet/test/otbWaveletTransform.cxx b/Modules/Filtering/Wavelet/test/otbWaveletTransform.cxx index 2c7c3a071d7c78d2d1be97a33e764d418b53e0bb..41a4e691f69b05ad13cc87523c6e373fc324a425 100644 --- a/Modules/Filtering/Wavelet/test/otbWaveletTransform.cxx +++ b/Modules/Filtering/Wavelet/test/otbWaveletTransform.cxx @@ -42,8 +42,12 @@ int otbWaveletTransform_generic(int argc, char * argv[]) if (argc == 7) { - unsigned int NbOfThreads = atoi(argv[6]); - itk::MultiThreader::SetGlobalDefaultNumberOfThreads(NbOfThreads); + unsigned int NbOfThreads = atoi(argv[6]); +#if ITK_VERSION_MAJOR < 5 + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(NbOfThreads); +#else + itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(NbOfThreads); +#endif } diff --git a/Modules/Fusion/Fuzzy/include/otbFuzzyDescriptorsModelManager.h b/Modules/Fusion/Fuzzy/include/otbFuzzyDescriptorsModelManager.h index d4eac61f52f45c90ba74f4b4a636c594656de180..a6746eecb0dd6347cfb36ad02494f54434496987 100644 --- a/Modules/Fusion/Fuzzy/include/otbFuzzyDescriptorsModelManager.h +++ b/Modules/Fusion/Fuzzy/include/otbFuzzyDescriptorsModelManager.h @@ -24,7 +24,7 @@ #include #include #include - +#include "OTBFuzzyExport.h" namespace otb { @@ -39,7 +39,7 @@ namespace otb { * * \ingroup OTBFuzzy */ - class FuzzyDescriptorsModelManager +class OTBFuzzy_EXPORT FuzzyDescriptorsModelManager { public: /** Standard class typedefs */ diff --git a/Modules/Fusion/Fuzzy/otb-module.cmake b/Modules/Fusion/Fuzzy/otb-module.cmake index b0db872c24065b7cc0d647984cc08093df735c2e..7358164bfc4a09eb2aa3c92ffedc94b16c4c7b31 100644 --- a/Modules/Fusion/Fuzzy/otb-module.cmake +++ b/Modules/Fusion/Fuzzy/otb-module.cmake @@ -25,6 +25,7 @@ membership value for each one of the qualitative values. it also contains classe to handle xml files where are stored several statistics.") otb_module(OTBFuzzy +ENABLE_SHARED DEPENDS OTBCommon OTBTinyXML diff --git a/Modules/IO/Carto/include/otbCoordinateToName.h b/Modules/IO/Carto/include/otbCoordinateToName.h index f440ae084cce6e731a1e0e71d9020bce4228862b..e3b982670b6206870ef461b2026569c09e5789de 100644 --- a/Modules/IO/Carto/include/otbCoordinateToName.h +++ b/Modules/IO/Carto/include/otbCoordinateToName.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) + * Copyright (C) 2018 CS Systemes d'Information (CS SI) * * This file is part of Orfeo Toolbox * @@ -22,9 +23,17 @@ #define otbCoordinateToName_h #include "itkPoint.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkMultiThreader.h" +#else +#include "itkPlatformMultiThreader.h" +#endif + +#include "itkConfigure.h" #include "otbCurlHelperInterface.h" #include "OTBCartoExport.h" +#include "otbMacro.h" //for ITK_THREAD_RETURN_TYPE in ITK5 #include namespace otb @@ -63,6 +72,12 @@ public: itkSetMacro(Lon, double); itkSetMacro(Lat, double); + #if ITK_VERSION_MAJOR > 4 + using PlatformMultiThreader = itk::PlatformMultiThreader; + #else + using PlatformMultiThreader = itk::MultiThreader; + #endif + /** * Set the lon/lat only if they are far enough from the current point to * avoid triggering too many updates @@ -125,7 +140,11 @@ protected: virtual void DoEvaluate(); - static ITK_THREAD_RETURN_TYPE ThreadFunction(void*); +#if ITK_VERSION_MAJOR >= 5 + static itk::ITK_THREAD_RETURN_TYPE ThreadFunction(void*); +#else + static ITK_THREAD_RETURN_TYPE ThreadFunction( void * ); +#endif private: CoordinateToName(const Self &) = delete; @@ -147,7 +166,7 @@ private: CurlHelperInterface::Pointer m_Curl; - itk::MultiThreader::Pointer m_Threader; + PlatformMultiThreader::Pointer m_Threader; }; } // namespace otb diff --git a/Modules/IO/Carto/include/otbMapFileProductWriter.h b/Modules/IO/Carto/include/otbMapFileProductWriter.h index 1c1dcb589f984788764f69dfeb2dc592f02c3436..1b95bf2cb96d63cad7e3f3169cd7143e35dd5db8 100644 --- a/Modules/IO/Carto/include/otbMapFileProductWriter.h +++ b/Modules/IO/Carto/include/otbMapFileProductWriter.h @@ -36,6 +36,7 @@ // projection filter #include "otbGenericRSResampleImageFilter.h" +#include "OTBCartoExport.h" #include namespace otb @@ -67,7 +68,7 @@ namespace otb * \ingroup OTBCarto */ template -class ITK_EXPORT MapFileProductWriter : public itk::ProcessObject +class ITK_TEMPLATE_EXPORT MapFileProductWriter : public itk::ProcessObject { public: /** Standard class typedefs. */ diff --git a/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h b/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h index 8f5ebf8eb061122fc7e30170d05ef0053e302273..5c9927b61aff7637a2dcc1ae116e902c13506211 100644 --- a/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h +++ b/Modules/IO/Carto/include/otbOSMDataToVectorDataGenerator.h @@ -27,6 +27,7 @@ #include #include "OTBCartoExport.h" +#include "itkMacro.h" #include "otbVectorData.h" #include "otbVectorDataSource.h" diff --git a/Modules/IO/Carto/src/otbCoordinateToName.cxx b/Modules/IO/Carto/src/otbCoordinateToName.cxx index 34228aa1eb4e171578e22911454dc80382b3fdce..4dde84933465def4f25a1ec20cd652ad0d267cee 100644 --- a/Modules/IO/Carto/src/otbCoordinateToName.cxx +++ b/Modules/IO/Carto/src/otbCoordinateToName.cxx @@ -1,5 +1,6 @@ /* * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) + * Copyright (C) 2018 CS Systemes d'Information (CS SI) * * This file is part of Orfeo Toolbox * @@ -57,7 +58,7 @@ CoordinateToName::CoordinateToName() : m_Curl = CurlHelper::New(); - m_Threader = itk::MultiThreader::New(); + m_Threader = PlatformMultiThreader::New(); m_UpdateDistance = 0.01; //about 1km at equator @@ -80,6 +81,7 @@ bool CoordinateToName::Evaluate() { if (m_Multithread) { + /* SpawnThread should be replace by std::thread in future */ m_Threader->SpawnThread(ThreadFunction, this); } else @@ -89,13 +91,26 @@ bool CoordinateToName::Evaluate() return true; } + +#if ITK_VERSION_MAJOR >= 5 +itk::ITK_THREAD_RETURN_TYPE +#else ITK_THREAD_RETURN_TYPE +#endif CoordinateToName::ThreadFunction(void *arg) { +#if ITK_VERSION_MAJOR < 5 struct itk::MultiThreader::ThreadInfoStruct * pInfo = (itk::MultiThreader::ThreadInfoStruct *) (arg); +#else + struct itk::MultiThreaderBase::ThreadInfoStruct * pInfo = (itk::MultiThreaderBase::ThreadInfoStruct *) (arg); +#endif CoordinateToName::Pointer lThis = (CoordinateToName*) (pInfo->UserData); lThis->DoEvaluate(); +#if ITK_VERSION_MAJOR >= 5 + return itk::ITK_THREAD_RETURN_DEFAULT_VALUE; +#else return ITK_THREAD_RETURN_VALUE; +#endif } void CoordinateToName::DoEvaluate() diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h index 69ca6e1a40c58b4274bbc9caa62ecc81a35163c4..78992db8065fbc3cd32fbbf22266ccc073289e89 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h +++ b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToReaderOptions.h @@ -22,6 +22,7 @@ #define otbExtendedFilenameToReaderOptions_h #include "otbExtendedFilenameHelper.h" +#include "OTBExtendedFilenameExport.h" #include namespace otb @@ -49,7 +50,7 @@ namespace otb * \ingroup OTBExtendedFilename */ -class ITK_EXPORT ExtendedFilenameToReaderOptions : public ExtendedFilenameHelper +class OTBExtendedFilename_EXPORT ExtendedFilenameToReaderOptions : public ExtendedFilenameHelper { public: /** Standard class typedefs. */ diff --git a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h index 8cde667b00149b61b93996eaaf6bc67308f39c2a..526a5d18b5dcef633044f99724f4ff6f2ec183a9 100644 --- a/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h +++ b/Modules/IO/ExtendedFilename/include/otbExtendedFilenameToWriterOptions.h @@ -23,6 +23,7 @@ #define otbExtendedFilenameToWriterOptions_h #include "otbExtendedFilenameHelper.h" +#include "OTBExtendedFilenameExport.h" #include "otbGDALImageIO.h" #include @@ -44,7 +45,7 @@ namespace otb * \ingroup OTBExtendedFilename */ -class ITK_EXPORT ExtendedFilenameToWriterOptions : public ExtendedFilenameHelper +class OTBExtendedFilename_EXPORT ExtendedFilenameToWriterOptions : public ExtendedFilenameHelper { public: /** Standard class typedefs. */ diff --git a/Modules/IO/ExtendedFilename/otb-module.cmake b/Modules/IO/ExtendedFilename/otb-module.cmake index fccc8bd7fc96722c8b21396776ea6757a49e38f9..dc5b7c995fb48c8c02ff05fb5bd7fcb3100bf8f9 100644 --- a/Modules/IO/ExtendedFilename/otb-module.cmake +++ b/Modules/IO/ExtendedFilename/otb-module.cmake @@ -25,6 +25,7 @@ different subdataset or resolution (for multi-resolution data), or manage ortho- product by skipping either geographic or sensor-model information.") otb_module(OTBExtendedFilename +ENABLE_SHARED DEPENDS OTBCommon OTBIOGDAL diff --git a/Modules/IO/IOBSQ/include/otbBSQImageIO.h b/Modules/IO/IOBSQ/include/otbBSQImageIO.h index 79666fbd21f0d162f04e720a51653289398bd98f..20cd736c09cb2a1749e09be5f5aec2374b85dbd5 100644 --- a/Modules/IO/IOBSQ/include/otbBSQImageIO.h +++ b/Modules/IO/IOBSQ/include/otbBSQImageIO.h @@ -26,7 +26,7 @@ #include #include "otbImageIOBase.h" - +#include "OTBIOBSQExport.h" namespace otb { @@ -41,7 +41,7 @@ namespace otb * * \ingroup OTBIOBSQ */ -class ITK_EXPORT BSQImageIO : public otb::ImageIOBase +class OTBIOBSQ_EXPORT BSQImageIO : public otb::ImageIOBase { public: diff --git a/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h b/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h index ab557795c27d21a0a1bff35f176bb2ba62c2aa50..73eb5cb31e29394360e3b0371342bf0578c5b536 100644 --- a/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h +++ b/Modules/IO/IOBSQ/include/otbBSQImageIOFactory.h @@ -22,7 +22,7 @@ #define otbBSQImageIOFactory_h #include "itkObjectFactoryBase.h" - +#include "OTBIOBSQExport.h" namespace otb { /** \class BSQImageIOFactory @@ -30,7 +30,7 @@ namespace otb * * \ingroup OTBIOBSQ */ -class ITK_EXPORT BSQImageIOFactory : public itk::ObjectFactoryBase +class OTBIOBSQ_EXPORT BSQImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IOBSQ/otb-module.cmake b/Modules/IO/IOBSQ/otb-module.cmake index 6dc9fb84167cf3cb43071cffbf6e462bcffb7b23..7c59e5019c04d3794d172f55caae699cbd510240 100644 --- a/Modules/IO/IOBSQ/otb-module.cmake +++ b/Modules/IO/IOBSQ/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains features to read BSQ format images.") otb_module(OTBIOBSQ +ENABLE_SHARED DEPENDS OTBImageBase OTBCommon diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 527091e25b0ea42dd13f7e6f1266393315853d74..7bd1b608b0b405ef4ac3d0ab72be52955111b11e 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1703,8 +1703,7 @@ bool GDALImageIO::GetOriginFromGMLBox(std::vector &origin) return false; } - std::vector originValues; - originValues = itksys::SystemTools::SplitString(originTag->GetText(),' ', false); + auto originValues = itksys::SystemTools::SplitString(originTag->GetText(),' ', false); // Compute origin in GDAL convention (the half-pixel shift is applied later) std::istringstream ss0 (originValues[0]); diff --git a/Modules/IO/IOLUM/include/otbLUMImageIO.h b/Modules/IO/IOLUM/include/otbLUMImageIO.h index 8d5dc2520e649cce671c0b77ed9066ce04af85b2..18a049ba14901f9ea5decf9adbe8536d60ed639c 100644 --- a/Modules/IO/IOLUM/include/otbLUMImageIO.h +++ b/Modules/IO/IOLUM/include/otbLUMImageIO.h @@ -22,6 +22,7 @@ #define otbLUMImageIO_h #include "otbImageIOBase.h" +#include "OTBIOLUMExport.h" #include #include #include @@ -40,7 +41,7 @@ namespace otb * * \ingroup OTBIOLUM */ -class ITK_EXPORT LUMImageIO : public otb::ImageIOBase +class OTBIOLUM_EXPORT LUMImageIO : public otb::ImageIOBase { public: diff --git a/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h b/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h index a1da92d76eabd538ce433846b71f68ddfd034be3..dcc84a750dc7925d422779147dbd47f3c80714f2 100644 --- a/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h +++ b/Modules/IO/IOLUM/include/otbLUMImageIOFactory.h @@ -22,6 +22,7 @@ #define otbLUMImageIOFactory_h #include "itkObjectFactoryBase.h" +#include "OTBIOLUMExport.h" namespace otb { @@ -30,7 +31,7 @@ namespace otb * * \ingroup OTBIOLUM */ -class ITK_EXPORT LUMImageIOFactory : public itk::ObjectFactoryBase +class OTBIOLUM_EXPORT LUMImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IOLUM/otb-module.cmake b/Modules/IO/IOLUM/otb-module.cmake index 586aa8b7c9703365b0bcf315a4f91290b9108d50..2c0e2ea3605d7b524404407f6b94745a4e7fbd21 100644 --- a/Modules/IO/IOLUM/otb-module.cmake +++ b/Modules/IO/IOLUM/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains features to read LUM format images.") otb_module(OTBIOLUM +ENABLE_SHARED DEPENDS OTBImageBase OTBCommon diff --git a/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h b/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h index 90170376daa0bcf8db23007b4daf151e7d3d2c18..5da108239fd4b363a7e0ac96bba44768e220dfd3 100644 --- a/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h +++ b/Modules/IO/IOMSTAR/include/otbMSTARImageIO.h @@ -22,6 +22,7 @@ #define otbMSTARImageIO_h #include "otbImageIOBase.h" +#include "OTBIOMSTARExport.h" namespace otb { @@ -37,7 +38,7 @@ namespace otb * * \ingroup OTBIOMSTAR */ -class ITK_EXPORT MSTARImageIO : public otb::ImageIOBase +class OTBIOMSTAR_EXPORT MSTARImageIO : public otb::ImageIOBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h b/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h index 7c46acab0cb7cf804483f0ddde35caa3898f8b14..49d5f03436bb4b3d4c261d3a7170db604f2dff0e 100644 --- a/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h +++ b/Modules/IO/IOMSTAR/include/otbMSTARImageIOFactory.h @@ -22,6 +22,7 @@ #define otbMSTARImageIOFactory_h #include "itkObjectFactoryBase.h" +#include "OTBIOMSTARExport.h" namespace otb { @@ -30,7 +31,7 @@ namespace otb * * \ingroup OTBIOMSTAR */ -class ITK_EXPORT MSTARImageIOFactory : public itk::ObjectFactoryBase +class OTBIOMSTAR_EXPORT MSTARImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IOMSTAR/otb-module.cmake b/Modules/IO/IOMSTAR/otb-module.cmake index d6a17f8466356625cac77179ea6ff975e419d5fe..c81795392f952d136df6998805b405a2fe9fdfef 100644 --- a/Modules/IO/IOMSTAR/otb-module.cmake +++ b/Modules/IO/IOMSTAR/otb-module.cmake @@ -22,6 +22,7 @@ set(DOCUMENTATION "This module contains features to read and write MSTAR format images.") otb_module(OTBIOMSTAR +ENABLE_SHARED DEPENDS OTBImageBase OTBCommon diff --git a/Modules/IO/IOONERA/include/otbONERAImageIO.h b/Modules/IO/IOONERA/include/otbONERAImageIO.h index 2634daeb92d2d13b2815177cd4047420abbf1d32..e92b4a8ddac26fd5216863eff495a5b1de87a35d 100644 --- a/Modules/IO/IOONERA/include/otbONERAImageIO.h +++ b/Modules/IO/IOONERA/include/otbONERAImageIO.h @@ -23,6 +23,7 @@ #include "itkByteSwapper.h" #include "otbImageIOBase.h" +#include "OTBIOONERAExport.h" #include namespace otb @@ -39,7 +40,7 @@ namespace otb * * \ingroup OTBIOONERA */ -class ITK_EXPORT ONERAImageIO : public otb::ImageIOBase +class OTBIOONERA_EXPORT ONERAImageIO : public otb::ImageIOBase { public: diff --git a/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h b/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h index 1c9efec2d5cdea2f6f2b8aef73c955be18033d99..e54a1e18974fec2bcd1124217f7aa4fc3cec0fcd 100644 --- a/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h +++ b/Modules/IO/IOONERA/include/otbONERAImageIOFactory.h @@ -22,6 +22,7 @@ #define otbONERAImageIOFactory_h #include "itkObjectFactoryBase.h" +#include "OTBIOONERAExport.h" namespace otb { @@ -30,7 +31,7 @@ namespace otb * * \ingroup OTBIOONERA */ -class ITK_EXPORT ONERAImageIOFactory : public itk::ObjectFactoryBase +class OTBIOONERA_EXPORT ONERAImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IOONERA/otb-module.cmake b/Modules/IO/IOONERA/otb-module.cmake index cc431e1ad5a8260a1bb64c714dd949dbcf04cb1f..824e70399adcfc8b0d422ea7be72c35a5d13049b 100644 --- a/Modules/IO/IOONERA/otb-module.cmake +++ b/Modules/IO/IOONERA/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains features to read ONERA format images.") otb_module(OTBIOONERA +ENABLE_SHARED DEPENDS OTBImageBase OTBCommon diff --git a/Modules/IO/IORAD/include/otbRADImageIO.h b/Modules/IO/IORAD/include/otbRADImageIO.h index 4ae50d1a9e187a78306be15d0001ab5804728e00..a21d169ecdccb787c6839953a59510e7518283ab 100644 --- a/Modules/IO/IORAD/include/otbRADImageIO.h +++ b/Modules/IO/IORAD/include/otbRADImageIO.h @@ -22,6 +22,7 @@ #define otbRADImageIO_h #include "otbImageIOBase.h" +#include "OTBIORADExport.h" #include #include #include @@ -40,7 +41,7 @@ namespace otb * * \ingroup OTBIORAD */ -class ITK_EXPORT RADImageIO : public otb::ImageIOBase +class OTBIORAD_EXPORT RADImageIO : public otb::ImageIOBase { public: diff --git a/Modules/IO/IORAD/include/otbRADImageIOFactory.h b/Modules/IO/IORAD/include/otbRADImageIOFactory.h index c76a91cefa314db60bbd5f6e9c58a2a3517c9e49..f0dc9d90fcd4af9c62e3115a2078d58ef323493d 100644 --- a/Modules/IO/IORAD/include/otbRADImageIOFactory.h +++ b/Modules/IO/IORAD/include/otbRADImageIOFactory.h @@ -21,6 +21,7 @@ #ifndef otbRADImageIOFactory_h #define otbRADImageIOFactory_h +#include "OTBIORADExport.h" #include "itkObjectFactoryBase.h" namespace otb @@ -30,7 +31,7 @@ namespace otb * * \ingroup OTBIORAD */ -class ITK_EXPORT RADImageIOFactory : public itk::ObjectFactoryBase +class OTBIORAD_EXPORT RADImageIOFactory : public itk::ObjectFactoryBase { public: /** Standard class typedefs. */ diff --git a/Modules/IO/IORAD/otb-module.cmake b/Modules/IO/IORAD/otb-module.cmake index f5720e90a4c6cfd2e077a313b0fceca29809b309..4fb3087c6ef9dd28f8c9549fccdbd7ebca38d12f 100644 --- a/Modules/IO/IORAD/otb-module.cmake +++ b/Modules/IO/IORAD/otb-module.cmake @@ -21,6 +21,7 @@ set(DOCUMENTATION "This module contains features to read RAD format images.") otb_module(OTBIORAD +ENABLE_SHARED DEPENDS OTBImageBase OTBCommon diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.h b/Modules/IO/ImageIO/include/otbImageFileWriter.h index 78edc3e678187d3be206dd3ddbc0464857217f86..a54b64e8283a8cdd08aad74aeea20f0ac06bdc90 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.h +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.h @@ -25,7 +25,12 @@ #include "itkProcessObject.h" #include "otbStreamingManager.h" #include "otbExtendedFilenameToWriterOptions.h" +#if ITK_VERSION_MAJOR < 5 #include "itkFastMutexLock.h" +#include "itkMutexLockHolder.h" +#else +#include +#endif #include #include "OTBImageIOExport.h" @@ -282,7 +287,11 @@ private: unsigned int m_IOComponents; /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ - itk::SimpleFastMutexLock m_Lock; +#if ITK_VERSION_MAJOR < 5 + mutable itk::SimpleFastMutexLock m_Lock; +#else + mutable std::mutex m_Lock; +#endif }; } // end namespace otb diff --git a/Modules/IO/ImageIO/include/otbImageFileWriter.hxx b/Modules/IO/ImageIO/include/otbImageFileWriter.hxx index f046197d3bbf6ff3c81e3275b705d25d8c856e65..6d993dabe68407f9d20b6f5ac642b89972547d26 100644 --- a/Modules/IO/ImageIO/include/otbImageFileWriter.hxx +++ b/Modules/IO/ImageIO/include/otbImageFileWriter.hxx @@ -850,10 +850,13 @@ const bool & ImageFileWriter ::GetAbortGenerateData() const { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif // protected read here bool ret = Superclass::GetAbortGenerateData(); - m_Lock.Unlock(); if (ret) return otb::Utils::TrueConstant; return otb::Utils::FalseConstant; } @@ -863,9 +866,12 @@ void ImageFileWriter ::SetAbortGenerateData(bool val) { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif Superclass::SetAbortGenerateData(val); - m_Lock.Unlock(); } } // end namespace otb diff --git a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.hxx b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.hxx index 849eea28a6c957b3e53f75a1344de676beda0511..901293a4721bcbdae77a65e31b3e30e9a889495f 100644 --- a/Modules/IO/ImageIO/include/otbMultiImageFileWriter.hxx +++ b/Modules/IO/ImageIO/include/otbMultiImageFileWriter.hxx @@ -34,7 +34,7 @@ MultiImageFileWriter::Sink const std::string & fileName): SinkBase(dynamic_cast(inputImage.GetPointer())), m_Writer(otb::ImageFileWriter::New()), - m_ImageIO(NULL) + m_ImageIO(nullptr) { m_Writer->SetFileName(fileName); m_Writer->SetInput(inputImage); @@ -45,7 +45,7 @@ MultiImageFileWriter::Sink ::Sink(typename otb::ImageFileWriter::ConstPointer writer): SinkBase(dynamic_cast(writer->GetInput()->GetPointer())), m_Writer(writer), - m_ImageIO(NULL) + m_ImageIO(nullptr) { } diff --git a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx index 042d600b569c8bec1a246b5f8d7963d1d824db1e..6b359ccc6f5c788afef08bef817cef297e0aef95 100644 --- a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx +++ b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx @@ -18,11 +18,6 @@ * limitations under the License. */ - - -#include "itkMutexLock.h" -#include "itkMutexLockHolder.h" - #include "otbImageIOFactory.h" #include "otbConfigure.h" @@ -33,6 +28,13 @@ #include "otbBSQImageIOFactory.h" #include "otbRADImageIOFactory.h" +#if ITK_VERSION_MAJOR < 5 +#include "itkMutexLock.h" +#include "itkMutexLockHolder.h" +#else +#include +#endif + namespace otb { @@ -83,11 +85,19 @@ ImageIOFactory::RegisterBuiltInFactories() { static bool firstTime = true; + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif { // This helper class makes sure the Mutex is unlocked // in the event an exception is thrown. + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(mutex); + #else + std::lock_guard mutexHolder(mutex); + #endif if (firstTime) { itk::ObjectFactoryBase::RegisterFactory(RADImageIOFactory::New()); diff --git a/Modules/IO/TestKernel/include/otbDifferenceImageFilter.hxx b/Modules/IO/TestKernel/include/otbDifferenceImageFilter.hxx index ddd40c5f9c3c661f721efb662d6dcec5992d1f00..fd93eb18010802886a7368019fb49bf2b4148e2e 100644 --- a/Modules/IO/TestKernel/include/otbDifferenceImageFilter.hxx +++ b/Modules/IO/TestKernel/include/otbDifferenceImageFilter.hxx @@ -37,6 +37,7 @@ template DifferenceImageFilter ::DifferenceImageFilter() { + OTB_DISABLE_DYNAMIC_MT; // We require two inputs to execute. this->SetNumberOfRequiredInputs(2); diff --git a/Modules/IO/TestKernel/include/otbTestMain.h b/Modules/IO/TestKernel/include/otbTestMain.h index d0d988393af1207beb29467ae5919191f17432e2..765de1c4f4c46d90bcb3412bcac8330ca3072286 100644 --- a/Modules/IO/TestKernel/include/otbTestMain.h +++ b/Modules/IO/TestKernel/include/otbTestMain.h @@ -27,7 +27,12 @@ #include #include +#if ITK_VERSION_MAJOR < 5 #include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif + #include "otbMacro.h" #include "otbOGRDriversInit.h" @@ -154,13 +159,21 @@ int main(int ac, char* av[]) if (CheckOption(av[1],"--with-threads", ac, 2)) { int numThreads = atoi(av[2]); + #if ITK_VERSION_MAJOR < 5 itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThreads); + #else + itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(numThreads); + #endif av += 2; ac -= 2; } else if (CheckOption(av[1], "--without-threads",ac, 1)) { + #if ITK_VERSION_MAJOR < 5 itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1); + #else + itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(1); + #endif av += 1; ac -= 1; } diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h b/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h index 200e7c98ae017bbe174ea2267f4722ee6ef664ed..f82f234b81b609534015caed7111e1e8f107e473 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataFileReader.h @@ -23,6 +23,7 @@ #include "otbVectorDataSource.h" #include "otbVectorDataIOBase.h" +#include "OTBVectorDataIOExport.h" #include namespace otb @@ -90,7 +91,7 @@ public: */ template -class ITK_EXPORT VectorDataFileReader : public VectorDataSource +class ITK_TEMPLATE_EXPORT VectorDataFileReader : public VectorDataSource { public: diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h b/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h index 9abdfb06fa4660edf6599660c2d833715eb4a3c2..0252a3d8c82e754f01fcc956706de62c08ace88a 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataFileWriter.h @@ -23,6 +23,7 @@ #include "itkProcessObject.h" #include "itkMacro.h" +#include "OTBVectorDataIOExport.h" #include "otbVectorDataIOBase.h" #include @@ -66,7 +67,7 @@ public: */ template -class ITK_EXPORT VectorDataFileWriter : public itk::ProcessObject +class ITK_TEMPLATE_EXPORT VectorDataFileWriter : public itk::ProcessObject { public: diff --git a/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h b/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h index a54a7fd40ec6a9c14aaa0f7c97e167bcd19a8388..a9e89bd80043fc24ea6af15e0cfd7fcb5527ec91 100644 --- a/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h +++ b/Modules/IO/VectorDataIO/include/otbVectorDataIOFactory.h @@ -23,6 +23,7 @@ #include "itkObject.h" #include "otbVectorDataIOBase.h" +#include "OTBVectorDataIOExport.h" namespace otb { @@ -31,7 +32,7 @@ namespace otb * * \ingroup OTBVectorDataIO */ -class ITK_EXPORT VectorDataIOFactory : public itk::Object +class OTBVectorDataIO_EXPORT VectorDataIOFactory : public itk::Object { public: /** Standard class typedefs. */ diff --git a/Modules/IO/VectorDataIO/otb-module.cmake b/Modules/IO/VectorDataIO/otb-module.cmake index dd63bb53b207862980e6f4cefc39fe779c0c259a..9ce1d9fd0266a737b25ee7e33de87d7b24da414e 100644 --- a/Modules/IO/VectorDataIO/otb-module.cmake +++ b/Modules/IO/VectorDataIO/otb-module.cmake @@ -23,6 +23,7 @@ writing of vector data (see also VectorDataBase and VectorDataManipulation modules).") otb_module(OTBVectorDataIO +ENABLE_SHARED DEPENDS OTBVectorDataBase OTBIOGDAL diff --git a/Modules/IO/VectorDataIO/src/otbVectorDataIOFactory.cxx b/Modules/IO/VectorDataIO/src/otbVectorDataIOFactory.cxx index b0da05abe89be4b492ba8ff02cbc91464ade5f32..d11e594fabb8dd93438d24745bdfc4928889cf18 100644 --- a/Modules/IO/VectorDataIO/src/otbVectorDataIOFactory.cxx +++ b/Modules/IO/VectorDataIO/src/otbVectorDataIOFactory.cxx @@ -26,8 +26,13 @@ #endif #include "itkObjectFactoryBase.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" #include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -86,11 +91,19 @@ VectorDataIOFactory { static bool firstTime = true; + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif { // This helper class makes sure the Mutex is unlocked // in the event an exception is thrown. + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(mutex); + #else + std::lock_guard mutexHolder(mutex); + #endif if (firstTime) { itk::ObjectFactoryBase::RegisterFactory(OGRVectorDataIOFactory::New()); diff --git a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.hxx b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.hxx index 986245968ed5a945835ed68c3c77ee3976a63d88..d38d3e8bfba35592cd7483341b228a4ee85703de 100644 --- a/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.hxx +++ b/Modules/Learning/DempsterShafer/include/otbDSFusionOfClassifiersImageFilter.hxx @@ -27,6 +27,7 @@ #include "itkMetaDataObject.h" #include "otbMetaDataKey.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; namespace otb { @@ -37,6 +38,7 @@ template DSFusionOfClassifiersImageFilter ::DSFusionOfClassifiersImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx index 6fad411f58b621348c901edcdd5f6e6d767b8343..1440f08dfa81f656920467ace7f1e55ef97d64e5 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx @@ -30,7 +30,11 @@ #include "otbPCAModelFactory.h" #endif +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLockHolder.h" +#else +#include +#endif namespace otb { @@ -106,8 +110,12 @@ template void DimensionalityReductionModelFactory ::RegisterBuiltInFactories() -{ +{ +#if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder lockHolder(mutex); +#else + std::lock_guard lockHolder(mutex); +#endif RegisterFactory(SOM2DModelFactory::New()); RegisterFactory(SOM3DModelFactory::New()); @@ -137,7 +145,11 @@ void DimensionalityReductionModelFactory ::CleanFactories() { +#if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder lockHolder(mutex); +#else + std::lock_guard lockHolder(mutex); +#endif std::list factories = itk::ObjectFactoryBase::GetRegisteredFactories(); std::list::iterator itFac; diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.hxx b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.hxx index b1aa17a83f7e6ac41fb731c3cb31519fb71ed79a..5500f14f16a5260812f1432ef868c9e8dc0f0392 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.hxx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbImageDimensionalityReductionFilter.hxx @@ -33,6 +33,7 @@ template ImageDimensionalityReductionFilter ::ImageDimensionalityReductionFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); diff --git a/Modules/Learning/LearningBase/include/otbImageClassificationFilter.hxx b/Modules/Learning/LearningBase/include/otbImageClassificationFilter.hxx index fae939bec87d650fab72ca610aa114a54e84b85d..e00385514e65b1a831757379c760e7e063791cf6 100644 --- a/Modules/Learning/LearningBase/include/otbImageClassificationFilter.hxx +++ b/Modules/Learning/LearningBase/include/otbImageClassificationFilter.hxx @@ -22,6 +22,7 @@ #define otbImageClassificationFilter_hxx #include "otbImageClassificationFilter.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIterator.h" #include "itkProgressReporter.h" @@ -37,7 +38,7 @@ ImageClassificationFilter this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); m_DefaultLabel = itk::NumericTraits::ZeroValue(); - + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredOutputs(3); this->SetNthOutput(0,TOutputImage::New()); this->SetNthOutput(1,ConfidenceImageType::New()); diff --git a/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.hxx b/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.hxx index 5951e4d18e2cfeeedbf67429d4160ad200d18adf..09faf3f51049ae4b6c175e11307df790c61192b0 100644 --- a/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.hxx +++ b/Modules/Learning/LearningBase/include/otbKMeansImageClassificationFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbKMeansImageClassificationFilter_hxx #define otbKMeansImageClassificationFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbKMeansImageClassificationFilter.h" #include "itkImageRegionIterator.h" #include "itkNumericTraits.h" @@ -34,6 +35,7 @@ template ::KMeansImageClassificationFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); this->SetNumberOfRequiredInputs(1); m_DefaultLabel = itk::NumericTraits::ZeroValue(); diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModel.hxx b/Modules/Learning/LearningBase/include/otbMachineLearningModel.hxx index 392857b02bc6106fd3f474b0c4e169f186bca266..857ede0b86147a3fea0ad0c60abad81019c01588 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModel.hxx +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModel.hxx @@ -27,7 +27,11 @@ #include "otbMachineLearningModel.h" +#if ITK_VERSION_MAJOR < 5 #include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif namespace otb { @@ -111,7 +115,11 @@ MachineLearningModel #pragma omp parallel shared(nb_threads,nb_batches) private(threadId) { // Get number of threads configured with ITK +#if ITK_VERSION_MAJOR < 5 omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); +#else + omp_set_num_threads(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads()); +#endif nb_threads = omp_get_num_threads(); threadId = omp_get_thread_num(); nb_batches = std::min(nb_threads,(unsigned int)input->Size()); diff --git a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h index 31b4029dfae9b0d9af382efe32566c02e72a8dd2..fd135fa7fa694ec606ea07dd2f67ab3369eee58a 100644 --- a/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h +++ b/Modules/Learning/LearningBase/include/otbMachineLearningModelFactoryBase.h @@ -21,7 +21,14 @@ #ifndef otbMachineLearningModelFactoryBase_h #define otbMachineLearningModelFactoryBase_h +#include "itkObject.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" +#else +#include +#endif + #include "OTBLearningBaseExport.h" namespace otb @@ -50,7 +57,11 @@ protected: MachineLearningModelFactoryBase(); ~MachineLearningModelFactoryBase() override; + #if ITK_VERSION_MAJOR < 5 static itk::SimpleMutexLock mutex; + #else + static std::mutex mutex; + #endif private: MachineLearningModelFactoryBase(const Self &) = delete; diff --git a/Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx b/Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx index 954899e159c672be9a1eabc1689b75fd78f15e77..6c45d5a2126aced575deaa36445d782e7c47f1ba 100644 --- a/Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx +++ b/Modules/Learning/LearningBase/src/otbMachineLearningModelFactoryBase.cxx @@ -23,6 +23,10 @@ namespace otb { +#if ITK_VERSION_MAJOR < 5 itk::SimpleMutexLock MachineLearningModelFactoryBase::mutex; +#else +std::mutex MachineLearningModelFactoryBase::mutex; +#endif } // end namespace otb diff --git a/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h b/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h index 05d2e71ff5a596a929b880c21ce2e93b5ac2bf45..3b87aab0a7c5be5aae64ecaf524ce5de6c46fdad 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyEdgeFidelity.h @@ -24,6 +24,10 @@ #include "otbMRFEnergy.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { /** diff --git a/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h b/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h index 6a780c25083c2edbd2d83e8ee21047672228f9c2..435c5917dd4acee068db6f23341827d82de7138f 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyGaussian.h @@ -26,6 +26,10 @@ #include "otbMath.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { /** diff --git a/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h b/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h index bb9451c4f87bd07d4efdf2d184ee7cfae0283a87..e49f825f3fdd990180b9f51ba6b51dfe8991a9b5 100644 --- a/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h +++ b/Modules/Learning/Markov/include/otbMRFEnergyGaussianClassification.h @@ -24,6 +24,10 @@ #include "otbMRFEnergy.h" #include "otbMath.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { /** diff --git a/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.hxx b/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.hxx index 5a3889c3025e871349fcc0ab2a17c06bb4e5eee0..ce666db2cfd41a43949e6dff031a480dfadfb31d 100644 --- a/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.hxx +++ b/Modules/Learning/SOM/include/otbSOMImageClassificationFilter.hxx @@ -34,6 +34,7 @@ template ::SOMImageClassificationFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetNumberOfRequiredInputs(2); this->SetNumberOfRequiredInputs(1); m_DefaultLabel = itk::NumericTraits::ZeroValue(); diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h index 552f3224f60d97fe2d775e46adce333da6b2f367..511f8f737d7aed3efa21ec78fa6203b2a1a0e5c5 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.h @@ -24,6 +24,7 @@ #include "otbPersistentImageFilter.h" #include "otbOGRDataSourceWrapper.h" #include "otbImage.h" +#include "otbMacro.h" //for ITK_THREAD_RETURN_TYPE in ITK5 #include namespace otb @@ -192,7 +193,11 @@ protected: const std::vector& GetAdditionalFields(); /** Callback function to launch VectorThreadedGenerateData in each thread */ +#if ITK_VERSION_MAJOR < 5 static ITK_THREAD_RETURN_TYPE VectorThreaderCallback(void *arg); +#else + static itk::ITK_THREAD_RETURN_TYPE VectorThreaderCallback(void *arg); +#endif /** basically the same struct as itk::ImageSource::ThreadStruct */ struct VectorThreadStruct diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.hxx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.hxx index c49051149dd537aa9972a4ed3362709005416cbd..919bea6691e6ecaae6f61bf906f77f57b54618e8 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.hxx +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.hxx @@ -29,6 +29,12 @@ #include "otbStopwatch.h" #include "itkProgressReporter.h" +#if ITK_VERSION_MAJOR < 5 +#include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif + namespace otb { @@ -878,14 +884,23 @@ PersistentSamplingFilterBase } template +#if ITK_VERSION_MAJOR < 5 ITK_THREAD_RETURN_TYPE +#else +itk::ITK_THREAD_RETURN_TYPE +#endif PersistentSamplingFilterBase ::VectorThreaderCallback(void *arg) { +#if ITK_VERSION_MAJOR < 5 VectorThreadStruct *str = (VectorThreadStruct*)(((itk::MultiThreader::ThreadInfoStruct *)(arg))->UserData); - int threadId = ((itk::MultiThreader::ThreadInfoStruct *)(arg))->ThreadID; int threadCount = ((itk::MultiThreader::ThreadInfoStruct *)(arg))->NumberOfThreads; +#else + VectorThreadStruct *str = (VectorThreadStruct*)(((itk::MultiThreaderBase::ThreadInfoStruct *)(arg))->UserData); + int threadId = ((itk::MultiThreaderBase::ThreadInfoStruct *)(arg))->ThreadID; + int threadCount = ((itk::MultiThreaderBase::ThreadInfoStruct *)(arg))->NumberOfThreads; +#endif ogr::Layer layer = str->Filter->GetInMemoryInput(threadId); @@ -893,8 +908,12 @@ PersistentSamplingFilterBase { str->Filter->ThreadedGenerateVectorData(layer,threadId); } - + +#if ITK_VERSION_MAJOR >= 5 + return itk::ITK_THREAD_RETURN_DEFAULT_VALUE; +#else return ITK_THREAD_RETURN_VALUE; +#endif } template diff --git a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.hxx b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.hxx index 802027f27b231350e4b6f03a80b124ed919dc178..432b8d0bce152751f5526bc20abd120ee7eaa997 100644 --- a/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.hxx +++ b/Modules/Learning/Supervised/include/otbMachineLearningModelFactory.hxx @@ -43,8 +43,11 @@ #include "otbSharkKMeansMachineLearningModelFactory.h" #endif +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLockHolder.h" - +#else +#include +#endif namespace otb { @@ -100,7 +103,11 @@ void MachineLearningModelFactory ::RegisterBuiltInFactories() { +#if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder lockHolder(mutex); +#else + std::lock_guard lockHolder(mutex); +#endif #ifdef OTB_USE_LIBSVM RegisterFactory(LibSVMMachineLearningModelFactory::New()); @@ -139,7 +146,11 @@ void MachineLearningModelFactory ::CleanFactories() { +#if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder lockHolder(mutex); +#else + std::lock_guard lockHolder(mutex); +#endif std::list factories = itk::ObjectFactoryBase::GetRegisteredFactories(); std::list::iterator itFac; diff --git a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.hxx b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.hxx index b59e079182e4ac3ea894c203ee7c6350159bdebb..a0553abaded5e15e95319bba0f62508d8a0b4537 100644 --- a/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.hxx +++ b/Modules/Learning/Supervised/include/otbSharkRandomForestsMachineLearningModel.hxx @@ -70,8 +70,12 @@ SharkRandomForestsMachineLearningModel ::Train() { #ifdef _OPENMP +#if ITK_VERSION_MAJOR < 5 omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); -#endif +#else + omp_set_num_threads(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads()); +#endif // ITK_VERSION_MAJOR +#endif // _OPENMP std::vector features; std::vector class_labels; @@ -185,9 +189,13 @@ SharkRandomForestsMachineLearningModel shark::Data inputSamples = shark::createDataFromRange(features); #ifdef _OPENMP +#if ITK_VERSION_MAJOR < 5 omp_set_num_threads(itk::MultiThreader::GetGlobalDefaultNumberOfThreads()); +#else + omp_set_num_threads(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads()); +#endif // ITK_VERSION_MAJOR +#endif // _OPENMP - #endif if( proba !=nullptr || quality != nullptr) { shark::Data probas = m_RFModel.decisionFunction()(inputSamples); diff --git a/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx b/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx index 76a5dbb3470077231e58ec8d36dbd7c47c1d5346..7929f6a96d86e9982bfafd7cd38c0c115720576e 100644 --- a/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx +++ b/Modules/MPI/MPIConfig/src/otbMPIConfig.cxx @@ -59,15 +59,15 @@ namespace otb { /** Initialize the singleton */ -MPIConfig::Pointer MPIConfig::m_Singleton = NULL; +MPIConfig::Pointer MPIConfig::m_Singleton = nullptr; MPIConfig::Pointer MPIConfig::Instance() { - if(m_Singleton.GetPointer() == NULL) + if(m_Singleton.GetPointer() == nullptr) { m_Singleton = itk::ObjectFactory::Create(); - if(m_Singleton.GetPointer() == NULL) + if(m_Singleton.GetPointer() == nullptr) { m_Singleton = new MPIConfig; } diff --git a/Modules/MPI/MPIConfig/test/otbMPIConfigTest.cxx b/Modules/MPI/MPIConfig/test/otbMPIConfigTest.cxx index 4b62b69d02507d30db67a3af760d177767f79164..30d94458d3af70b5a446cb201c431e47a567b426 100644 --- a/Modules/MPI/MPIConfig/test/otbMPIConfigTest.cxx +++ b/Modules/MPI/MPIConfig/test/otbMPIConfigTest.cxx @@ -21,7 +21,7 @@ #include "otbMPIConfig.h" #include -#include "itkMultiThreader.h" +//#include "itkMultiThreader.h" int otbMPIConfigTest(int argc, char* argv[]) { diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h index 0fe5cb7ede587fb1b651fd3cc9ac2d0cd9453b35..dd7293e8768f626961efdfa6821843ab65f9cf86 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.h @@ -31,7 +31,14 @@ #include "itkImageFileWriter.h" #include "itkObjectFactoryBase.h" + + +#if ITK_VERSION_MAJOR < 5 #include "itkFastMutexLock.h" +#include "itkMutexLockHolder.h" +#else +#include +#endif #include "itkImageRegionMultidimensionalSplitter.h" #include "otbImageIOFactory.h" @@ -332,7 +339,12 @@ private: bool m_TiffTiledMode; /** Lock to ensure thread-safety (added for the AbortGenerateData flag) */ - itk::SimpleFastMutexLock m_Lock; +#if ITK_VERSION_MAJOR < 5 + mutable itk::SimpleFastMutexLock m_Lock; +#else + mutable std::mutex m_Lock; +#endif + }; diff --git a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.hxx b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.hxx index 0e132d6e908f252bb3ed256ed83aff27bb931d7f..3a7f131f0c03b4c83101e4a4eb75700d61c013b6 100644 --- a/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.hxx +++ b/Modules/MPI/MPITiffWriter/include/otbSimpleParallelTiffWriter.hxx @@ -842,9 +842,12 @@ const bool & SimpleParallelTiffWriter ::GetAbortGenerateData() const { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif bool ret = Superclass::GetAbortGenerateData(); - m_Lock.Unlock(); if (ret) return otb::Utils::TrueConstant; return otb::Utils::FalseConstant; } @@ -854,9 +857,12 @@ void SimpleParallelTiffWriter ::SetAbortGenerateData(bool val) { - m_Lock.Lock(); +#if ITK_VERSION_MAJOR < 5 + itk::MutexLockHolder mutexHolder(m_Lock); +#else + std::lock_guard mutexHolder(m_Lock); +#endif Superclass::SetAbortGenerateData(val); - m_Lock.Unlock(); } } diff --git a/Modules/MPI/MPIVrtWriter/test/otbMPIReadWriteTest.cxx b/Modules/MPI/MPIVrtWriter/test/otbMPIReadWriteTest.cxx index f8f7fa0f9682701431b9707f24326a61ecda5247..f9ef5f376f2aee0b76df47fd600e3b156de3c41c 100644 --- a/Modules/MPI/MPIVrtWriter/test/otbMPIReadWriteTest.cxx +++ b/Modules/MPI/MPIVrtWriter/test/otbMPIReadWriteTest.cxx @@ -26,6 +26,12 @@ #include "otbMPIConfig.h" #include "otbMPIVrtWriter.h" +#if ITK_VERSION_MAJOR < 5 +#include "itkMultiThreader.h" +#else +#include "itkMultiThreaderBase.h" +#endif + #include #include @@ -34,9 +40,14 @@ int otbMPIReadWriteTest(int argc, char * argv[]) { // Mono-thread execution +#if ITK_VERSION_MAJOR < 5 itk::MultiThreader::SetGlobalMaximumNumberOfThreads(1); itk::MultiThreader::SetGlobalDefaultNumberOfThreads(1); - +#else + itk::MultiThreaderBase::SetGlobalMaximumNumberOfThreads(1); + itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(1); +#endif + // MPI Initialization typedef otb::MPIConfig MPIConfigType; MPIConfigType::Pointer config = MPIConfigType::Instance(); diff --git a/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h index 9b8fed242084ca2778781508b41f04b04cc1b0a8..c58c175e103df76af64dc8b2375a2e3df77ff802 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbImageToRadianceImageFilter.h @@ -165,6 +165,7 @@ protected: /** Constructor */ ImageToRadianceImageFilter() { + OTB_DISABLE_DYNAMIC_MT; m_Alpha.SetSize(0); m_Beta.SetSize(0); }; diff --git a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h index 2ce98ce899001ae31f50670c07623548c5f4eb31..18c3249056d2ce642142412d8977c317d5693f99 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbRadianceToReflectanceImageFilter.h @@ -259,6 +259,7 @@ protected: m_IsSetSolarDistance(false), m_UseClamp(true) { + OTB_DISABLE_DYNAMIC_MT; m_SolarIllumination.SetSize(0); }; diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h index 3f59b864dc8711ba6efbcad6e15bb347139fd4f3..f7f294fdf7f4e6b8f8e319976440760c4ab8f0e0 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h +++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToRadianceImageFilter.h @@ -241,6 +241,7 @@ protected: m_IsSetFluxNormalizationCoefficient(false), m_IsSetSolarDistance(false) { + OTB_DISABLE_DYNAMIC_MT; m_SolarIllumination.SetSize(0); }; diff --git a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.hxx b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.hxx index 1dfd7c0ca8a6e16237cc040548fe6920d6101781..0ffd630537a01a668012567147360a7e2786026a 100644 --- a/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.hxx +++ b/Modules/Radiometry/OpticalCalibration/include/otbReflectanceToSurfaceReflectanceImageFilter.hxx @@ -38,6 +38,7 @@ ReflectanceToSurfaceReflectanceImageFilter m_IsSetAcquiCorrectionParameters(false), m_UseGenerateParameters(true) { + OTB_DISABLE_DYNAMIC_MT; m_AtmosphericRadiativeTerms = AtmosphericRadiativeTermsType::New(); m_AtmoCorrectionParameters = AtmoCorrectionParametersType::New(); m_AcquiCorrectionParameters = AcquiCorrectionParametersType::New(); diff --git a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.hxx b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.hxx index 502c13161cebc728c4cd598441e538af57657200..62b6a6b7bad8fa069dfdd98e69ab4017f913d42e 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.hxx +++ b/Modules/Radiometry/SARCalibration/include/otbSarDeburstImageFilter.hxx @@ -25,6 +25,7 @@ #include "otbSarSensorModelAdapter.h" #include "otbImageKeywordlist.h" +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageScanlineIterator.h" #include "itkImageScanlineConstIterator.h" #include "itkImageRegionIterator.h" @@ -35,7 +36,9 @@ namespace otb // Constructor template SarDeburstImageFilter::SarDeburstImageFilter() : m_LinesRecord(), m_SamplesRecord(), m_OnlyValidSample(false) -{} +{ + OTB_DISABLE_DYNAMIC_MT; +} // Needs to be re-implemented since size of output is modified template< class TImage> diff --git a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.hxx b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.hxx index 017bec212cebf8582d60a036afcd90500a4b2da8..4d7c6a47858722d2bd8fdc4fa1f18a94a026368f 100644 --- a/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.hxx +++ b/Modules/Radiometry/SARCalibration/include/otbSarRadiometricCalibrationToImageFilter.hxx @@ -37,7 +37,7 @@ SarRadiometricCalibrationToImageFilter ::SarRadiometricCalibrationToImageFilter() : m_LookupSelected(0) { - + OTB_DISABLE_DYNAMIC_MT; } template diff --git a/Modules/Radiometry/SARCalibration/test/otbSarParametricMapFunctionTest.cxx b/Modules/Radiometry/SARCalibration/test/otbSarParametricMapFunctionTest.cxx index 82904e132d17f472db4fe1d7d40e4c48533ddc15..71b68784e3edd4789c212ef24fa726ec90507565 100644 --- a/Modules/Radiometry/SARCalibration/test/otbSarParametricMapFunctionTest.cxx +++ b/Modules/Radiometry/SARCalibration/test/otbSarParametricMapFunctionTest.cxx @@ -59,8 +59,6 @@ int otbSarParametricMapFunctionTest(int itkNotUsed(argc), char* argv[]) FunctionType::PointType p0; IndexType index; InputPixelType value; - FunctionType::PointType pDst; - p0[0] = static_cast(size[0] / 2.); p0[1] = static_cast(size[1] / 4.); diff --git a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx index 439eda0b92a4ddaa019293656e3358b50935b95c..67e355a4d227198abe23982e532f73b6cf61d500 100644 --- a/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx +++ b/Modules/Radiometry/Simulation/test/otbSoilDBTest.cxx @@ -23,6 +23,8 @@ #include "otbSoilDataBase.h" #include +#include /* fabs */ + int otbSoilDataBaseParseFile(int argc, char * argv[]) { if(argc < 5) diff --git a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.hxx b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.hxx index a95c3702912abd1f003531c7e1483d39447db7f2..15b5c1f115c5a3123dfc2a76f96f69bec17fc0e6 100644 --- a/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.hxx +++ b/Modules/Registration/DisparityMap/include/otbDisparityTranslateFilter.hxx @@ -22,7 +22,7 @@ #define otbDisparityTranslateFilter_hxx #include "otbDisparityTranslateFilter.h" - +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "itkImageRegionIteratorWithIndex.h" #include "itkImageRegionIterator.h" @@ -33,6 +33,7 @@ template ::DisparityTranslateFilter() { + OTB_DISABLE_DYNAMIC_MT; m_NoDataValue = -32768; // Set the number of inputs (1 moving image by default -> 3 inputs) this->SetNumberOfRequiredInputs(6); diff --git a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.hxx b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.hxx index ed60d5d19d6862185945ae2edd9b8a6db228b9e3..1adad664550be34e044af44f9123acff3ed96539 100644 --- a/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.hxx +++ b/Modules/Registration/DisparityMap/include/otbMultiDisparityMapTo3DFilter.hxx @@ -33,6 +33,7 @@ class TMaskImage, class TResidueImage> MultiDisparityMapTo3DFilter ::MultiDisparityMapTo3DFilter() { + OTB_DISABLE_DYNAMIC_MT; // Set the number of inputs (1 moving image by default -> 3 inputs) this->SetNumberOfRequiredInputs(3); this->SetNumberOfRequiredInputs(1); diff --git a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.hxx b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.hxx index 8d052aa47869ce952a695a5c3d272ac2b7ddf371..a140195f10f5156e7bef886b8089e8b4f8828dae 100644 --- a/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.hxx +++ b/Modules/Registration/DisparityMap/include/otbNCCRegistrationFunction.hxx @@ -28,6 +28,10 @@ #include "otbMacro.h" #include "otbNCCRegistrationFunction.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { diff --git a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.hxx b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.hxx index 454a6385f1c86d16a82ad13cb0fff45b0d2ed4cd..252bb01725e5d4d3c6928bb0d6e2dc5f55ff6cec 100644 --- a/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.hxx +++ b/Modules/Registration/DisparityMap/include/otbPixelWiseBlockMatchingImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbPixelWiseBlockMatchingImageFilter_hxx #define otbPixelWiseBlockMatchingImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbPixelWiseBlockMatchingImageFilter.h" #include "itkProgressReporter.h" #include "itkConstantBoundaryCondition.h" @@ -33,6 +34,7 @@ PixelWiseBlockMatchingImageFilter ::PixelWiseBlockMatchingImageFilter() { + OTB_DISABLE_DYNAMIC_MT; // Set the number of inputs this->SetNumberOfRequiredInputs(6); this->SetNumberOfRequiredInputs(2); diff --git a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.hxx b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.hxx index fdf976a52d326216161d337b5b8f3f560b3d97d5..324f033b5c644641370925b65d90c07c5d9eac77 100644 --- a/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.hxx +++ b/Modules/Registration/DisparityMap/include/otbSubPixelDisparityImageFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbSubPixelDisparityImageFilter_hxx #define otbSubPixelDisparityImageFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbSubPixelDisparityImageFilter.h" namespace otb @@ -31,6 +32,7 @@ SubPixelDisparityImageFilter ::SubPixelDisparityImageFilter() { + OTB_DISABLE_DYNAMIC_MT; // Set the number of required inputs this->SetNumberOfRequiredInputs(3); diff --git a/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.hxx b/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.hxx index 28760532276fff1a93e35702b8de4b2659e5c89e..d5d49f1d6d7de4cd82f9f69d83cc78d45bce1b05 100644 --- a/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.hxx +++ b/Modules/Registration/Stereo/include/otbBijectionCoherencyFilter.hxx @@ -21,6 +21,7 @@ #ifndef otbBijectionCoherencyFilter_hxx #define otbBijectionCoherencyFilter_hxx +#include "otbMacro.h" //for OTB_DISABLE_DYNAMIC_MT; #include "otbBijectionCoherencyFilter.h" #include "itkImageRegionConstIteratorWithIndex.h" @@ -33,6 +34,7 @@ template BijectionCoherencyFilter ::BijectionCoherencyFilter() { + OTB_DISABLE_DYNAMIC_MT; // Set the number of inputs (1 moving image by default -> 3 inputs) this->SetNumberOfRequiredInputs(4); this->SetNumberOfRequiredInputs(1); diff --git a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.hxx b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.hxx index 5f659baf366148ba89fc491ff9802293e224d239..ec0e2075991a58cc8940fefef9521fe385791ffe 100644 --- a/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.hxx +++ b/Modules/Registration/Stereo/include/otbMulti3DMapToDEMFilter.hxx @@ -33,6 +33,7 @@ namespace otb template Multi3DMapToDEMFilter::Multi3DMapToDEMFilter() { + OTB_DISABLE_DYNAMIC_MT; // Set the number of inputs (1 image one optional mask) this->SetNumberOfIndexedInputs(2); this->SetNumberOfRequiredInputs(1); @@ -416,7 +417,6 @@ void Multi3DMapToDEMFilter::GenerateInput typename T3DImage::RegionType mapRegion = imgPtr->GetLargestPossibleRegion(); - itk::ContinuousIndex mapContiIndex; long int maxMapIndex[2] = { 0, 0 }; long int minMapIndex[2] = { 0, 0 }; maxMapIndex[0] = static_cast (mapRegion.GetIndex(0) + mapRegion.GetSize(0)); @@ -569,7 +569,6 @@ void Multi3DMapToDEMFilter::ThreadedGener TOutputDEMImage * outputPtr = this->GetOutput(); typename OutputImageType::PointType pointRef; - typename OutputImageType::PointType pointRefStep; typename OutputImageType::RegionType requestedRegion = outputPtr->GetRequestedRegion(); // typename TOutputDEMImage::SpacingType step = outputPtr->GetSignedSpacing(); diff --git a/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.hxx b/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.hxx index 45b9a2d347146171722aad3f6da48f94989e8bb3..7b7cd6f6c9bea5e46e8a295eb5e293b597db1b59 100644 --- a/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.hxx +++ b/Modules/Registration/Stereo/include/otbStereoSensorModelToElevationMapFilter.hxx @@ -398,7 +398,7 @@ StereoSensorModelToElevationFilter while(!outputIt.IsAtEnd() && !inputIt.IsAtEnd()) { // Define some loop variables - typename InputImageType::PointType inPoint, outPoint, currentPoint, optimalPoint; + typename InputImageType::PointType inPoint, outPoint; typename GenericRSTransform3DType::InputPointType in3DPoint, out3DPoint; typename InputImageType::IndexType index; diff --git a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.hxx b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.hxx index ca6b15351509b554341708323e1ee40018193fc8..abb6ce8e355b0c98defba5b383f7a93ecb21e183 100644 --- a/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.hxx +++ b/Modules/Registration/Stereo/include/otbStereorectificationDisplacementFieldSource.hxx @@ -171,7 +171,6 @@ StereorectificationDisplacementFieldSource if(m_UseDEM) { - RSTransform2DType::InputPointType tmpPoint; localElevation = demHandler->GetHeightAboveEllipsoid(leftToGroundTransform->TransformPoint(m_LeftImage->GetOrigin())); } diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h index 90cba65b597b17be3de77bf8a9469b94659715a4..57cb18599e9758b83b943045f286ea59e0729157 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapFilter.h @@ -24,7 +24,7 @@ #include "itkLabelObject.h" #include "itkProgressReporter.h" -#include "itkBarrier.h" +//#include "itkBarrier.h" #include "itkConceptChecking.h" #include "itkContinuousIndex.h" //#include "itkDataObject.h" diff --git a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h index 60586c59d87aeec48f26f494763f9a128af06240..bd13db6df3d95c60169f57fcb0dfdc0ef8d91f2c 100644 --- a/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h +++ b/Modules/Segmentation/Conversion/include/otbVectorDataToLabelMapWithAttributesFilter.h @@ -24,7 +24,7 @@ #include "itkLabelObject.h" #include "itkProgressReporter.h" -#include "itkBarrier.h" +//#include "itkBarrier.h" #include "itkConceptChecking.h" #include "itkContinuousIndex.h" //#include "itkDataObject.h" diff --git a/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h b/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h index 93c43a52e984510dd048227b2b8ba57e01ba10ad..6a2894643cd1805ca39ccb7e6121e1733fedff58 100644 --- a/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h +++ b/Modules/Segmentation/Labelling/include/otbLabelToBoundaryImageFilter.h @@ -23,7 +23,7 @@ #define otbLabelToBoundaryImageFilter_h #include "otbUnaryFunctorNeighborhoodImageFilter.h" - +#include "otbMacro.h" namespace otb { namespace Functor @@ -96,6 +96,7 @@ public: protected: LabelToBoundaryImageFilter() { + OTB_DISABLE_DYNAMIC_MT; this->SetRadius(1); } ~LabelToBoundaryImageFilter() override { } diff --git a/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h b/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h index 6733c105511dcdd3bbfff67874efe48aa6419d63..3256245aa22305aeb3052e8db6c2898a120818c0 100644 --- a/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h +++ b/Modules/Segmentation/MorphologicalProfiles/include/otbMultiScaleConvexOrConcaveClassificationFilter.h @@ -177,5 +177,6 @@ using MultiScaleConvexOrConcaveClassificationFilter Functor::MultiScaleConvexOrConcaveDecisionRule_tags::max_closing_profile_derivative, Functor::MultiScaleConvexOrConcaveDecisionRule_tags::opening_profile_characteristics, Functor::MultiScaleConvexOrConcaveDecisionRule_tags::closing_profile_characteristics> >; + } // End namespace otb #endif diff --git a/Modules/ThirdParty/6S/src/CMakeLists.txt b/Modules/ThirdParty/6S/src/CMakeLists.txt index 2898cca97f2ec7fe1f56fb5b59b90f004d972074..eddfba640e3708783ebc8561b517ca106764df62 100644 --- a/Modules/ThirdParty/6S/src/CMakeLists.txt +++ b/Modules/ThirdParty/6S/src/CMakeLists.txt @@ -93,6 +93,10 @@ if(OTB_LIBRARY_PROPERTIES) set_target_properties(otb6S PROPERTIES ${OTB_LIBRARY_PROPERTIES}) endif() +if(MSVC) + set_target_properties(otb6S PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +endif() + # Below "extra" compile flags are needed for proper functioning of 6S # library. Without these flags especially /Oy- OpticalCalibration tests # are failing. the flags are automatially added by VS generator. diff --git a/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h b/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h index 8b0b7632d47e6f36736917995367dafb70660fb1..6c84c5856171277ae6eba3e79dff84e8980e4f7b 100644 --- a/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h +++ b/Modules/ThirdParty/ITK/include/itkImageRegionSplitter.h @@ -71,7 +71,7 @@ namespace itk */ template< unsigned int VImageDimension > -class ITK_EXPORT ImageRegionSplitter:public ImageRegionSplitterBase +class ITK_ABI_EXPORT ImageRegionSplitter : public ImageRegionSplitterBase { public: /** Standard class typedefs. */ diff --git a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx index c8db8c9d6fe02cc109b0b25b1c87eb117a9c2919..25c3d43e2bb4f095d006c1cb4dcac7b1b0f4cd55 100644 --- a/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx +++ b/Modules/ThirdParty/ITK/include/itkTransformToDisplacementFieldSource.hxx @@ -34,6 +34,9 @@ template< class TOutputImage, class TTransformPrecisionType > TransformToDisplacementFieldSource< TOutputImage, TTransformPrecisionType > ::TransformToDisplacementFieldSource() { + #if ITK_VERSION_MAJOR > 4 + this->DynamicMultiThreadingOff(); + #endif this->m_OutputSpacing.Fill(1.0); this->m_OutputOrigin.Fill(0.0); this->m_OutputDirection.SetIdentity(); diff --git a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h index 694cb0297bf95464458c63e741884fdabc3f260a..08fbf260d48fdeabe8b89976b5457445432652bb 100644 --- a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h +++ b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.h @@ -50,7 +50,7 @@ namespace itk * \ingroup OTBITK */ template< class TInputImage, class TOutputImage, class TFunction > -class ITK_EXPORT UnaryFunctorImageFilter:public InPlaceImageFilter< TInputImage, TOutputImage > +class ITK_TEMPLATE_EXPORT UnaryFunctorImageFilter:public InPlaceImageFilter< TInputImage, TOutputImage > { public: /** Standard class typedefs. */ diff --git a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx index e5872ddce4bd35ab2e00cbf98b97fac77dc7a22c..4dda6cc9efcdf774a9a7540d6bddf039668fe8f8 100644 --- a/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx +++ b/Modules/ThirdParty/ITK/include/itkUnaryFunctorImageFilter.hxx @@ -31,6 +31,9 @@ template< class TInputImage, class TOutputImage, class TFunction > UnaryFunctorImageFilter< TInputImage, TOutputImage, TFunction > ::UnaryFunctorImageFilter() { + #if ITK_VERSION_MAJOR > 4 + this->DynamicMultiThreadingOff(); + #endif this->SetNumberOfRequiredInputs(1); this->InPlaceOff(); } diff --git a/Modules/ThirdParty/ITK/otb-module-init.cmake b/Modules/ThirdParty/ITK/otb-module-init.cmake index d5d354ec560f0b3223a7559e1821530379df06ad..71b4f188a1b440ed4e478121963aab9e606f4f0b 100644 --- a/Modules/ThirdParty/ITK/otb-module-init.cmake +++ b/Modules/ThirdParty/ITK/otb-module-init.cmake @@ -71,7 +71,6 @@ set(OTBITK_ITK_REQUIRED_MODULE_LIST ITKEigen #ITKFEM ITKNarrowBand - ITKNeuralNetworks ITKOptimizers ITKOptimizersv4 ITKPolynomials diff --git a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt index 0718ae262b374f0c1476c83416f0717a2bf12b47..809bed1be23edbf21490ecf9703c19f54e391f77 100644 --- a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt +++ b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt @@ -106,6 +106,9 @@ if(OTB_LIBRARY_PROPERTIES) set_target_properties(otbsiftfast PROPERTIES ${OTB_LIBRARY_PROPERTIES}) endif() +if(MSVC) + set_target_properties(otbsiftfast PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +endif() install(TARGETS otbsiftfast EXPORT ${OTB3P_INSTALL_EXPORT_NAME} RUNTIME DESTINATION ${OTB3P_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries diff --git a/Modules/Visualization/Ice/src/otbGlImageActor.cxx b/Modules/Visualization/Ice/src/otbGlImageActor.cxx index 1a61ab0062e8745c104dbfb0372a2523c01f6909..c4ec370d3ed2ab93379c00f20a062efdf5be174b 100644 --- a/Modules/Visualization/Ice/src/otbGlImageActor.cxx +++ b/Modules/Visualization/Ice/src/otbGlImageActor.cxx @@ -31,6 +31,10 @@ #include "itkListSample.h" #include "otbListSampleToHistogramListGenerator.h" +#if ITK_VERSION_MAJOR >= 5 +#include "vcl_legacy_aliases.h" // ITK v5 compatibility +#endif + namespace otb { diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx index 74967552f28a7fea8e4d986529302219bdfdc46a..1b31e39a6e7d847f7ede00dc6910e54a18d27043 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx @@ -384,7 +384,7 @@ ParameterList< T > std::for_each( begin(), end(), - [ this_list, get ]( auto parameter ) -> void + [ this_list, get ]( typename T::Pointer parameter ) -> void { assert( parameter ); assert( parameter==otb::DynamicCast< T >( parameter ) ); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx index ebf41589f69182b75805bbf78e5270af483228f3..3230105edef53c40b2d9d0b4f91e73355e181354 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplicationRegistry.cxx @@ -24,8 +24,13 @@ #include "itksys/SystemTools.hxx" #include "itkDynamicLoader.h" #include "itkDirectory.h" + +#if ITK_VERSION_MAJOR < 5 #include "itkMutexLock.h" #include "itkMutexLockHolder.h" +#else +#include +#endif #include @@ -50,7 +55,11 @@ public: if (app && handle) { // mutex lock to ensure thread safety + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(m_Mutex); + #else + std::lock_guard mutexHolder(m_Mutex); + #endif pair.first = app; pair.second = handle; m_Container.push_back(pair); @@ -65,7 +74,11 @@ public: if (app) { // mutex lock to ensure thread safety + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(m_Mutex); + #else + std::lock_guard mutexHolder(m_Mutex); + #endif AppHandleContainerType::iterator it = m_Container.begin(); while (it != m_Container.end()) { @@ -81,7 +94,11 @@ public: /** Release the library handles from applications already deleted */ void ReleaseUnusedHandle() { + #if ITK_VERSION_MAJOR < 5 itk::MutexLockHolder mutexHolder(m_Mutex); + #else + std::lock_guard mutexHolder(m_Mutex); + #endif AppHandleContainerType::iterator it; for (it = m_Container.begin() ; it != m_Container.end() ; ++it) { @@ -111,8 +128,12 @@ public: private: AppHandleContainerType m_Container; - + + #if ITK_VERSION_MAJOR < 5 itk::SimpleMutexLock m_Mutex; + #else + std::mutex m_Mutex; + #endif }; // static finalizer to close opened libraries static ApplicationPrivateRegistry m_ApplicationPrivateRegistryGlobal; @@ -244,27 +265,27 @@ ApplicationRegistry::CreateApplicationFaster(const std::string& name) #endif std::string otbAppPath = GetApplicationPath(); - std::vector pathList; + if (!otbAppPath.empty()) { - pathList = itksys::SystemTools::SplitString(otbAppPath,pathSeparator,false); - } - for (unsigned int i=0 ; i pathList; + if (!otbAppPath.empty()) { - pathList = itksys::SystemTools::SplitString(otbAppPath,pathSeparator,false); - } - for (unsigned int k=0 ; kLoad(pathList[k].c_str())) - { - continue; - } - for (unsigned int i = 0; i < dir->GetNumberOfFiles(); i++) + auto pathList = itksys::SystemTools::SplitString(otbAppPath,pathSeparator,false); + + for (unsigned int k=0 ; kGetFile(i); - std::string sfilename(filename); - std::string::size_type extPos = sfilename.rfind(appExtension); - std::string::size_type prefixPos = sfilename.find(appPrefix); - - // Check if current file is a shared lib with the right pattern - if (extPos + appExtension.size() == sfilename.size() && - prefixPos == 0) + itk::Directory::Pointer dir = itk::Directory::New(); + if (!dir->Load(pathList[k].c_str())) { - std::string name = sfilename.substr(appPrefix.size(),extPos-appPrefix.size()); - std::string fullpath = pathList[k]; - if (!fullpath.empty() && fullpath[fullpath.size() - 1] != sep) - { - fullpath.push_back(sep); - } - fullpath.append(sfilename); - appli = LoadApplicationFromPath(fullpath,name); - if (appli.IsNotNull()) + continue; + } + for (unsigned int i = 0; i < dir->GetNumberOfFiles(); i++) + { + const char *filename = dir->GetFile(i); + std::string sfilename(filename); + std::string::size_type extPos = sfilename.rfind(appExtension); + std::string::size_type prefixPos = sfilename.find(appPrefix); + + // Check if current file is a shared lib with the right pattern + if (extPos + appExtension.size() == sfilename.size() && + prefixPos == 0) { - appSet.insert(name); + std::string name = sfilename.substr(appPrefix.size(),extPos-appPrefix.size()); + std::string fullpath = pathList[k]; + if (!fullpath.empty() && fullpath[fullpath.size() - 1] != sep) + { + fullpath.push_back(sep); + } + fullpath.append(sfilename); + appli = LoadApplicationFromPath(fullpath,name); + if (appli.IsNotNull()) + { + appSet.insert(name); + } + appli = nullptr; } - appli = nullptr; } } } - if (useFactory) { std::list allobjects = itk::ObjectFactoryBase::CreateAllInstance("otbWrapperApplication"); diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index 728d349b0ca37684df34c2aeb86322eebd2afd45..976e7663825e40c97008ed9b1c25717dc580e106 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -497,7 +497,7 @@ bool CommandLineLauncher::CheckOutputPathsValidity(const std::string & paramKey) type == ParameterType_OutputFilename) { std::string filename = m_Application->GetParameterString(paramKey); - itksys::String path = itksys::SystemTools::GetFilenamePath(filename); + auto path = itksys::SystemTools::GetFilenamePath(filename); if (path!="" && !itksys::SystemTools::FileIsDirectory(path)) { std::cerr <<"ERROR: Directory doesn't exist : "<< path << std::endl; diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineParser.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineParser.cxx index 4626907639219ca379c5818ac0e5f97323c13c45..56529cdc60d802edcaa09b85a5ebfcd865239589 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineParser.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineParser.cxx @@ -153,8 +153,7 @@ CommandLineParser::GetPaths( std::vector & paths, const std::string if( tempModPath.size() > 0 ) { - std::vector pathAttribut = itksys::SystemTools::SplitString(tempModPath, ' ', false); - + auto pathAttribut = itksys::SystemTools::SplitString(tempModPath, ' ', false); // Remove " " string element for(unsigned int i=0; i spaceSplitExp = itksys::SystemTools::SplitString(exp, ' ', false); + auto spaceSplitExp = itksys::SystemTools::SplitString(exp, ' ', false); // if the chain is " module", SplitString will return: [ ], [module] for(unsigned int i=0; i 0 ) { - std::vector spaceSplit = itksys::SystemTools::SplitString(tempModKey.substr(0, tempModKey.size()), ' ', false); + auto spaceSplit = itksys::SystemTools::SplitString(tempModKey.substr(0, tempModKey.size()), ' ', false); // Remove " " string element for(unsigned int i=0; i