VTK-based writer for mitk::UnstructuredGrid. More...
#include <mitkUnstructuredGridVtkWriter.h>


Public Types | |
| typedef UnstructuredGridVtkWriter | Self |
| typedef mitk::FileWriter | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| 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::UnstructuredGrid * | GetInput () |
| 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. | |
| VtkWriterType * | GetVtkWriter () |
| 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 |
| VtkWriterType * | m_VtkWriter |
| bool | m_WriterWriteHasReturnValue |
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.
| typedef itk::SmartPointer<const Self> mitk::UnstructuredGridVtkWriter< VTKWRITER >::ConstPointer |
Reimplemented from mitk::FileWriter.
Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.
| typedef itk::SmartPointer<Self> mitk::UnstructuredGridVtkWriter< VTKWRITER >::Pointer |
Reimplemented from mitk::FileWriter.
Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.
| typedef UnstructuredGridVtkWriter mitk::UnstructuredGridVtkWriter< VTKWRITER >::Self |
Reimplemented from mitk::FileWriter.
Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.
| typedef mitk::FileWriter mitk::UnstructuredGridVtkWriter< VTKWRITER >::Superclass |
Reimplemented from mitk::FileWriter.
Definition at line 53 of file mitkUnstructuredGridVtkWriter.h.
| typedef VTKWRITER mitk::UnstructuredGridVtkWriter< VTKWRITER >::VtkWriterType |
Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.
| 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 }
| mitk::UnstructuredGridVtkWriter< VTKWRITER >::~UnstructuredGridVtkWriter | ( | ) | [protected, virtual] |
Virtual destructor.
Definition at line 44 of file mitkUnstructuredGridVtkWriter.txx.
{
m_VtkWriter->Delete();
}
| 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;
}
| 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");
}
}
| void mitk::UnstructuredGridVtkWriter< vtkXMLUnstructuredGridWriter >::ExecuteWrite | ( | VtkWriterType * | m_VtkWriter, |
| vtkTransformFilter * | transformPointSet | ||
| ) | [protected] |
Definition at line 38 of file mitkUnstructuredGridVtkWriter.cpp.
{
if (!m_VtkWriter->Write())
{
| 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";
}
| virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::FileWriter.
| virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetExtension | ( | ) | const [virtual] |
Get the extension to be added to the filename.
| 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;
}
| virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFileName | ( | ) | const [virtual] |
Implements mitk::FileWriter.
| virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFilePattern | ( | ) | const [virtual] |
Implements mitk::FileWriter.
| virtual const char* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetFilePrefix | ( | ) | const [virtual] |
Implements mitk::FileWriter.
| const mitk::UnstructuredGrid * mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetInput | ( | void | ) |
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 ) );
}
}
| 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.
| 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.
{
| 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.
{
| VtkWriterType* mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetVtkWriter | ( | ) | [inline] |
Definition at line 153 of file mitkUnstructuredGridVtkWriter.h.
References mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_VtkWriter.
{
return m_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;
}
| static Pointer mitk::UnstructuredGridVtkWriter< VTKWRITER >::New | ( | ) | [static] |
| 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";
}
| void mitk::UnstructuredGridVtkWriter< vtkXMLUnstructuredGridWriter >::SetDefaultExtension | ( | ) |
Definition at line 31 of file mitkUnstructuredGridVtkWriter.cpp.
{
| void mitk::UnstructuredGridVtkWriter< vtkUnstructuredGridWriter >::SetDefaultExtension | ( | ) |
Definition at line 24 of file mitkUnstructuredGridVtkWriter.cpp.
References mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetDefaultExtension().
{
template<>
void UnstructuredGridVtkWriter<vtkUnstructuredGridWriter>::SetDefaultExtension()
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetExtension | ( | const char * | _arg ) | [virtual] |
Explicitly set the extension to be added to the filename.
| _arg | to 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.
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFileName | ( | const char * | _arg ) | [virtual] |
Sets the filename of the file to write.
| _arg | the name of the file to write. |
Implements mitk::FileWriter.
Referenced by mitkUnstructuredGridVtkWriterTest().
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFilePattern | ( | const char * | _arg ) | [virtual] |
Implements mitk::FileWriter.
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFilePrefix | ( | const char * | _arg ) | [virtual] |
Implements mitk::FileWriter.
| 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() ) );
}
| void mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetInput | ( | mitk::UnstructuredGrid * | input ) |
Sets the 0'th input object for the filter.
| input | the first input for the filter. |
Definition at line 149 of file mitkUnstructuredGridVtkWriter.txx.
Referenced by mitkUnstructuredGridVtkWriterTest().
{
this->ProcessObject::SetNthInput( 0, ug );
}
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::Update | ( | ) | [inline, virtual] |
Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.
Referenced by mitkUnstructuredGridVtkWriterTest().
| virtual void mitk::UnstructuredGridVtkWriter< VTKWRITER >::Write | ( | ) | [inline, virtual] |
Implements mitk::FileWriter.
Definition at line 57 of file mitkUnstructuredGridVtkWriter.h.
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_Extension [protected] |
Definition at line 180 of file mitkUnstructuredGridVtkWriter.h.
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FileName [protected] |
Definition at line 174 of file mitkUnstructuredGridVtkWriter.h.
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FilePattern [protected] |
Definition at line 178 of file mitkUnstructuredGridVtkWriter.h.
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_FilePrefix [protected] |
Definition at line 176 of file mitkUnstructuredGridVtkWriter.h.
std::string mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_MimeType [protected] |
Definition at line 182 of file mitkUnstructuredGridVtkWriter.h.
VtkWriterType* mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_VtkWriter [protected] |
Definition at line 184 of file mitkUnstructuredGridVtkWriter.h.
Referenced by mitk::UnstructuredGridVtkWriter< VTKWRITER >::GetVtkWriter(), and mitk::UnstructuredGridVtkWriter< VTKWRITER >::UnstructuredGridVtkWriter().
bool mitk::UnstructuredGridVtkWriter< VTKWRITER >::m_WriterWriteHasReturnValue [protected] |
Definition at line 186 of file mitkUnstructuredGridVtkWriter.h.
1.7.2