Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include <vtkErrorCode.h>
14 
15 #include "mitkSurfaceVtkWriter.h"
16 #include "mitkSurfaceVtkWriter.txx"
17 
18 namespace mitk
19 {
20  template <>
22  {
23  m_Extension = ".stl";
24  m_WriterWriteHasReturnValue = false;
25  }
26 
27  template <>
29  {
30  m_Extension = ".vtk";
31  m_WriterWriteHasReturnValue = false;
32  }
33 
34  template <>
36  {
37  m_Extension = ".vtp";
38  m_WriterWriteHasReturnValue = true;
39  }
40 
41  template <>
43  {
44  return "surface";
45  }
46 
47  template <>
49  {
50  return "STL Surface (*.stl)";
51  }
52 
53  template <>
55  {
56  return ".stl";
57  }
58 
59  template <>
61  {
62  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
63  }
64 
65  template <>
67  {
68  if (this->CanWriteBaseDataType(data))
69  {
70  this->SetInput(data.GetPointer());
71  this->Update();
72  }
73  }
74 
75  template <>
77  {
78  return "surface";
79  }
80 
81  template <>
83  {
84  return "VTK Polydata (*.vtk)";
85  }
86 
87  template <>
89  {
90  return ".vtk";
91  }
92 
93  template <>
95  {
96  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
97  }
98 
99  template <>
101  {
102  if (this->CanWriteBaseDataType(data))
103  {
104  this->SetInput(data.GetPointer());
105  this->Update();
106  }
107  }
108 
109  template <>
111  {
112  return "surface";
113  }
114 
115  template <>
117  {
118  return "VTK XML Polydata (*.vtp)";
119  }
120 
121  template <>
123  {
124  return ".vtp";
125  }
126 
127  template <>
129  {
130  return dynamic_cast<mitk::Surface *>(data.GetPointer()) != nullptr;
131  }
132 
133  template <>
135  {
136  if (this->CanWriteBaseDataType(data))
137  {
138  this->SetInput(data.GetPointer());
139  this->Update();
140  }
141  }
142 
143  template <>
145  {
146  if (vtkWriter->Write() == 0 || vtkWriter->GetErrorCode() != 0)
147  {
148  itkExceptionMacro(<< "Error during surface writing: "
149  << vtkErrorCode::GetStringFromErrorCode(vtkWriter->GetErrorCode()));
150  }
151  }
152 
153  template <>
155  {
156  std::vector<std::string> possibleFileExtensions;
157  possibleFileExtensions.push_back(".stl");
158  possibleFileExtensions.push_back(".obj");
159  return possibleFileExtensions;
160  }
161 
162  template <>
164  {
165  std::vector<std::string> possibleFileExtensions;
166  possibleFileExtensions.push_back(".vtk");
167  possibleFileExtensions.push_back(".obj");
168  return possibleFileExtensions;
169  }
170 
171  template <>
173  {
174  std::vector<std::string> possibleFileExtensions;
175  possibleFileExtensions.push_back(".vtp");
176  possibleFileExtensions.push_back(".obj");
177  return possibleFileExtensions;
178  }
179 
180  template class SurfaceVtkWriter<vtkSTLWriter>;
183 }
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
bool CanWriteBaseDataType(BaseData::Pointer data) override
const char * GetFileDialogPattern() override
std::vector< std::string > GetPossibleFileExtensions() override
Return the possible file extensions for the data type associated with the writer. ...
VTK-based writer for mitk::Surface.
const char * GetDefaultExtension() override
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:31
DataCollection - Class to facilitate loading/accessing structured data.
const char * GetDefaultFilename() override
void ExecuteWrite(VtkWriterType *vtkWriter)
void SetDefaultExtension()
Set the extension to be added to the filename to the default.
void DoWrite(BaseData::Pointer data) override