22 #ifndef otbImageIOBase_h
23 #define otbImageIOBase_h
26 #include "itkLightProcessObject.h"
27 #include "itkIndent.h"
28 #include "itkImageIORegion.h"
29 #include "vnl/vnl_vector.h"
35 #include "OTBImageBaseExport.h"
69 class OTBImageBase_EXPORT
ImageIOBase :
public itk::LightProcessObject
81 itkSetStringMacro(FileName);
82 itkGetStringMacro(FileName);
122 typedef enum { UNKNOWNCOMPONENTTYPE, UCHAR, CHAR,
USHORT, SHORT, UINT, INT, ULONG, LONG, FLOAT, DOUBLE, CSHORT, CINT, CFLOAT, CDOUBLE } IOComponentType;
127 void SetNumberOfDimensions(
unsigned int);
128 itkGetConstMacro(NumberOfDimensions,
unsigned int);
134 virtual void SetDimensions(
unsigned int i,
unsigned int dim);
137 return m_Dimensions[i];
143 virtual void SetOrigin(
unsigned int i,
double origin);
152 virtual void SetSpacing(
unsigned int i,
double spacing);
161 virtual void SetDirection(
unsigned int i, std::vector<double>& direction);
162 virtual void SetDirection(
unsigned int i, vnl_vector<double>& direction);
165 return m_Direction[i];
171 virtual std::vector<double> GetDefaultDirection(
unsigned int i)
const;
179 itkSetMacro(IORegion, itk::ImageIORegion);
180 itkGetConstReferenceMacro(IORegion, itk::ImageIORegion);
188 itkSetEnumMacro(PixelType, IOPixelType);
189 itkGetEnumMacro(PixelType, IOPixelType);
198 virtual bool SetPixelTypeInfo(
const std::type_info& ptype);
202 itkSetEnumMacro(ComponentType, IOComponentType);
203 itkGetEnumMacro(ComponentType, IOComponentType);
204 virtual const std::type_info& GetComponentTypeInfo()
const;
211 itkSetMacro(NumberOfComponents,
unsigned int);
212 itkGetConstReferenceMacro(NumberOfComponents,
unsigned int);
216 itkSetMacro(UseCompression,
bool);
217 itkGetConstMacro(UseCompression,
bool);
218 itkBooleanMacro(UseCompression);
222 itkSetMacro(UseStreamedReading,
bool);
223 itkGetConstMacro(UseStreamedReading,
bool);
224 itkBooleanMacro(UseStreamedReading);
228 itkSetMacro(UseStreamedWriting,
bool);
229 itkGetConstMacro(UseStreamedWriting,
bool);
230 itkBooleanMacro(UseStreamedWriting);
236 static std::string GetComponentTypeAsString(IOComponentType);
240 static std::string GetPixelTypeAsString(IOPixelType);
244 typedef enum { ASCII, Binary, TypeNotApplicable } FileType;
248 typedef enum { BigEndian, LittleEndian, OrderNotApplicable } ByteOrder;
252 itkSetEnumMacro(FileType, FileType);
253 itkGetEnumMacro(FileType, FileType);
256 this->SetFileType(ASCII);
260 this->SetFileType(Binary);
275 itkSetEnumMacro(ByteOrder, ByteOrder);
276 itkGetEnumMacro(ByteOrder, ByteOrder);
279 this->SetByteOrder(BigEndian);
283 this->SetByteOrder(LittleEndian);
289 static std::string GetFileTypeAsString(FileType);
293 static std::string GetByteOrderAsString(ByteOrder);
307 virtual SizeType GetPixelStride()
const;
310 SizeType GetImageSizeInPixels()
const;
313 SizeType GetImageSizeInBytes()
const;
317 SizeType GetImageSizeInComponents()
const;
324 virtual unsigned int GetComponentSize()
const;
328 virtual unsigned int GetOverviewsCount() = 0;
332 virtual std::vector<std::string> GetOverviewsInfo() = 0;
336 virtual void SetOutputImagePixelType(
bool isComplexInternalPixelType,
bool isVectorImage) = 0;
342 virtual bool CanReadFile(
const char*) = 0;
353 virtual void ReadImageInformation() = 0;
356 virtual void Read(
void* buffer) = 0;
363 virtual bool CanWriteFile(
const char*) = 0;
377 virtual void WriteImageInformation() = 0;
382 virtual void Write(
const void* buffer) = 0;
407 virtual itk::ImageIORegion GenerateStreamableReadRegionFromRequestedRegion(
const itk::ImageIORegion& requested)
const;
424 virtual unsigned int GetActualNumberOfSplitsForWriting(
unsigned int numberOfRequestedSplits,
const itk::ImageIORegion& pasteRegion,
425 const itk::ImageIORegion& largestPossibleRegion);
433 virtual itk::ImageIORegion GetSplitRegionForWriting(
unsigned int ithPiece,
unsigned int numberOfActualSplits,
const itk::ImageIORegion& pasteRegion,
434 const itk::ImageIORegion& largestPossibleRegion);
456 void DoMapBuffer(
void* buffer,
size_t numberOfPixels, std::vector<unsigned int>& bandList);
459 itkGetConstReferenceMacro(AttachedFileNames, std::vector<std::string>);
468 void PrintSelf(std::ostream& os, itk::Indent indent)
const override;
525 virtual void Reset(
const bool freeDynamic =
true);
528 void Resize(
const unsigned int numDimensions,
const unsigned int* dimensions);
532 virtual unsigned int GetPixelSize()
const;
540 void ComputeStrides();
544 SizeType GetComponentStride()
const;
555 void WriteBufferAsASCII(std::ostream& os,
const void* buffer,
IOComponentType ctype,
SizeType numberOfBytesToWrite);
561 bool ReadBufferAsBinary(std::istream& os,
void* buffer,
SizeType numberOfBytesToBeRead);
565 void AddSupportedReadExtension(
const char* extension);
568 void AddSupportedWriteExtension(
const char* extension);
572 virtual unsigned int GetActualNumberOfSplitsForWritingCanStreamWrite(
unsigned int numberOfRequestedSplits,
const itk::ImageIORegion& pasteRegion)
const;
576 virtual itk::ImageIORegion GetSplitRegionForWritingCanStreamWrite(
unsigned int ithPiece,
unsigned int numberOfActualSplits,
577 const itk::ImageIORegion& pasteRegion)
const;
592 void operator=(
const Self&) =
delete;
600 #endif // otbImageIOBase_h