diff --git a/Core/Code/IO/mitkFileWriterWithInformation.h b/Core/Code/IO/mitkFileWriterWithInformation.h index 933a8ca983..9cfd05c8d9 100644 --- a/Core/Code/IO/mitkFileWriterWithInformation.h +++ b/Core/Code/IO/mitkFileWriterWithInformation.h @@ -1,42 +1,42 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef FILEWRITERWITHINFORMATION_H_INCLUDED #define FILEWRITERWITHINFORMATION_H_INCLUDED #include "mitkFileWriter.h" #include "mitkBaseData.h" namespace mitk { /** * \brief Interface for FileWriters with extra information. * Should be merged into FileWriter. */ class MITK_CORE_EXPORT FileWriterWithInformation : public FileWriter { public: mitkClassMacro(FileWriterWithInformation,FileWriter); virtual const char *GetDefaultFilename() = 0; virtual const char *GetFileDialogPattern() = 0; virtual const char *GetDefaultExtension() = 0; - virtual bool CanWriteDataType(BaseData::Pointer data) = 0; + virtual bool CanWriteBaseDataType(BaseData::Pointer data) = 0; virtual void DoWrite(BaseData::Pointer data) = 0; }; } #endif diff --git a/Modules/DiffusionImaging/IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriter.h b/Modules/DiffusionImaging/IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriter.h index fb14341f75..10745e747c 100644 --- a/Modules/DiffusionImaging/IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/DiffusionWeightedImages/mitkNrrdDiffusionImageWriter.h @@ -1,133 +1,133 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_NRRDDIFFVOL_WRITER__H_ #define _MITK_NRRDDIFFVOL_WRITER__H_ #include #include #include namespace mitk { /** * Writes diffusion volumes to a file * @ingroup Process */ template < class TPixelType > class NrrdDiffusionImageWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( NrrdDiffusionImageWriter, mitk::FileWriterWithInformation ); mitkWriterMacro; itkNewMacro( Self ); typedef mitk::DiffusionImage InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInput( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "DiffusionWeightedImages.dwi"; } virtual const char * GetFileDialogPattern() { return "Diffusion Weighted Images (*.dwi *.hdwi *.fsl)"; } virtual const char * GetDefaultExtension() { return ".dwi"; } - virtual bool CanWriteDataType(BaseData::Pointer data) { return (dynamic_cast*>(data.GetPointer()) != NULL); }; + virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast*>(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteDataType(data)) { this->SetInput(dynamic_cast*>(data.GetPointer())); this->Update(); } }; protected: NrrdDiffusionImageWriter(); virtual ~NrrdDiffusionImageWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #include "mitkNrrdDiffusionImageWriter.cpp" #endif diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h index 9738c30c90..da046b3237 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h @@ -1,216 +1,216 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkFiberBundleWriter_h #define __mitkFiberBundleWriter_h #include #include #include "mitkFiberBundle.h" #include namespace mitk { /** * Writes fiber bundles to a file * @ingroup Process */ class FiberBundleWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( FiberBundleWriter, mitk::FileWriterWithInformation ); //mitkWriterMacro; virtual void Write() { if ( this->GetInput() == NULL ) { itkExceptionMacro(<<"Write:Please specify an input!"); return; } /* Fill in image information.*/ this->UpdateOutputInformation(); (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); this->PropagateRequestedRegion(NULL); this->UpdateOutputData(NULL); } virtual void Update() { Write(); } itkNewMacro( Self ); typedef mitk::FiberBundle InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInput( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "FiberBundle.fib"; } virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.afib *.vtk)"; } virtual const char * GetDefaultExtension() { return ".fib"; } - virtual bool CanWriteDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; + virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } }; static const char* XML_GEOMETRY; static const char* XML_MATRIX_XX; static const char* XML_MATRIX_XY; static const char* XML_MATRIX_XZ; static const char* XML_MATRIX_YX; static const char* XML_MATRIX_YY; static const char* XML_MATRIX_YZ; static const char* XML_MATRIX_ZX; static const char* XML_MATRIX_ZY; static const char* XML_MATRIX_ZZ; static const char* XML_ORIGIN_X; static const char* XML_ORIGIN_Y; static const char* XML_ORIGIN_Z; static const char* XML_SPACING_X; static const char* XML_SPACING_Y; static const char* XML_SPACING_Z; static const char* XML_SIZE_X; static const char* XML_SIZE_Y; static const char* XML_SIZE_Z; static const char* XML_FIBER_BUNDLE; static const char* XML_FIBER; static const char* XML_PARTICLE; static const char* XML_ID; static const char* XML_POS_X; static const char* XML_POS_Y; static const char* XML_POS_Z; static const char* VERSION_STRING; static const char* XML_FIBER_BUNDLE_FILE; static const char* XML_FILE_VERSION; static const char* XML_NUM_FIBERS; static const char* XML_NUM_PARTICLES; static const char* ASCII_FILE; static const char* FILE_NAME; protected: FiberBundleWriter(); virtual ~FiberBundleWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //__mitkFiberBundleWriter_h diff --git a/Modules/DiffusionImaging/IODataStructures/QBallImages/mitkNrrdQBallImageWriter.h b/Modules/DiffusionImaging/IODataStructures/QBallImages/mitkNrrdQBallImageWriter.h index bdcded426b..8ee0a188d8 100644 --- a/Modules/DiffusionImaging/IODataStructures/QBallImages/mitkNrrdQBallImageWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/QBallImages/mitkNrrdQBallImageWriter.h @@ -1,130 +1,130 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_NRRDQBI_WRITER__H_ #define _MITK_NRRDQBI_WRITER__H_ #include #include #include namespace mitk { /** * Writes diffusion volumes to a file * @ingroup Process */ class NrrdQBallImageWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( NrrdQBallImageWriter, mitk::FileWriterWithInformation ); mitkWriterMacro; itkNewMacro( Self ); typedef mitk::QBallImage InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInput( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "QBalls.qbi"; } virtual const char * GetFileDialogPattern() { return "Q-Ball Images (*.qbi *.hqbi"; } virtual const char * GetDefaultExtension() { return ".qbi"; } - virtual bool CanWriteDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; + virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } }; protected: NrrdQBallImageWriter(); virtual ~NrrdQBallImageWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //_MITK_NRRDQBI_WRITER__H_ diff --git a/Modules/DiffusionImaging/IODataStructures/TensorImages/mitkNrrdTensorImageWriter.h b/Modules/DiffusionImaging/IODataStructures/TensorImages/mitkNrrdTensorImageWriter.h index 67d5a22286..a44425ac31 100644 --- a/Modules/DiffusionImaging/IODataStructures/TensorImages/mitkNrrdTensorImageWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/TensorImages/mitkNrrdTensorImageWriter.h @@ -1,130 +1,130 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_NRRDDTI_WRITER__H_ #define _MITK_NRRDDTI_WRITER__H_ #include #include #include namespace mitk { /** * Writes diffusion volumes to a file * @ingroup Process */ class NrrdTensorImageWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( NrrdTensorImageWriter, mitk::FileWriterWithInformation ); mitkWriterMacro; itkNewMacro( Self ); typedef mitk::TensorImage InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInput( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "Tensors.dti"; } virtual const char * GetFileDialogPattern() { return "Tensor Images (*.dti *.hdti)"; } virtual const char * GetDefaultExtension() { return ".dti"; } - virtual bool CanWriteDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; + virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } }; protected: NrrdTensorImageWriter(); virtual ~NrrdTensorImageWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //_MITK_NRRDDTI_WRITER__H_ diff --git a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.h b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.h index 6ec9dd8749..d8df668d96 100644 --- a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.h +++ b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.h @@ -1,144 +1,144 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 10863 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ #define _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ #include #include #include "mitkUnstructuredGrid.h" namespace mitk { /** * @brief 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. * @ingroup Process */ template class UnstructuredGridVtkWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( UnstructuredGridVtkWriter, mitk::FileWriterWithInformation ); itkNewMacro( Self ); mitkWriterMacro; /** * Sets the filename of the file to write. * @param _arg the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the 0'th input object for the filter. * @param input the first input for the filter. */ void SetInput( mitk::UnstructuredGrid* input ); /** * @returns the 0'th input object of the filter. */ const UnstructuredGrid* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @brief Return the possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename(); virtual const char * GetFileDialogPattern(); virtual const char * GetDefaultExtension(); - virtual bool CanWriteDataType(BaseData::Pointer data); + virtual bool CanWriteBaseDataType(BaseData::Pointer data); virtual void DoWrite(BaseData::Pointer data); protected: /** * Constructor. */ UnstructuredGridVtkWriter(); /** * Virtual destructor. */ virtual ~UnstructuredGridVtkWriter(); void ExecuteWrite(VTKWRITER* vtkWriter); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } #include "mitkUnstructuredGridVtkWriter.txx" #endif // _MITK_UNSTRUCTURED_GRID_VTK_WRITER__H_ diff --git a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.txx b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.txx index 8b4435a9d4..41906e2a1d 100644 --- a/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.txx +++ b/Modules/MitkExt/IO/mitkUnstructuredGridVtkWriter.txx @@ -1,252 +1,252 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 10863 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_UNSTRUCTURED_GRID_VTKWRITER_TXX_ #define _MITK_UNSTRUCTURED_GRID_VTKWRITER_TXX_ #include #include #include #include #include #include #include #include #include #include #include namespace mitk { template UnstructuredGridVtkWriter::UnstructuredGridVtkWriter() : m_Success(false) { this->SetNumberOfRequiredInputs(1); } template UnstructuredGridVtkWriter::~UnstructuredGridVtkWriter() { } template void UnstructuredGridVtkWriter::GenerateData() { m_Success = false; if ( m_FileName == "" ) { itkWarningMacro( << "Sorry, filename has not been set!" ); return ; } mitk::UnstructuredGrid::Pointer input = const_cast(this->GetInput()); if (input.IsNull()) { itkWarningMacro( << "Sorry, input to mitk::UnstructuredGridVtkWriter is NULL"); return; } VTKWRITER* unstructuredGridWriter = VTKWRITER::New(); 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 << GetDefaultExtension(); } else { itkWarningMacro(<<"Error on write: TimeSlicedGeometry invalid of unstructured grid " << filename << "."); filename << m_FileName.c_str() << "_T" << t << GetDefaultExtension(); } geometry->TransferItkToVtkTransform(); transformPointSet->SetInput(input->GetVtkUnstructuredGrid(t)); transformPointSet->SetTransform(geometry->GetVtkTransform()); transformPointSet->UpdateWholeExtent(); unstructuredGrid = static_cast(transformPointSet->GetOutput()); unstructuredGridWriter->SetFileName(filename.str().c_str()); unstructuredGridWriter->SetInput(unstructuredGrid); ExecuteWrite( unstructuredGridWriter ); } } else { geometry = input->GetGeometry(); geometry->TransferItkToVtkTransform(); transformPointSet->SetInput(input->GetVtkUnstructuredGrid()); transformPointSet->SetTransform(geometry->GetVtkTransform()); transformPointSet->UpdateWholeExtent(); unstructuredGrid = static_cast(transformPointSet->GetOutput()); unstructuredGridWriter->SetFileName(m_FileName.c_str()); unstructuredGridWriter->SetInput(unstructuredGrid); ExecuteWrite( unstructuredGridWriter ); } transformPointSet->Delete(); unstructuredGridWriter->Delete(); m_Success = true; } template void UnstructuredGridVtkWriter::ExecuteWrite( VTKWRITER* vtkWriter ) { struct stat fileStatus; time_t timeBefore=0; if (!stat(vtkWriter->GetFileName(), &fileStatus)) { timeBefore = fileStatus.st_mtime; } if (!vtkWriter->Write()) { itkExceptionMacro( << "Error during unstructured grid writing."); } // check if file can be written because vtkWriter doesn't check that if (stat(vtkWriter->GetFileName(), &fileStatus) || (timeBefore == fileStatus.st_mtime)) { itkExceptionMacro(<<"Error during unstructured grid writing: file could not be written"); } } template void UnstructuredGridVtkWriter::SetInput(UnstructuredGrid *input) { this->ProcessObject::SetNthInput(0, input); } template const UnstructuredGrid* UnstructuredGridVtkWriter::GetInput() { if (this->GetNumberOfInputs() < 1) { return 0; } else { return dynamic_cast(this->ProcessObject::GetInput(0)); } } template -bool UnstructuredGridVtkWriter::CanWriteDataType(BaseData::Pointer data) +bool UnstructuredGridVtkWriter::CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != 0); } template void UnstructuredGridVtkWriter::DoWrite(BaseData::Pointer data) { - if (CanWriteDataType(data)) + if (CanWriteBaseDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } } template std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions() { throw std::exception(); // no specialization available! } template const char* UnstructuredGridVtkWriter::GetDefaultFilename() { throw std::exception(); // no specialization available! } template const char* UnstructuredGridVtkWriter::GetFileDialogPattern() { throw std::exception(); // no specialization available! } template const char* UnstructuredGridVtkWriter::GetDefaultExtension() { throw std::exception(); // no specialization available! } template<> std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions(); template<> std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions(); template<> std::vector UnstructuredGridVtkWriter::GetPossibleFileExtensions(); template<> const char * UnstructuredGridVtkWriter::GetDefaultFilename(); template<> const char * UnstructuredGridVtkWriter::GetDefaultFilename(); template<> const char * UnstructuredGridVtkWriter::GetDefaultFilename(); template<> const char * UnstructuredGridVtkWriter::GetFileDialogPattern(); template<> const char * UnstructuredGridVtkWriter::GetFileDialogPattern(); template<> const char * UnstructuredGridVtkWriter::GetFileDialogPattern(); template<> const char * UnstructuredGridVtkWriter::GetDefaultExtension(); template<> const char * UnstructuredGridVtkWriter::GetDefaultExtension(); template<> const char * UnstructuredGridVtkWriter::GetDefaultExtension(); #ifndef __APPLE__ // On MacOS, we get duplicate symbol errors during linking of mitkCoreExt. // It looks like the linker does not coalesce the two instantiations in // mitkUnstructuredGridVtkWriter.cpp and mitkCoreExtObjectFactory.cpp // (which both include this file) template class MitkExt_EXPORT UnstructuredGridVtkWriter; template class MitkExt_EXPORT UnstructuredGridVtkWriter; template class MitkExt_EXPORT UnstructuredGridVtkWriter; #endif } #endif diff --git a/Modules/PlanarFigure/IO/mitkPlanarFigureWriter.h b/Modules/PlanarFigure/IO/mitkPlanarFigureWriter.h index 0ecc9f692e..2b9cc0e38b 100644 --- a/Modules/PlanarFigure/IO/mitkPlanarFigureWriter.h +++ b/Modules/PlanarFigure/IO/mitkPlanarFigureWriter.h @@ -1,206 +1,206 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12. Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_PlanarFigure_WRITER__H_ #define _MITK_PlanarFigure_WRITER__H_ #include #include "PlanarFigureExports.h" #include #include class TiXmlElement; namespace mitk { /** * @brief XML-based writer for mitk::PlanarFigures * * XML-based writer for mitk::PlanarFigures. * @ingroup Process */ class PlanarFigure_EXPORT PlanarFigureWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( PlanarFigureWriter, mitk::FileWriter ); mitkWriterMacro; itkNewMacro( Self ); typedef mitk::PlanarFigure InputType; typedef InputType::Pointer InputTypePointer; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the 0'th input object for the filter. * @param input the first input for the filter. */ void SetInput( InputType* input ); /** * Sets the n'th input object for the filter. If num is * larger than GetNumberOfInputs() the number of inputs is * resized appropriately. * @param input the n'th input for the filter. */ void SetInput( const unsigned int& num, InputType* input); /** * @returns the 0'th input object of the filter. */ PlanarFigure* GetInput(); /** * @param num the index of the desired output object. * @returns the n'th input object of the filter. */ PlanarFigure* GetInput( const unsigned int& num ); /** * @brief Return the possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); /** * @brief Return the extension to be added to the filename. */ virtual std::string GetFileExtension(); /** * @brief Check if the Writer can write the Content of the */ virtual bool CanWriteDataType( DataNode* ); /** * @brief Return the MimeType of the saved File. */ virtual std::string GetWritenMIMEType(); /** * @brief Set the DataTreenode as Input. Important: The Writer always have a SetInput-Function. */ virtual void SetInput( DataNode* ); /** * @returns whether the last write attempt was successful or not. */ itkGetConstMacro(Success, bool); virtual const char * GetDefaultFilename() { return "PlanarFigure.pf"; } virtual const char * GetFileDialogPattern() { return "Planar Figure Files (*.pf)"; } virtual const char * GetDefaultExtension() { return ".pf"; } - virtual bool CanWriteDataType(BaseData::Pointer data) + virtual bool CanWriteBaseDataType(BaseData::Pointer data) { mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(data); return CanWriteDataType(node); } virtual void DoWrite(BaseData::Pointer data) { - if (CanWriteDataType(data)) { + if (CanWriteBaseDataType(data)) { this->SetInput(dynamic_cast(data.GetPointer())); this->Update(); } } /** @brief CAUTION: It's up to the user to call this function to release the memory buffer after use in case the file writer has written to its memory array. See mitkFileWriter base class. */ virtual void ReleaseMemory(); protected: /** * Constructor. */ PlanarFigureWriter(); /** * Virtual destructor. */ virtual ~PlanarFigureWriter(); /** * Writes the a .pf file in xml format that contains all input planar figures */ virtual void GenerateData(); /** * Resizes the number of inputs of the writer. * The inputs are initialized by empty PlanarFigures * @param num the new number of inputs */ virtual void ResizeInputs( const unsigned int& num ); /**Documentation * \brief creates a TinyXML element that contains x, y, and z values * * \param[in] name the name of the XML element * \param[in] v the vector or point that contains the x, y and z values * \return returns a TiXmlElement named name and three attributes x, y and z. */ TiXmlElement* CreateXMLVectorElement(const char* name, itk::FixedArray v); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; std::string m_Extension; std::string m_MimeType; bool m_Success; }; } #endif