Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

mitk::VtkSurfaceReader Class Reference
[IO Classes]

Reader to read surface files in vtk-format. More...

#include <mitkVtkSurfaceReader.h>

Inheritance diagram for mitk::VtkSurfaceReader:
Inheritance graph
[legend]
Collaboration diagram for mitk::VtkSurfaceReader:
Collaboration graph
[legend]

List of all members.

Public Types

typedef VtkSurfaceReader Self
typedef SurfaceSource Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void SetFileName (const char *_arg)
virtual const char * GetFileName () const
virtual void SetFilePrefix (const char *_arg)
virtual const char * GetFilePrefix () const
virtual void SetFilePattern (const char *_arg)
virtual const char * GetFilePattern () const

Static Public Member Functions

static Pointer New ()
static bool CanReadFile (const std::string filename, const std::string filePrefix, const std::string filePattern)

Protected Member Functions

virtual void GenerateData ()
 VtkSurfaceReader ()
 ~VtkSurfaceReader ()

Protected Attributes

std::string m_FileName
std::string m_FilePrefix
std::string m_FilePattern

Detailed Description

Reader to read surface files in vtk-format.

Definition at line 27 of file mitkVtkSurfaceReader.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::VtkSurfaceReader::ConstPointer

Definition at line 30 of file mitkVtkSurfaceReader.h.

typedef itk::SmartPointer<Self> mitk::VtkSurfaceReader::Pointer

Definition at line 30 of file mitkVtkSurfaceReader.h.

Definition at line 30 of file mitkVtkSurfaceReader.h.

Definition at line 30 of file mitkVtkSurfaceReader.h.


Constructor & Destructor Documentation

mitk::VtkSurfaceReader::VtkSurfaceReader (  ) [protected]

Definition at line 27 of file mitkVtkSurfaceReader.cpp.

: m_FileName("")
{
}
mitk::VtkSurfaceReader::~VtkSurfaceReader (  ) [protected]

Definition at line 32 of file mitkVtkSurfaceReader.cpp.

{
}

Member Function Documentation

bool mitk::VtkSurfaceReader::CanReadFile ( const std::string  filename,
const std::string  filePrefix,
const std::string  filePattern 
) [static]

Definition at line 97 of file mitkVtkSurfaceReader.cpp.

{
  // First check the extension
  if(  filename == "" )
    return false;

  std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename);
  ext = itksys::SystemTools::LowerCase(ext);
  if (ext == ".vtk")
  {
    vtkDataReader *chooser=vtkDataReader::New();
    chooser->SetFileName(filename.c_str() );
    if(!chooser->IsFilePolyData())
    {
      chooser->Delete();
      return false;
    }
    chooser->Delete();
  }
#if ((VTK_MAJOR_VERSION > 4) || ((VTK_MAJOR_VERSION==4) && (VTK_MINOR_VERSION>=4) ))
  else
    if (ext == ".vtp")
    {
      vtkXMLPolyDataReader *chooser=vtkXMLPolyDataReader::New();
      if(!chooser->CanReadFile(filename.c_str()))
      {
        chooser->Delete();
        return false;
      }
      chooser->Delete();
    }
#endif
    else
      return false;

  return true;
}
void mitk::VtkSurfaceReader::GenerateData (  ) [protected, virtual]

We create a Generic Reader to test de .vtk/

PolyData/

Definition at line 36 of file mitkVtkSurfaceReader.cpp.

References MITK_INFO.

{
  if( m_FileName != "")
  {
    bool success = false;
    MITK_INFO << "Loading " << m_FileName << " as vtk" << std::endl;

    std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName);
    ext = itksys::SystemTools::LowerCase(ext);
    if (ext == ".vtk")
    {
      vtkDataReader *chooser=vtkDataReader::New();
      chooser->SetFileName(m_FileName.c_str() );
      if( chooser->IsFilePolyData())
      {
        itkDebugMacro( << "PolyData" );
        vtkPolyDataReader *reader = vtkPolyDataReader::New();
        reader->SetFileName( m_FileName.c_str() );
        reader->Update();

        if ( reader->GetOutput() != NULL )
        {
          mitk::Surface::Pointer output = this->GetOutput();
          output->SetVtkPolyData( reader->GetOutput() );
          success = true;
        }
        reader->Delete();
      }
      chooser->Delete();
    }
#if ((VTK_MAJOR_VERSION > 4) || ((VTK_MAJOR_VERSION==4) && (VTK_MINOR_VERSION>=4) ))
    else
    if (ext == ".vtp")
    {
      vtkXMLPolyDataReader *reader=vtkXMLPolyDataReader::New();
      if( reader->CanReadFile(m_FileName.c_str()) )
      {
        itkDebugMacro( << "XMLPolyData" );
        reader->SetFileName( m_FileName.c_str() );
        reader->Update();

        if ( reader->GetOutput() != NULL )
        {
          mitk::Surface::Pointer output = this->GetOutput();
          output->SetVtkPolyData( reader->GetOutput() );
          success = true;
        }
        reader->Delete();
      }
    }
#endif
    if(!success)
    {
      itkWarningMacro( << " ... sorry, this .vtk format is not supported yet." );
    }
  }
}
virtual const char* mitk::VtkSurfaceReader::GetClassName (  ) const [virtual]
virtual const char* mitk::VtkSurfaceReader::GetFileName (  ) const [virtual]
virtual const char* mitk::VtkSurfaceReader::GetFilePattern (  ) const [virtual]
virtual const char* mitk::VtkSurfaceReader::GetFilePrefix (  ) const [virtual]
static Pointer mitk::VtkSurfaceReader::New (  ) [static]

Method for creation through the object factory.

Reimplemented from mitk::SurfaceSource.

virtual void mitk::VtkSurfaceReader::SetFileName ( const char *  _arg ) [virtual]
virtual void mitk::VtkSurfaceReader::SetFilePattern ( const char *  _arg ) [virtual]
virtual void mitk::VtkSurfaceReader::SetFilePrefix ( const char *  _arg ) [virtual]

Member Data Documentation

std::string mitk::VtkSurfaceReader::m_FileName [protected]

Definition at line 53 of file mitkVtkSurfaceReader.h.

std::string mitk::VtkSurfaceReader::m_FilePattern [protected]

Definition at line 53 of file mitkVtkSurfaceReader.h.

std::string mitk::VtkSurfaceReader::m_FilePrefix [protected]

Definition at line 53 of file mitkVtkSurfaceReader.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines