ITK  4.1.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions
itk::StreamingImageIOBase Class Reference

#include <itkStreamingImageIOBase.h>

+ Inheritance diagram for itk::StreamingImageIOBase:
+ Collaboration diagram for itk::StreamingImageIOBase:

List of all members.

Public Types

typedef SmartPointer< SelfPointer
typedef StreamingImageIOBase Self
typedef ImageIOBase Superclass

Public Member Functions

virtual bool CanStreamRead (void)
virtual bool CanStreamWrite (void)
virtual ImageIORegion GenerateStreamableReadRegionFromRequestedRegion (const ImageIORegion &requested) const
virtual unsigned int GetActualNumberOfSplitsForWriting (unsigned int numberOfRequestedSplits, const ImageIORegion &pasteRegion, const ImageIORegion &largestPossibleRegion)
virtual const char * GetNameOfClass () const

Protected Member Functions

virtual SizeType GetDataPosition (void) const
virtual SizeType GetHeaderSize (void) const =0
virtual void OpenFileForReading (std::ifstream &os, const char *filename)
virtual void OpenFileForWriting (std::ofstream &os, const char *filename, bool truncate)
virtual void PrintSelf (std::ostream &os, Indent indent) const
virtual bool ReadBufferAsBinary (std::istream &is, void *buffer, SizeType num)
virtual bool RequestedToStream (void) const
 StreamingImageIOBase ()
virtual bool StreamReadBufferAsBinary (std::istream &os, void *buffer)
virtual bool StreamWriteBufferAsBinary (std::ostream &os, const void *buffer)
virtual bool WriteBufferAsBinary (std::ostream &is, const void *buffer, SizeType num)

Private Member Functions

void operator= (const Self &)
 StreamingImageIOBase (const Self &)

Detailed Description

A base class for specific ImageIO file formats which support streaming.

This class overloads the methods needed to enable streaming. These methods are utilized by the ImageFileReader and ImageFileWriter. The implementation supports streaming of an arbitrary sized region as well as pasting to new or existing file ( of the same name, size, and pixel type ).

See also:
CanStreamWrite CanStreamRead GenerateStreamableReadRegionFromRequestedRegion GetActualNumberOfSplitsForWriting

Additionaly low level IO methods are provided to read and write an IORegion from a file.

See also:
StreamReadBufferAsBinary StreamWriteBufferAsBinary

This implementation was taken fron the Insight Joural: http://hdl.handle.net/10380/3171

See also:
itk::ImageFileReader itk::ImageFileWriter

Definition at line 51 of file itkStreamingImageIOBase.h.


Member Typedef Documentation

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 57 of file itkStreamingImageIOBase.h.

Standard class typedefs.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 55 of file itkStreamingImageIOBase.h.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

Definition at line 56 of file itkStreamingImageIOBase.h.


Constructor & Destructor Documentation


Member Function Documentation

virtual bool itk::StreamingImageIOBase::CanStreamRead ( void  ) [virtual]

Determine if the ImageIO can stream reading from the current settings. Default is false. If this is queried after the header of the file has been read then it will indicate if that file can be streamed

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::VTKImageIO.

virtual bool itk::StreamingImageIOBase::CanStreamWrite ( void  ) [virtual]

Determine if the ImageIO can stream write from the current settings.

There are two types of non exclusive streaming: pasteing subregions, and iterative

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::JPEG2000ImageIO, and itk::VTKImageIO.

Method for supporting streaming. Given a requested region, determine what could be the region that we can read from the file. This is called the streamable region, which will be equal or smaller than the LargestPossibleRegion (unless it was dimensionaly clipped) and greater or equal to the RequestedRegion

the resulting IORegion may be a greater dimensions the the requested IORegion, if the the derived class is unable to read the requested region. For example if the file has a size of [ 10, 10, 10] but the requested region is [10, 10] the return may be 3 dimensions.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::JPEG2000ImageIO.

virtual unsigned int itk::StreamingImageIOBase::GetActualNumberOfSplitsForWriting ( unsigned int  numberOfRequestedSplits,
const ImageIORegion pasteRegion,
const ImageIORegion largestPossibleRegion 
) [virtual]

Before this method is called all the configuration will be done, that is Streaming/PasteRegion/Compression/Filename etc If pasting is being used the number of requested splits is for that region not the largest. The derived ImageIO class should verify that the file is capable of being writen with this configuration. If pasted is enabled and is not support or does not work with the file, then an excepetion should be thrown.

The default implementation depends on CanStreamWrite. If false then 1 is returned (unless pasting is indicated), so that the whole file will be updated in one region. If true then its assumed that any arbitrary region can be writen to any file. So the users request will be respected. If a derived class has more restictive conditions then they should be checked

Reimplemented from itk::ImageIOBase.

virtual SizeType itk::StreamingImageIOBase::GetDataPosition ( void  ) const [inline, protected, virtual]

Returns the byte offset into the file where the data is located.

The default implementation is to return the header size.

Definition at line 152 of file itkStreamingImageIOBase.h.

virtual SizeType itk::StreamingImageIOBase::GetHeaderSize ( void  ) const [protected, pure virtual]

Returns the size of the header in the file.

Implemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

virtual const char* itk::StreamingImageIOBase::GetNameOfClass ( ) const [virtual]

Run-time type information (and related methods).

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::MRCImageIO, itk::VTKImageIO, and itk::JPEG2000ImageIO.

virtual void itk::StreamingImageIOBase::OpenFileForReading ( std::ifstream &  os,
const char *  filename 
) [protected, virtual]

Opens a file for reading and random access.

The stream is closed if it's already opened. If an error is encountered then an exception will be thrown.

virtual void itk::StreamingImageIOBase::OpenFileForWriting ( std::ofstream &  os,
const char *  filename,
bool  truncate 
) [protected, virtual]

Opens a file for writing and random access.

Parameters:
osis an ostream presumed to be opened for writing
filenameis the name of the file
truncateif true then the file is truncated

The stream is closed if it's already opened. If an error is encountered then an exception will be thrown.

void itk::StreamingImageIOBase::operator= ( const Self ) [private]

This method causes the filter to generate its output.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::VTKImageIO, itk::MRCImageIO, and itk::JPEG2000ImageIO.

virtual void itk::StreamingImageIOBase::PrintSelf ( std::ostream &  os,
Indent  indent 
) const [protected, virtual]

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from itk::ImageIOBase.

Reimplemented in itk::HDF5ImageIO, itk::JPEG2000ImageIO, itk::MRCImageIO, and itk::VTKImageIO.

virtual bool itk::StreamingImageIOBase::ReadBufferAsBinary ( std::istream &  is,
void *  buffer,
SizeType  num 
) [protected, virtual]

Reimplemented from super class to get around 2GB read/write limitation.

Todo:
Move this method to itk::ImageIOBase

Reimplemented from itk::ImageIOBase.

virtual bool itk::StreamingImageIOBase::RequestedToStream ( void  ) const [protected, virtual]

Returns true if GetIORegion is not the same size as the largest region give by GetNumberOfDimensions.

This compares the IORegion to the size of the image in the file. With out regaurd to the dimensions of either, if the images represent the same region then false is returned.

virtual bool itk::StreamingImageIOBase::StreamReadBufferAsBinary ( std::istream &  os,
void *  buffer 
) [protected, virtual]

Reads the set IORegion from os into buffer.

Parameters:
osis an istream presumed to be opened for reading in binary mode
bufferis pointer to an allocated block of memory suitable to hold the IORegion of the pixel type

This methods relies on GetDataPosition to determin where the data is located in the file. It uses m_IORegion to determin the requested region to read.

The files data is assumed to be unpadded and continuous in the file for the size of the image in the dimensions of the m_IORegion. This means that the image file could be broken into slices, but not blocks for this methods to be used.

virtual bool itk::StreamingImageIOBase::StreamWriteBufferAsBinary ( std::ostream &  os,
const void *  buffer 
) [protected, virtual]

Writes the set IORegion from buffer into os.

Parameters:
osis an ostream presumed to be opened for writing and reading
bufferis a pointer to the data in a continuous block for the region

This methods relies on GetDataPosition to determin where the data is located in the file. It usesy m_IORegion determin the requested region to written.

virtual bool itk::StreamingImageIOBase::WriteBufferAsBinary ( std::ostream &  is,
const void *  buffer,
SizeType  num 
) [protected, virtual]

Reimplemented from super class to get around 2GB read/write limitation.

Todo:
Move this methods to itk::ImageIOBase

The documentation for this class was generated from the following file: