1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkXMLPImageDataWriter.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 "vtkXMLPImageDataWriter.h"
16 
17 #include "vtkErrorCode.h"
18 #include "vtkImageData.h"
19 #include "vtkInformation.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkXMLImageDataWriter.h"
22 
23 vtkStandardNewMacro(vtkXMLPImageDataWriter);
24 
25 //------------------------------------------------------------------------------
26 vtkXMLPImageDataWriter::vtkXMLPImageDataWriter() = default;
27 
28 //------------------------------------------------------------------------------
29 vtkXMLPImageDataWriter::~vtkXMLPImageDataWriter() = default;
30 
31 //------------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)32 void vtkXMLPImageDataWriter::PrintSelf(ostream& os, vtkIndent indent)
33 {
34   this->Superclass::PrintSelf(os, indent);
35 }
36 
37 //------------------------------------------------------------------------------
GetInput()38 vtkImageData* vtkXMLPImageDataWriter::GetInput()
39 {
40   return static_cast<vtkImageData*>(this->Superclass::GetInput());
41 }
42 
43 //------------------------------------------------------------------------------
GetDataSetName()44 const char* vtkXMLPImageDataWriter::GetDataSetName()
45 {
46   return "PImageData";
47 }
48 
49 //------------------------------------------------------------------------------
GetDefaultFileExtension()50 const char* vtkXMLPImageDataWriter::GetDefaultFileExtension()
51 {
52   return "pvti";
53 }
54 
55 //------------------------------------------------------------------------------
WritePrimaryElementAttributes(ostream & os,vtkIndent indent)56 void vtkXMLPImageDataWriter::WritePrimaryElementAttributes(ostream& os, vtkIndent indent)
57 {
58   this->Superclass::WritePrimaryElementAttributes(os, indent);
59   if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
60   {
61     return;
62   }
63 
64   vtkImageData* input = this->GetInput();
65   this->WriteVectorAttribute("Origin", 3, input->GetOrigin());
66   if (this->ErrorCode == vtkErrorCode::OutOfDiskSpaceError)
67   {
68     return;
69   }
70 
71   this->WriteVectorAttribute("Spacing", 3, input->GetSpacing());
72 }
73 
74 //------------------------------------------------------------------------------
CreateStructuredPieceWriter()75 vtkXMLStructuredDataWriter* vtkXMLPImageDataWriter::CreateStructuredPieceWriter()
76 {
77   // Create the writer for the piece.
78   vtkXMLImageDataWriter* pWriter = vtkXMLImageDataWriter::New();
79   pWriter->SetInputConnection(this->GetInputConnection(0, 0));
80   return pWriter;
81 }
82 
83 //------------------------------------------------------------------------------
FillInputPortInformation(int vtkNotUsed (port),vtkInformation * info)84 int vtkXMLPImageDataWriter::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info)
85 {
86   info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkImageData");
87   return 1;
88 }
89