1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkDataObjectWriter.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 "vtkDataObjectWriter.h" 16 17 #include "vtkDataObject.h" 18 #include "vtkInformation.h" 19 #include "vtkObjectFactory.h" 20 21 vtkStandardNewMacro(vtkDataObjectWriter); 22 vtkDataObjectWriter()23vtkDataObjectWriter::vtkDataObjectWriter() 24 { 25 this->Writer = vtkDataWriter::New(); 26 } 27 ~vtkDataObjectWriter()28vtkDataObjectWriter::~vtkDataObjectWriter() 29 { 30 this->Writer->Delete(); 31 } 32 33 // Write FieldData data to file WriteData()34void vtkDataObjectWriter::WriteData() 35 { 36 ostream* fp; 37 vtkFieldData* f = this->GetInput()->GetFieldData(); 38 39 vtkDebugMacro(<< "Writing vtk FieldData data..."); 40 41 this->Writer->SetInputData(this->GetInput()); 42 43 if (!(fp = this->Writer->OpenVTKFile()) || !this->Writer->WriteHeader(fp)) 44 { 45 return; 46 } 47 // 48 // Write FieldData data specific stuff 49 // 50 this->Writer->WriteFieldData(fp, f); 51 52 this->Writer->CloseVTKFile(fp); 53 54 this->Writer->SetInputData(nullptr); 55 } 56 PrintSelf(ostream & os,vtkIndent indent)57void vtkDataObjectWriter::PrintSelf(ostream& os, vtkIndent indent) 58 { 59 this->Superclass::PrintSelf(os, indent); 60 61 os << indent 62 << "File Name: " << (this->Writer->GetFileName() ? this->Writer->GetFileName() : "(none)") 63 << "\n"; 64 65 if (this->Writer->GetFileType() == VTK_BINARY) 66 { 67 os << indent << "File Type: BINARY\n"; 68 } 69 else 70 { 71 os << indent << "File Type: ASCII\n"; 72 } 73 74 if (this->Writer->GetHeader()) 75 { 76 os << indent << "Header: " << this->Writer->GetHeader() << "\n"; 77 } 78 else 79 { 80 os << indent << "Header: (None)\n"; 81 } 82 83 if (this->Writer->GetFieldDataName()) 84 { 85 os << indent << "Field Data Name: " << this->Writer->GetFieldDataName() << "\n"; 86 } 87 else 88 { 89 os << indent << "Field Data Name: (None)\n"; 90 } 91 } 92 FillInputPortInformation(int,vtkInformation * info)93int vtkDataObjectWriter::FillInputPortInformation(int, vtkInformation* info) 94 { 95 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject"); 96 return 1; 97 } 98