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

mitk::UnstructuredGridVtkWriter< VTKWRITER > Class Template Reference
[Process Classes]

VTK-based writer for mitk::UnstructuredGrid. More...

#include <mitkUnstructuredGridVtkWriter.h>

Inheritance diagram for mitk::UnstructuredGridVtkWriter< VTKWRITER >:
Inheritance graph
[legend]
Collaboration diagram for mitk::UnstructuredGridVtkWriter< VTKWRITER >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef UnstructuredGridVtkWriter Self
typedef mitk::FileWriter Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer
typedef VTKWRITER VtkWriterType

Public Member Functions

virtual const char * GetClassName () const
virtual void Write ()
virtual void Update ()
virtual void SetFileName (const char *_arg)
virtual const char * GetFileName () const
virtual void SetExtension (const char *_arg)
 Explicitly set the extension to be added to the filename.
virtual const char * GetExtension () const
 Get the extension to be added to the filename.
void SetDefaultExtension ()
 Set the extension to be added to the filename to the default.
virtual void SetFilePrefix (const char *_arg)
virtual const char * GetFilePrefix () const
virtual void SetFilePattern (const char *_arg)
virtual const char * GetFilePattern () const
void SetInput (mitk::UnstructuredGrid *input)
const mitk::UnstructuredGridGetInput ()
virtual std::vector< std::string > GetPossibleFileExtensions ()
 Return the possible file extensions for the data type associated with the writer.
virtual std::string GetFileExtension ()
 Return the extension to be added to the filename.
virtual bool CanWriteDataType (DataNode *)
 Check if the Writer can write the Content of the DataTreenode.
virtual std::string GetWritenMIMEType ()
 Return the MimeType of the saved File.
virtual void SetInput (DataNode *)
 Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function.
VtkWriterTypeGetVtkWriter ()
template<>
void SetDefaultExtension ()
template<>
void SetDefaultExtension ()
template<>
std::vector< std::string > GetPossibleFileExtensions ()
 Return the possible file extensions for the data type associated with the writer.
template<>
std::vector< std::string > GetPossibleFileExtensions ()
 Return the possible file extensions for the data type associated with the writer.

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 UnstructuredGridVtkWriter ()
virtual ~UnstructuredGridVtkWriter ()
virtual void GenerateData ()
void ExecuteWrite (VtkWriterType *m_VtkWriter, vtkTransformFilter *transformPointSet)
template<>
void ExecuteWrite (VtkWriterType *m_VtkWriter, vtkTransformFilter *transformPointSet)

Protected Attributes

std::string m_FileName
std::string m_FilePrefix
std::string m_FilePattern
std::string m_Extension
std::string m_MimeType
VtkWriterTypem_VtkWriter
bool m_WriterWriteHasReturnValue

Detailed Description

template<class VTKWRITER>
class mitk::UnstructuredGridVtkWriter< VTKWRITER >

VTK-based writer for mitk::UnstructuredGrid.

The mitk::UnstructuredGrid is written using the VTK-writer-type provided as the template argument. If the mitk::UnstructuredGrid contains multiple points of time, multiple files are written. The life-span (time-bounds) of each each point of time is included in the filename according to the following scheme: <filename>_S<timebounds[0]>E<timebounds[1]>_T<framenumber> (S=start, E=end, T=time). Writing of multiple files according to a given filename pattern is not yet supported.

Definition at line 49 of file mitkUnstructuredGridVtkWriter.h.


Member Typedef Documentation

template<class VTKWRITER>
typedef itk::SmartPointer<const Self> mitk::UnstructuredGridVtkWriter< VTKWRITER >::ConstPointer

Reimplemented from mitk::FileWriter.

Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
typedef itk::SmartPointer<Self> mitk::UnstructuredGridVtkWriter< VTKWRITER >::Pointer

Reimplemented from mitk::FileWriter.

Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
typedef UnstructuredGridVtkWriter mitk::UnstructuredGridVtkWriter< VTKWRITER >::Self

Reimplemented from mitk::FileWriter.

Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
typedef mitk::FileWriter mitk::UnstructuredGridVtkWriter< VTKWRITER >::Superclass

Reimplemented from mitk::FileWriter.

Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
typedef VTKWRITER mitk::UnstructuredGridVtkWriter< VTKWRITER >::VtkWriterType

Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.


Constructor & Destructor Documentation

template<class VTKWRITER >
mitk::UnstructuredGridVtkWriter< VTKWRITER >::UnstructuredGridVtkWriter (  ) [protected]

Constructor.

Definition at line 30 of file mitkUnstructuredGridVtkWriter.txx.

References mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_VtkWriter, mitk::UnstructuredGridVtkWriter< VTKWRITER >::New(), and mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetDefaultExtension().

: m_WriterWriteHasReturnValue( false )
{
  this->SetNumberOfRequiredInputs( 1 );
  
  m_VtkWriter = VtkWriterType::New();

  //enable to write ascii-formatted-file
  //m_VtkWriter->SetFileTypeToASCII();

  SetDefaultExtension(); // and information about the Writer's Write() method
}
template<class VTKWRITER >
mitk::UnstructuredGridVtkWriter< VTKWRITER >::~UnstructuredGridVtkWriter (  ) [protected, virtual]

Virtual destructor.

Definition at line 44 of file mitkUnstructuredGridVtkWriter.txx.

{
  m_VtkWriter->Delete();
}

Member Function Documentation

template<class VTKWRITER >
bool mitk::UnstructuredGridVtkWriter< VTKWRITER >::CanWriteDataType ( DataNode input ) [virtual]

Check if the Writer can write the Content of the DataTreenode.

Reimplemented from mitk::FileWriter.

Definition at line 168 of file mitkUnstructuredGridVtkWriter.txx.

References mitk::DataNode::GetData().

{
  if ( input )
  {
    mitk::BaseData* data = input->GetData();
    if ( data )
    {
       mitk::UnstructuredGrid::Pointer ug = dynamic_cast<mitk::UnstructuredGrid*>( data );
       if( ug.IsNotNull() )
       {
         SetDefaultExtension();
         return true;
       }
    }
  }
  return false;
}
template<class VTKWRITER >
void mitk::UnstructuredGridVtkWriter< VTKWRITER >::ExecuteWrite ( VtkWriterType m_VtkWriter,
vtkTransformFilter *  transformPointSet 
) [protected]

Definition at line 56 of file mitkUnstructuredGridVtkWriter.txx.

{
  struct stat fileStatus;
  time_t timeBefore=0;
  if (!stat(m_VtkWriter->GetFileName(),&fileStatus))
  {
  timeBefore = fileStatus.st_mtime;
  }
   if (!m_VtkWriter->Write())
  {
    itkExceptionMacro(<<"Error during surface writing.");
  }
  // check if file can be written because vtkWriter doesn't check that
  if (stat(m_VtkWriter->GetFileName(),&fileStatus)||(timeBefore==fileStatus.st_mtime))
  {
    itkExceptionMacro(<<"Error during surface writing: file could not be written");
  }
}
template<>
void mitk::UnstructuredGridVtkWriter< vtkXMLUnstructuredGridWriter >::ExecuteWrite ( VtkWriterType m_VtkWriter,
vtkTransformFilter *  transformPointSet 
) [protected]

Definition at line 38 of file mitkUnstructuredGridVtkWriter.cpp.

{
  if (!m_VtkWriter->Write())
  {
template<class VTKWRITER >
void mitk::UnstructuredGridVtkWriter< VTKWRITER >::GenerateData (  ) [protected, virtual]

Definition at line 76 of file mitkUnstructuredGridVtkWriter.txx.

References mitk::Geometry3D::GetTimeBounds(), mitk::Geometry3D::GetVtkTransform(), QuadProgPP::t(), and mitk::Geometry3D::TransferItkToVtkTransform().

{
  if ( m_FileName == "" )
  {
    itkWarningMacro( << "Sorry, filename has not been set!" );
    return ;
  }

  mitk::UnstructuredGrid::Pointer input = const_cast<mitk::UnstructuredGrid*>(this->GetInput());
  
  vtkTransformFilter* transformPointSet = vtkTransformFilter::New();
  vtkUnstructuredGrid * unstructuredGrid;
  Geometry3D* geometry;

  if(input->GetTimeSlicedGeometry()->GetTimeSteps()>1)
  {
    
    int t, timesteps;

    timesteps = input->GetTimeSlicedGeometry()->GetTimeSteps();
    for(t = 0; t < timesteps; ++t)
    {
      ::itk::OStringStream filename;
      geometry = input->GetGeometry(t);
      if(input->GetTimeSlicedGeometry()->IsValidTime(t))
      {
        const mitk::TimeBounds& timebounds = geometry->GetTimeBounds();
        filename <<  m_FileName.c_str() << "_S" << std::setprecision(0) << timebounds[0] << "_E" << std::setprecision(0) << timebounds[1] << "_T" << t << m_Extension;
      }
      else
      {
        itkWarningMacro(<<"Error on write: TimeSlicedGeometry invalid of unstructured grid " << filename << ".");
        filename <<  m_FileName.c_str() << "_T" << t << m_Extension;
      }
      geometry->TransferItkToVtkTransform();
      transformPointSet->SetInput(input->GetVtkUnstructuredGrid(t));
      transformPointSet->SetTransform(geometry->GetVtkTransform());
      transformPointSet->UpdateWholeExtent();
      unstructuredGrid = static_cast<vtkUnstructuredGrid*>(transformPointSet->GetOutput());
      
      m_VtkWriter->SetFileName(filename.str().c_str());
#if VTK_MAJOR_VERSION >= 5 
      m_VtkWriter->SetInput((vtkDataObject*)unstructuredGrid);
#else
      m_VtkWriter->SetInput(unstructuredGrid);
#endif
     
      ExecuteWrite( m_VtkWriter, transformPointSet );
    }
  }
  else
  {
    geometry = input->GetGeometry();
    geometry->TransferItkToVtkTransform();
    transformPointSet->SetInput(input->GetVtkUnstructuredGrid());
    transformPointSet->SetTransform(geometry->GetVtkTransform());
    transformPointSet->UpdateWholeExtent();
    unstructuredGrid = static_cast<vtkUnstructuredGrid*>(transformPointSet->GetOutput());
      
    m_VtkWriter->SetFileName(m_FileName.c_str());
#if VTK_MAJOR_VERSION >= 5 
    m_VtkWriter->SetInput((vtkDataObject*)unstructuredGrid);
#else
    m_VtkWriter->SetInput(unstructuredGrid);
#endif
    
    ExecuteWrite( m_VtkWriter, transformPointSet );
  }
  transformPointSet->Delete();
  m_MimeType = "image/ug";
}
template<class VTKWRITER>
virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetClassName (  ) const [virtual]

Reimplemented from mitk::FileWriter.

template<class VTKWRITER>
virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetExtension (  ) const [virtual]

Get the extension to be added to the filename.

Returns:
the extension to be added to the filename (e.g., ".vtk").
template<class VTKWRITER >
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFileExtension (  ) [virtual]

Return the extension to be added to the filename.

Reimplemented from mitk::FileWriter.

Definition at line 200 of file mitkUnstructuredGridVtkWriter.txx.

{
  return m_Extension;
}
template<class VTKWRITER>
virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFileName (  ) const [virtual]
Returns:
the name of the file to be written to disk.

Implements mitk::FileWriter.

template<class VTKWRITER>
virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFilePattern (  ) const [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class VTKWRITER>
virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFilePrefix (  ) const [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class VTKWRITER >
const mitk::UnstructuredGrid * mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetInput ( void   )
Returns:
the 0'th input object of the filter.

Definition at line 155 of file mitkUnstructuredGridVtkWriter.txx.

{
  if ( this->GetNumberOfInputs() < 1 )
  {
    return NULL;
  }
  else
  {
    return static_cast< const mitk::UnstructuredGrid * >( this->ProcessObject::GetInput( 0 ) );
  }
}
template<class VTKWRITER>
virtual std::vector<std::string> mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetPossibleFileExtensions (  ) [virtual]

Return the possible file extensions for the data type associated with the writer.

Implements mitk::FileWriter.

template<>
std::vector< std::string > mitk::UnstructuredGridVtkWriter< vtkUnstructuredGridWriter >::GetPossibleFileExtensions (  ) [virtual]

Return the possible file extensions for the data type associated with the writer.

Implements mitk::FileWriter.

Definition at line 48 of file mitkUnstructuredGridVtkWriter.cpp.

{
template<>
std::vector< std::string > mitk::UnstructuredGridVtkWriter< vtkXMLUnstructuredGridWriter >::GetPossibleFileExtensions (  ) [virtual]

Return the possible file extensions for the data type associated with the writer.

Implements mitk::FileWriter.

Definition at line 56 of file mitkUnstructuredGridVtkWriter.cpp.

{
template<class VTKWRITER>
VtkWriterType* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetVtkWriter (  ) [inline]
template<class VTKWRITER >
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetWritenMIMEType (  ) [virtual]

Return the MimeType of the saved File.

Reimplemented from mitk::FileWriter.

Definition at line 194 of file mitkUnstructuredGridVtkWriter.txx.

{
  return m_MimeType;
}
template<class VTKWRITER>
static Pointer mitk::UnstructuredGridVtkWriter< VTKWRITER >::New (  ) [static]
template<class VTKWRITER >
void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetDefaultExtension (  )

Set the extension to be added to the filename to the default.

Partial template specialization is used for some vtk-writer types to define the default extension.

Definition at line 50 of file mitkUnstructuredGridVtkWriter.txx.

Referenced by mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetDefaultExtension(), and mitk::UnstructuredGridVtkWriter< VTKWRITER >::UnstructuredGridVtkWriter().

{
  m_Extension = ".vtk";
}
template<>
void mitk::UnstructuredGridVtkWriter< vtkXMLUnstructuredGridWriter >::SetDefaultExtension (  )

Definition at line 31 of file mitkUnstructuredGridVtkWriter.cpp.

{
template<>
void mitk::UnstructuredGridVtkWriter< vtkUnstructuredGridWriter >::SetDefaultExtension (  )
template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetExtension ( const char *  _arg ) [virtual]

Explicitly set the extension to be added to the filename.

Parameters:
_argto be added to the filename, including a "." (e.g., ".vtk").

Partial template specialization is used for some vtk-writer types to set a default extension.

template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFileName ( const char *  _arg ) [virtual]

Sets the filename of the file to write.

Parameters:
_argthe name of the file to write.

Implements mitk::FileWriter.

Referenced by mitkUnstructuredGridVtkWriterTest().

template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFilePattern ( const char *  _arg ) [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFilePrefix ( const char *  _arg ) [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

template<class VTKWRITER >
void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetInput ( DataNode input ) [virtual]

Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function.

Reimplemented from mitk::FileWriter.

Definition at line 187 of file mitkUnstructuredGridVtkWriter.txx.

References mitk::DataNode::GetData().

{
  if( input && CanWriteDataType( input ) )
   SetInput( dynamic_cast<mitk::UnstructuredGrid*>( input->GetData() ) );
}
template<class VTKWRITER >
void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetInput ( mitk::UnstructuredGrid input )

Sets the 0'th input object for the filter.

Parameters:
inputthe first input for the filter.

Definition at line 149 of file mitkUnstructuredGridVtkWriter.txx.

Referenced by mitkUnstructuredGridVtkWriterTest().

{
  this->ProcessObject::SetNthInput( 0, ug );
}
template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::Update (  ) [inline, virtual]

Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.

Referenced by mitkUnstructuredGridVtkWriterTest().

template<class VTKWRITER>
virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::Write (  ) [inline, virtual]

Implements mitk::FileWriter.

Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.


Member Data Documentation

template<class VTKWRITER>
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_Extension [protected]

Definition at line 180 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FileName [protected]

Definition at line 174 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FilePattern [protected]

Definition at line 178 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FilePrefix [protected]

Definition at line 176 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_MimeType [protected]

Definition at line 182 of file mitkUnstructuredGridVtkWriter.h.

template<class VTKWRITER>
VtkWriterType* mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_VtkWriter [protected]
template<class VTKWRITER>
bool mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_WriterWriteHasReturnValue [protected]

Definition at line 186 of file mitkUnstructuredGridVtkWriter.h.


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