Medical Imaging Interaction Toolkit  2022.04.99-3f7a773b
Medical Imaging Interaction Toolkit
mitkSurfaceVtkWriter.h
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 #ifndef _MITK_SURFACE_VTK_WRITER__H_
14 #define _MITK_SURFACE_VTK_WRITER__H_
15 
16 #include <iomanip>
17 
18 #include <vtkPolyDataWriter.h>
19 #include <vtkSTLWriter.h>
20 #include <vtkXMLPolyDataWriter.h>
21 
22 #include <MitkLegacyIOExports.h>
23 #include <itkProcessObject.h>
25 #include <mitkPointSet.h>
26 #include <mitkSurface.h>
27 
28 #include <vtkSmartPointer.h>
29 
30 class vtkTransformPolyDataFilter;
31 
32 namespace mitk
33 {
50  template <class VTKWRITER>
52  {
53  public:
55 
56  itkFactorylessNewMacro(Self);
57 
58  itkCloneMacro(Self);
59 
61 
62  typedef VTKWRITER VtkWriterType;
63 
68  itkSetStringMacro(FileName);
69 
73  itkGetStringMacro(FileName);
74 
83  itkSetStringMacro(Extension);
84 
90  itkGetStringMacro(Extension);
91 
98  void SetDefaultExtension();
99 
103  itkSetStringMacro(FilePrefix);
104 
108  itkGetStringMacro(FilePrefix);
109 
113  itkSetStringMacro(FilePattern);
114 
118  itkGetStringMacro(FilePattern);
119 
124  void SetInput(mitk::Surface *input);
125 
129  const mitk::Surface *GetInput();
130 
134  std::string GetFileExtension() override;
135 
139  bool CanWriteDataType(DataNode *) override;
140 
144  std::string GetWritenMIMEType() override;
145 
146  using Superclass::SetInput;
150  virtual void SetInput(DataNode *);
151 
152  VtkWriterType *GetVtkWriter() { return m_VtkWriter; }
156  std::vector<std::string> GetPossibleFileExtensions() override;
157 
158  std::string GetSupportedBaseData() const override { return Surface::GetStaticNameOfClass(); }
159  const char *GetDefaultFilename() override;
160  const char *GetFileDialogPattern() override;
161  const char *GetDefaultExtension() override;
162  bool CanWriteBaseDataType(BaseData::Pointer data) override;
163  void DoWrite(BaseData::Pointer data) override;
164 
165  protected:
170 
174  ~SurfaceVtkWriter() override;
175 
176  void GenerateData() override;
177 
178  void ExecuteWrite(VtkWriterType *vtkWriter);
179 
180  std::string m_FileName;
181 
182  std::string m_FilePrefix;
183 
184  std::string m_FilePattern;
185 
186  std::string m_Extension;
187 
188  std::string m_MimeType;
189 
190  vtkSmartPointer<VtkWriterType> m_VtkWriter;
191 
193  };
194 
195 #ifndef MitkLegacyIO_EXPORTS
196  extern template class SurfaceVtkWriter<vtkSTLWriter>;
197  extern template class SurfaceVtkWriter<vtkPolyDataWriter>;
198  extern template class SurfaceVtkWriter<vtkXMLPolyDataWriter>;
199 #endif
200 }
201 
202 #endif //_MITK_SURFACE_VTK_WRITER__H_
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
#define MITKLEGACYIO_EXPORT
VTK-based writer for mitk::Surface.
DataCollection - Class to facilitate loading/accessing structured data.
Interface for FileWriters with extra information. Should be merged into FileWriter.
vtkSmartPointer< VtkWriterType > m_VtkWriter
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
Interface class of writers that write data to files.
VtkWriterType * GetVtkWriter()
static const char * GetStaticNameOfClass()
Definition: mitkSurface.h:33
std::string GetSupportedBaseData() const override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63