00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkSurfaceVtkWriter.h" 00019 #include "mitkSurfaceVtkWriter.txx" 00020 00021 #include <vtkSTLWriter.h> 00022 #include <vtkPolyDataWriter.h> 00023 #include <vtkXMLPolyDataWriter.h> 00024 #include <vtkErrorCode.h> 00025 00026 namespace mitk { 00027 00028 template<> 00029 void SurfaceVtkWriter<vtkSTLWriter>::SetDefaultExtension() 00030 { 00031 m_Extension = ".stl"; 00032 m_WriterWriteHasReturnValue = false; 00033 } 00034 00035 template<> 00036 void SurfaceVtkWriter<vtkPolyDataWriter>::SetDefaultExtension() 00037 { 00038 m_Extension = ".vtk"; 00039 m_WriterWriteHasReturnValue = false; 00040 } 00041 00042 template<> 00043 void SurfaceVtkWriter<vtkXMLPolyDataWriter>::SetDefaultExtension() 00044 { 00045 m_Extension = ".vtp"; 00046 m_WriterWriteHasReturnValue = true; 00047 } 00048 00049 template<> 00050 void SurfaceVtkWriter<vtkXMLPolyDataWriter>::ExecuteWrite( VtkWriterType* vtkWriter ) 00051 { 00052 if ( vtkWriter->Write() == 0 || vtkWriter->GetErrorCode() != 0 ) 00053 { 00054 itkExceptionMacro(<<"Error during surface writing: " << vtkErrorCode::GetStringFromErrorCode(vtkWriter->GetErrorCode()) ); 00055 } 00056 } 00057 00058 template<> 00059 std::vector<std::string> SurfaceVtkWriter<vtkSTLWriter>::GetPossibleFileExtensions() 00060 { 00061 std::vector<std::string> possibleFileExtensions; 00062 possibleFileExtensions.push_back(".stl"); 00063 possibleFileExtensions.push_back(".obj"); 00064 return possibleFileExtensions; 00065 } 00066 00067 template<> 00068 std::vector<std::string> SurfaceVtkWriter<vtkPolyDataWriter>::GetPossibleFileExtensions() 00069 { 00070 std::vector<std::string> possibleFileExtensions; 00071 possibleFileExtensions.push_back(".vtk"); 00072 possibleFileExtensions.push_back(".obj"); 00073 return possibleFileExtensions; 00074 } 00075 00076 template<> 00077 std::vector<std::string> SurfaceVtkWriter<vtkXMLPolyDataWriter>::GetPossibleFileExtensions() 00078 { 00079 std::vector<std::string> possibleFileExtensions; 00080 possibleFileExtensions.push_back(".vtp"); 00081 possibleFileExtensions.push_back(".obj"); 00082 return possibleFileExtensions; 00083 } 00084 00085 template class MITK_CORE_EXPORT SurfaceVtkWriter<vtkSTLWriter>; 00086 00087 template class MITK_CORE_EXPORT SurfaceVtkWriter<vtkPolyDataWriter>; 00088 00089 template class MITK_CORE_EXPORT SurfaceVtkWriter<vtkXMLPolyDataWriter>; 00090 00091 } 00092 00093