Skip to content
Snippets Groups Projects
Commit 381a994a authored by Antoine Regimbeau's avatar Antoine Regimbeau
Browse files

REFAC: refac defaultconvertpixel implementation with inheritance from itk

parent 68e2e745
No related branches found
No related tags found
1 merge request!12Complex image integration
...@@ -19,13 +19,25 @@ ...@@ -19,13 +19,25 @@
#define otbDefaultConvertNewImp_h #define otbDefaultConvertNewImp_h
#include "itkDefaultConvertPixelTraits.h" #include "itkDefaultConvertPixelTraits.h"
#include "itkRGBPixel.h"
// #include "itkOffset.h"
// #include "itkVector.h"
// #include "itkMatrix.h"
// #include "itkVariableLengthVector.h"
// #include "itkVariableSizeMatrix.h"
namespace otb namespace otb
{ {
template < typename PixelType> template < typename PixelType>
class DefaultConvertPixelTraitsTest : public itk::DefaultConvertPixelTraits < 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 > template < typename T >
...@@ -33,10 +45,48 @@ class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::Default ...@@ -33,10 +45,48 @@ class DefaultConvertPixelTraitsTest < std::complex < T > > : public itk::Default
{ {
public: public:
typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass; typedef itk::DefaultConvertPixelTraits < std::complex < T > > SuperClass;
static typename SuperClass::TargetType GetNthComponent ( int , const typename SuperClass::TargetType & pixel ) 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; 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 } // end namespace
#endif #endif
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "itkExceptionObject.h" #include "itkExceptionObject.h"
#include "itkImageRegion.h" #include "itkImageRegion.h"
#include "otbDefaultConvertPixelTraits.h" #include "otbDefaultConvertNewImpl.h"
#include "otbImageKeywordlist.h" #include "otbImageKeywordlist.h"
#include "otbExtendedFilenameToReaderOptions.h" #include "otbExtendedFilenameToReaderOptions.h"
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
* \ingroup OTBImageIO * \ingroup OTBImageIO
*/ */
template <class TOutputImage, template <class TOutputImage,
class ConvertPixelTraits=DefaultConvertPixelTraits< class ConvertPixelTraits=DefaultConvertPixelTraitsTest<
typename TOutputImage::IOPixelType > > typename TOutputImage::IOPixelType > >
class ITK_EXPORT ImageFileReader : public itk::ImageSource<TOutputImage> class ITK_EXPORT ImageFileReader : public itk::ImageSource<TOutputImage>
{ {
......
...@@ -179,8 +179,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits> ...@@ -179,8 +179,8 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
this->m_ImageIO->SetIORegion(ioRegion); this->m_ImageIO->SetIORegion(ioRegion);
typedef otb::DefaultConvertPixelTraits<typename TOutputImage::IOPixelType> ConvertIOPixelTraits; typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::IOPixelType> ConvertIOPixelTraits;
typedef otb::DefaultConvertPixelTraits<typename TOutputImage::PixelType> ConvertOutputPixelTraits; typedef otb::DefaultConvertPixelTraitsTest<typename TOutputImage::PixelType> ConvertOutputPixelTraits;
if (this->m_ImageIO->GetComponentTypeInfo() if (this->m_ImageIO->GetComponentTypeInfo()
== typeid(typename ConvertOutputPixelTraits::ComponentType) == typeid(typename ConvertOutputPixelTraits::ComponentType)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment