1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkXMLImageDataWriter.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #include "vtkXMLImageDataWriter.h"
16 #include "vtkImageData.h"
17 #include "vtkInformation.h"
18 #include "vtkMatrix3x3.h"
19 #include "vtkObjectFactory.h"
20 
21 vtkStandardNewMacro(vtkXMLImageDataWriter);
22 
23 //------------------------------------------------------------------------------
24 vtkXMLImageDataWriter::vtkXMLImageDataWriter() = default;
25 
26 //------------------------------------------------------------------------------
27 vtkXMLImageDataWriter::~vtkXMLImageDataWriter() = default;
28 
29 //------------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)30 void vtkXMLImageDataWriter::PrintSelf(ostream& os, vtkIndent indent)
31 {
32   this->Superclass::PrintSelf(os, indent);
33 }
34 
35 //------------------------------------------------------------------------------
GetInput()36 vtkImageData* vtkXMLImageDataWriter::GetInput()
37 {
38   return static_cast<vtkImageData*>(this->Superclass::GetInput());
39 }
40 
41 //------------------------------------------------------------------------------
GetInputExtent(int * extent)42 void vtkXMLImageDataWriter::GetInputExtent(int* extent)
43 {
44   this->GetInput()->GetExtent(extent);
45 }
46 
47 //------------------------------------------------------------------------------
GetDataSetName()48 const char* vtkXMLImageDataWriter::GetDataSetName()
49 {
50   return "ImageData";
51 }
52 
53 //------------------------------------------------------------------------------
GetDefaultFileExtension()54 const char* vtkXMLImageDataWriter::GetDefaultFileExtension()
55 {
56   return "vti";
57 }
58 
59 //------------------------------------------------------------------------------
WritePrimaryElementAttributes(ostream & os,vtkIndent indent)60 void vtkXMLImageDataWriter::WritePrimaryElementAttributes(ostream& os, vtkIndent indent)
61 {
62   this->Superclass::WritePrimaryElementAttributes(os, indent);
63   vtkImageData* input = this->GetInput();
64   this->WriteVectorAttribute("Origin", 3, input->GetOrigin());
65   this->WriteVectorAttribute("Spacing", 3, input->GetSpacing());
66   this->WriteVectorAttribute("Direction", 9, input->GetDirectionMatrix()->GetData());
67 }
68 
69 //------------------------------------------------------------------------------
FillInputPortInformation(int vtkNotUsed (port),vtkInformation * info)70 int vtkXMLImageDataWriter::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info)
71 {
72   info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageData");
73   return 1;
74 }
75