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(NULL); 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 << "File Name: " 62 << (this->Writer->GetFileName() ? this->Writer->GetFileName() : "(none)") << "\n"; 63 64 if ( this->Writer->GetFileType() == VTK_BINARY ) 65 { 66 os << indent << "File Type: BINARY\n"; 67 } 68 else 69 { 70 os << indent << "File Type: ASCII\n"; 71 } 72 73 if ( this->Writer->GetHeader() ) 74 { 75 os << indent << "Header: " << this->Writer->GetHeader() << "\n"; 76 } 77 else 78 { 79 os << indent << "Header: (None)\n"; 80 } 81 82 if ( this->Writer->GetFieldDataName() ) 83 { 84 os << indent << "Field Data Name: " << this->Writer->GetFieldDataName() << "\n"; 85 } 86 else 87 { 88 os << indent << "Field Data Name: (None)\n"; 89 } 90 } 91 FillInputPortInformation(int,vtkInformation * info)92int vtkDataObjectWriter::FillInputPortInformation(int, vtkInformation *info) 93 { 94 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject"); 95 return 1; 96 } 97