diff --git a/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..bd084e77ff085d7c93eb9278805a7163a56e0f2a --- /dev/null +++ b/Modules/Core/ImageBase/include/otbDefaultConvertNewImpl.h @@ -0,0 +1,92 @@ +/*========================================================================= + * + * 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 otbDefaultConvertNewImp_h +#define otbDefaultConvertNewImp_h + +#include "itkDefaultConvertPixelTraits.h" +#include "itkRGBPixel.h" + +// #include "itkOffset.h" +// #include "itkVector.h" +// #include "itkMatrix.h" +// #include "itkVariableLengthVector.h" +// #include "itkVariableSizeMatrix.h" + +namespace otb +{ +template < typename PixelType> +class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > +{ +public: + typedef PixelType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } +}; + +template < typename T > +class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > +{ +public: + typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; + typedef typename SuperClass::TargetType TargetType; + static void SetNthComponent(int , TargetType & pixel, const TargetType& v) + { + pixel = v; + } + static TargetType GetNthComponent ( int , const TargetType & pixel ) + { + return pixel; + } +}; + +// template <> +// class DefaultConvertPixelTraitsTest < itk::RGBPixel < short int > > +// : public itk::DefaultConvertPixelTraits < itk::FixedArray < short int > > +// { +// public: +// typedef itk::DefaultConvertPixelTraits < itk::RGBPixel < short int > > SuperClass; +// typedef itk::RGBPixel < short int > TargetType; +// static void SetNthComponent(int , TargetType & pixel, const TargetType & v) +// { +// pixel = v; +// } +// }; + +#define OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type) \ +template < typename TComponentType , unsigned VDimension > \ +class DefaultConvertPixelTraitsTest < type < TComponentType , VDimension > > \ +: public itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > \ +{ \ +public: \ + typedef itk::DefaultConvertPixelTraits < type < TComponentType , VDimension > > SuperClass;\ + typedef typename SuperClass::TargetType TargetType; \ + static void SetNthComponent(int , TargetType & pixel, const TargetType & v) \ + { \ + pixel = v; \ + } \ +} \ + +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Vector); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::CovariantVector); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::Point); +OTB_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(itk::FixedArray); + +} // end namespace +#endif diff --git a/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h b/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h deleted file mode 100644 index 44e9b17a598d6807aa354a1cbf5f6a0cd8585239..0000000000000000000000000000000000000000 --- a/Modules/Filtering/ImageManipulation/include/otbDefaultConvertNewImpl.h +++ /dev/null @@ -1,42 +0,0 @@ -/*========================================================================= - * - * 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 otbDefaultConvertNewImp_h -#define otbDefaultConvertNewImp_h - -#include "itkDefaultConvertPixelTraits.h" - -namespace otb -{ -template < typename PixelType> -class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < PixelType > -{ - -}; - -template < typename T > -class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::DefaultConvertPixelTraits < std::complex < T > > -{ -public: - typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; - static typename SuperClass::TargetType GetNthComponent ( int , const typename SuperClass::TargetType & pixel ) - { - return pixel; - } -}; -} // end namespace -#endif diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.h b/Modules/IO/ImageIO/include/otbImageFileReader.h index 631f9d7dc27fdda1020a734086e71b95607f7786..8843e4bb2bd7e64549a7557953599a8cb0129eec 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.h +++ b/Modules/IO/ImageIO/include/otbImageFileReader.h @@ -33,7 +33,7 @@ #include "itkExceptionObject.h" #include "itkImageRegion.h" -#include "otbDefaultConvertPixelTraits.h" +#include "otbDefaultConvertNewImpl.h" #include "otbImageKeywordlist.h" #include "otbExtendedFilenameToReaderOptions.h" @@ -86,7 +86,7 @@ public: * \ingroup OTBImageIO */ template <class TOutputImage, - class ConvertPixelTraits=DefaultConvertPixelTraits< + class ConvertPixelTraits=DefaultConvertPixelTraitsTest< typename TOutputImage::IOPixelType > > class ITK_EXPORT ImageFileReader : public itk::ImageSource<TOutputImage> { diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx index 98a37bf87b51b5caade4258ab231a45b1f39c87a..1c67d82e002867612c1fc0768e0a268e6b3d1025 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.txx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx @@ -179,8 +179,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> this->m_ImageIO->SetIORegion(ioRegion); - typedef otb::DefaultConvertPixelTraits<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; - typedef otb::DefaultConvertPixelTraits<typename TOutputImage::PixelType> ConvertOutputPixelTraits; + typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; + typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::PixelType> ConvertOutputPixelTraits; if (this->m_ImageIO->GetComponentTypeInfo() == typeid(typename ConvertOutputPixelTraits::ComponentType)