Public Member Functions | Protected Member Functions | Private Attributes

creaImageIO::VtkImageReader Class Reference
[Image I/O classes]

Concrete image reader based on a vtkImageReader2. More...

#include <creaImageIOVtkImageReader.h>

Inheritance diagram for creaImageIO::VtkImageReader:
Inheritance graph
[legend]
Collaboration diagram for creaImageIO::VtkImageReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 VtkImageReader (vtkImageReader2 *reader, const std::string &name="", const std::string &extensions="")
virtual ~VtkImageReader ()
virtual void PushBackExtensions (std::vector< std::string > &)
 Add file extensions read by the reader.
virtual bool CanRead (const std::string &filename)
 Test if file is read by this reader.
virtual vtkImageData * ReadImage (const std::string &filename)
 return for a file a 2D VTkImage
virtual void ReadAttributes (const std::string &filename, tree::AttributeMapType &attr)
 Read the attributes for a file.
virtual void getAttributes (const std::string filename, std::map< std::string, std::string > &infos, std::vector< std::string > i_attr)
 Another function to read attributes for a file.
const std::string & GetName () const
 Get the reader's name.

Protected Member Functions

void SetName (const std::string &s)
 Set the reader's name.

Private Attributes

vtkImageReader2 * mReader
std::string mExtensions

Detailed Description

Concrete image reader based on a vtkImageReader2.

Definition at line 20 of file creaImageIOVtkImageReader.h.


Constructor & Destructor Documentation

creaImageIO::VtkImageReader::VtkImageReader ( vtkImageReader2 *  reader,
const std::string &  name = "",
const std::string &  extensions = "" 
)

Definition at line 8 of file creaImageIOVtkImageReader.cpp.

References creaImageIO::AbstractImageReader::GetName(), GimmickDebugMessage, mReader, and creaImageIO::AbstractImageReader::SetName().

    : mReader(r), mExtensions(extensions)
  {
    if (name.size() == 0) 
      {
                  const char *test =mReader->GetDescriptiveName();
                  if(test != "")
                  {
                        SetName ( "toto");// mReader->GetDescriptiveName());
                  }
      }
    else 
      {
        SetName ( name );
      }
    GimmickDebugMessage(5,"Constructing vtkImageReader : "<<GetName()
                        <<std::endl);
      
  }

Here is the call graph for this function:

creaImageIO::VtkImageReader::~VtkImageReader (  )  [virtual]

Definition at line 32 of file creaImageIOVtkImageReader.cpp.

References mReader.

  {

    mReader->Delete();
  }


Member Function Documentation

bool creaImageIO::VtkImageReader::CanRead ( const std::string &  filename  )  [virtual]

Test if file is read by this reader.

Reimplemented from creaImageIO::AbstractImageReader.

Definition at line 40 of file creaImageIOVtkImageReader.cpp.

References mReader.

  { 

    return (mReader->CanReadFile(filename.c_str())!=0);
/*        if(filename != "")
          {
                return (mReader->CanReadFile(filename.c_str())!=0);
          }
          else
          {
                  return false;
          }*/
  }

void creaImageIO::VtkImageReader::getAttributes ( const std::string  filename,
std::map< std::string, std::string > &  infos,
std::vector< std::string >  i_attr 
) [virtual]

Another function to read attributes for a file.

Reimplemented from creaImageIO::AbstractImageReader.

Definition at line 54 of file creaImageIOVtkImageReader.cpp.

   {
   }

const std::string& creaImageIO::AbstractImageReader::GetName (  )  const [inline, inherited]

Get the reader's name.

Definition at line 16 of file creaImageIOAbstractImageReader.h.

Referenced by VtkImageReader().

{

Here is the caller graph for this function:

void creaImageIO::VtkImageReader::PushBackExtensions ( std::vector< std::string > &  v  )  [virtual]

Add file extensions read by the reader.

Reimplemented from creaImageIO::AbstractImageReader.

Definition at line 103 of file creaImageIOVtkImageReader.cpp.

References mExtensions, mReader, and creaImageIO::SplitExtensionsString().

  {
    std::string ext = mExtensions;
    if (ext.size()==0) ext = mReader->GetFileExtensions ();
    
    SplitExtensionsString(ext," ",v);
  }

Here is the call graph for this function:

virtual void creaImageIO::VtkImageReader::ReadAttributes ( const std::string &  filename,
tree::AttributeMapType attr 
) [virtual]

Read the attributes for a file.

Reimplemented from creaImageIO::AbstractImageReader.

vtkImageData * creaImageIO::VtkImageReader::ReadImage ( const std::string &  filename  )  [virtual]

return for a file a 2D VTkImage

Reimplemented from creaImageIO::AbstractImageReader.

Definition at line 59 of file creaImageIOVtkImageReader.cpp.

References mReader.

  {
    vtkImageData* im = 0;
    try
      {
        mReader->SetFileName(filename.c_str());
        mReader->Update();
        im = vtkImageData::New();
        im->ShallowCopy(mReader->GetOutput());
      }
    catch (...)
      {
        if (im!=0) im->Delete();
        im = 0;
      }
    return im;
  }

void creaImageIO::AbstractImageReader::SetName ( const std::string &  s  )  [inline, protected, inherited]

Set the reader's name.

Definition at line 36 of file creaImageIOAbstractImageReader.h.

Referenced by creaImageIO::DicomImageReader::DicomImageReader(), creaImageIO::UltrasonixImageReader::UltrasonixImageReader(), and VtkImageReader().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 45 of file creaImageIOVtkImageReader.h.

Referenced by PushBackExtensions().

vtkImageReader2* creaImageIO::VtkImageReader::mReader [private]

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