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

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

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

#include <mitkSurfaceVtkWriter.h>

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

List of all members.

Public Types

typedef SurfaceVtkWriter 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::Surface *input)
const mitk::SurfaceGetInput ()
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 ()
virtual std::vector< std::string > GetPossibleFileExtensions ()
 Return the possible file extensions for the data type associated with the writer.
template<>
void SetDefaultExtension ()
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.
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

 SurfaceVtkWriter ()
virtual ~SurfaceVtkWriter ()
virtual void GenerateData ()
void ExecuteWrite (VtkWriterType *vtkWriter)
template<>
void ExecuteWrite (VtkWriterType *vtkWriter)

Protected Attributes

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

Detailed Description

template<class VTKWRITER>
class mitk::SurfaceVtkWriter< VTKWRITER >

VTK-based writer for mitk::Surface.

The mitk::Surface is written using the VTK-writer-type provided as the template argument. If the mitk::Surface 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 51 of file mitkSurfaceVtkWriter.h.


Member Typedef Documentation

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

Reimplemented from mitk::FileWriter.

Definition at line 55 of file mitkSurfaceVtkWriter.h.

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

Reimplemented from mitk::FileWriter.

Definition at line 55 of file mitkSurfaceVtkWriter.h.

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

Reimplemented from mitk::FileWriter.

Definition at line 55 of file mitkSurfaceVtkWriter.h.

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

Reimplemented from mitk::FileWriter.

Definition at line 55 of file mitkSurfaceVtkWriter.h.

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

Definition at line 59 of file mitkSurfaceVtkWriter.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 31 of file mitkSurfaceVtkWriter.txx.

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

: m_WriterWriteHasReturnValue( false )
{
  this->SetNumberOfRequiredInputs( 1 );

  m_VtkWriter = vtkSmartPointer<VtkWriterType>::New();

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

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

Virtual destructor.

Definition at line 45 of file mitkSurfaceVtkWriter.txx.

{
}

Member Function Documentation

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

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

Reimplemented from mitk::FileWriter.

Definition at line 139 of file mitkSurfaceVtkWriter.txx.

References mitk::DataNode::GetData().

{
  if ( input )
  {
    BaseData* data = input->GetData();
    if ( data )
    {
      Surface::Pointer surface = dynamic_cast<Surface*>( data );
      if( surface.IsNotNull() )
      {
        SetDefaultExtension();
        return true;
      }
    }
  }
  return false;
}
template<class VTKWRITER >
void mitk::SurfaceVtkWriter< VTKWRITER >::ExecuteWrite ( VtkWriterType vtkWriter ) [protected]

Definition at line 56 of file mitkSurfaceVtkWriter.txx.

{
  if ( vtkWriter->Write() == 0 || vtkWriter->GetErrorCode() != 0 )
  {
    itkExceptionMacro(<<"Error during surface writing: " << vtkErrorCode::GetStringFromErrorCode(vtkWriter->GetErrorCode()) );
  }
}
template<>
void mitk::SurfaceVtkWriter< vtkXMLPolyDataWriter >::ExecuteWrite ( VtkWriterType vtkWriter ) [protected]

Definition at line 44 of file mitkSurfaceVtkWriter.cpp.

template<class VTKWRITER >
void mitk::SurfaceVtkWriter< VTKWRITER >::GenerateData (  ) [protected, virtual]

Definition at line 65 of file mitkSurfaceVtkWriter.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::Surface::Pointer input = const_cast<mitk::Surface*>(this->GetInput());

  vtkSmartPointer<vtkTransformPolyDataFilter> transformPolyData = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
  vtkPolyData * polyData;
  Geometry3D* geometry;

  unsigned int t, timesteps = input->GetTimeSlicedGeometry()->GetTimeSteps();

  for(t = 0; t < timesteps; ++t)
  {
    // surfaces do not have to exist in all timeteps; therefor, only write valid surfaces
    if( input->GetVtkPolyData(t) == NULL ) continue;

    ::itk::OStringStream filename;
    geometry = input->GetGeometry(t);
    if ( timesteps > 1 )
    {
      if(input->GetTimeSlicedGeometry()->IsValidTime(t))
      {
        const 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 surface " << filename << ".");
        filename <<  m_FileName.c_str() << "_T" << t << m_Extension;
      }
      m_VtkWriter->SetFileName(filename.str().c_str());
    }
    else 
      m_VtkWriter->SetFileName(m_FileName.c_str());

    geometry->TransferItkToVtkTransform();
    transformPolyData->SetInput(input->GetVtkPolyData(t));
    transformPolyData->SetTransform(geometry->GetVtkTransform());
    transformPolyData->UpdateWholeExtent();
    polyData = transformPolyData->GetOutput();

    m_VtkWriter->SetInput(polyData);

    ExecuteWrite( m_VtkWriter );
  }

  m_MimeType = "application/MITK.Surface";
}
template<class VTKWRITER>
virtual const char* mitk::SurfaceVtkWriter< VTKWRITER >::GetClassName (  ) const [virtual]

Reimplemented from mitk::FileWriter.

template<class VTKWRITER>
virtual const char* mitk::SurfaceVtkWriter< 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::SurfaceVtkWriter< VTKWRITER >::GetFileExtension (  ) [virtual]

Return the extension to be added to the filename.

Reimplemented from mitk::FileWriter.

Definition at line 171 of file mitkSurfaceVtkWriter.txx.

{
  return m_Extension;
}
template<class VTKWRITER>
virtual const char* mitk::SurfaceVtkWriter< 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::SurfaceVtkWriter< VTKWRITER >::GetFilePattern (  ) const [virtual]
Warning:
multiple write not (yet) supported

Implements mitk::FileWriter.

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

Implements mitk::FileWriter.

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

Definition at line 126 of file mitkSurfaceVtkWriter.txx.

{
  if ( this->GetNumberOfInputs() < 1 )
  {
    return NULL;
  }
  else
  {
    return static_cast< const Surface * >( this->ProcessObject::GetInput( 0 ) );
  }
}
template<class VTKWRITER>
virtual std::vector<std::string> mitk::SurfaceVtkWriter< 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::SurfaceVtkWriter< vtkPolyDataWriter >::GetPossibleFileExtensions (  ) [virtual]

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

Implements mitk::FileWriter.

Definition at line 62 of file mitkSurfaceVtkWriter.cpp.

{
template<>
std::vector< std::string > mitk::SurfaceVtkWriter< vtkSTLWriter >::GetPossibleFileExtensions (  ) [virtual]

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

Implements mitk::FileWriter.

Definition at line 53 of file mitkSurfaceVtkWriter.cpp.

  {
    itkExceptionMacro(<<"Error during surface writing: " << vtkErrorCode::GetStringFromErrorCode(vtkWriter->GetErrorCode()) );
  }
}

template<>
std::vector<std::string> SurfaceVtkWriter<vtkSTLWriter>::GetPossibleFileExtensions()
template<>
std::vector< std::string > mitk::SurfaceVtkWriter< vtkXMLPolyDataWriter >::GetPossibleFileExtensions (  ) [virtual]

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

Implements mitk::FileWriter.

Definition at line 71 of file mitkSurfaceVtkWriter.cpp.

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

Return the MimeType of the saved File.

Reimplemented from mitk::FileWriter.

Definition at line 165 of file mitkSurfaceVtkWriter.txx.

{
  return m_MimeType;
}
template<class VTKWRITER>
static Pointer mitk::SurfaceVtkWriter< VTKWRITER >::New (  ) [static]
template<class VTKWRITER >
void mitk::SurfaceVtkWriter< 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 mitkSurfaceVtkWriter.txx.

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

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

Definition at line 30 of file mitkSurfaceVtkWriter.cpp.

template<>
void mitk::SurfaceVtkWriter< vtkXMLPolyDataWriter >::SetDefaultExtension (  )

Definition at line 37 of file mitkSurfaceVtkWriter.cpp.

template<>
void mitk::SurfaceVtkWriter< vtkSTLWriter >::SetDefaultExtension (  )
template<class VTKWRITER>
virtual void mitk::SurfaceVtkWriter< 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::SurfaceVtkWriter< 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 mitkManualSegmentationToSurfaceFilterTest(), mitkSurfaceVtkWriterTest(), CommonFunctionality::SaveSurface(), and mitk::SurfaceSerializer::Serialize().

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

Implements mitk::FileWriter.

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

Implements mitk::FileWriter.

template<class VTKWRITER >
void mitk::SurfaceVtkWriter< 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 158 of file mitkSurfaceVtkWriter.txx.

References mitk::DataNode::GetData().

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

Sets the 0'th input object for the filter.

Parameters:
inputthe first input for the filter.

Definition at line 120 of file mitkSurfaceVtkWriter.txx.

Referenced by mitkManualSegmentationToSurfaceFilterTest(), mitkSurfaceVtkWriterTest(), CommonFunctionality::SaveSurface(), and mitk::SurfaceSerializer::Serialize().

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

Definition at line 59 of file mitkSurfaceVtkWriter.h.

Referenced by mitkSurfaceVtkWriterTest().

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

Member Data Documentation

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

Definition at line 182 of file mitkSurfaceVtkWriter.h.

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

Definition at line 176 of file mitkSurfaceVtkWriter.h.

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

Definition at line 180 of file mitkSurfaceVtkWriter.h.

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

Definition at line 178 of file mitkSurfaceVtkWriter.h.

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

Definition at line 184 of file mitkSurfaceVtkWriter.h.

template<class VTKWRITER>
vtkSmartPointer<VtkWriterType> mitk::SurfaceVtkWriter< VTKWRITER >::m_VtkWriter [protected]
template<class VTKWRITER>
bool mitk::SurfaceVtkWriter< VTKWRITER >::m_WriterWriteHasReturnValue [protected]

Definition at line 188 of file mitkSurfaceVtkWriter.h.


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