Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkSurfaceVtkWriter.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <vtkErrorCode.h>
18 
19 #include "mitkSurfaceVtkWriter.h"
20 #include "mitkSurfaceVtkWriter.txx"
21 
22 namespace mitk
23 {
24  template <>
26  {
27  m_Extension = ".stl";
28  m_WriterWriteHasReturnValue = false;
29  }
30 
31  template <>
33  {
34  m_Extension = ".vtk";
35  m_WriterWriteHasReturnValue = false;
36  }
37 
38  template <>
40  {
41  m_Extension = ".vtp";
42  m_WriterWriteHasReturnValue = true;
43  }
44 
45  template <>
47  {
48  return "surface";
49  }
50 
51  template <>
53  {
54  return "STL Surface (*.stl)";
55  }
56 
57  template <>
59  {
60  return ".stl";
61  }
62 
63  template <>
65  {
66  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
67  }
68 
69  template <>
71  {
72  if (this->CanWriteBaseDataType(data))
73  {
74  this->SetInput(data.GetPointer());
75  this->Update();
76  }
77  }
78 
79  template <>
81  {
82  return "surface";
83  }
84 
85  template <>
87  {
88  return "VTK Polydata (*.vtk)";
89  }
90 
91  template <>
93  {
94  return ".vtk";
95  }
96 
97  template <>
99  {
100  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
101  }
102 
103  template <>
105  {
106  if (this->CanWriteBaseDataType(data))
107  {
108  this->SetInput(data.GetPointer());
109  this->Update();
110  }
111  }
112 
113  template <>
115  {
116  return "surface";
117  }
118 
119  template <>
121  {
122  return "VTK XML Polydata (*.vtp)";
123  }
124 
125  template <>
127  {
128  return ".vtp";
129  }
130 
131  template <>
133  {
134  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
135  }
136 
137  template <>
139  {
140  if (this->CanWriteBaseDataType(data))
141  {
142  this->SetInput(data.GetPointer());
143  this->Update();
144  }
145  }
146 
147  template <>
149  {
150  if (vtkWriter->Write() == 0 || vtkWriter->GetErrorCode() != 0)
151  {
152  itkExceptionMacro(<< "Error during surface writing: "
153  << vtkErrorCode::GetStringFromErrorCode(vtkWriter->GetErrorCode()));
154  }
155  }
156 
157  template <>
159  {
160  std::vector<std::string> possibleFileExtensions;
161  possibleFileExtensions.push_back(".stl");
162  possibleFileExtensions.push_back(".obj");
163  return possibleFileExtensions;
164  }
165 
166  template <>
168  {
169  std::vector<std::string> possibleFileExtensions;
170  possibleFileExtensions.push_back(".vtk");
171  possibleFileExtensions.push_back(".obj");
172  return possibleFileExtensions;
173  }
174 
175  template <>
177  {
178  std::vector<std::string> possibleFileExtensions;
179  possibleFileExtensions.push_back(".vtp");
180  possibleFileExtensions.push_back(".obj");
181  return possibleFileExtensions;
182  }
183 
184  template class SurfaceVtkWriter<vtkSTLWriter>;
187 }
virtual std::vector< std::string > GetPossibleFileExtensions() override
Return the possible file extensions for the data type associated with the writer. ...
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
virtual const char * GetDefaultFilename() override
VTK-based writer for mitk::Surface.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
DataCollection - Class to facilitate loading/accessing structured data.
virtual const char * GetDefaultExtension() override
virtual bool CanWriteBaseDataType(BaseData::Pointer data) override
void ExecuteWrite(VtkWriterType *vtkWriter)
virtual void DoWrite(BaseData::Pointer data) override
void SetDefaultExtension()
Set the extension to be added to the filename to the default.
virtual const char * GetFileDialogPattern() override