VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkParticleReader.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00039 #ifndef __vtkParticleReader_h 00040 #define __vtkParticleReader_h 00041 00042 #include "vtkPolyDataAlgorithm.h" 00043 00044 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0 00045 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1 00046 00047 00048 class VTK_IO_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm 00049 { 00050 public: 00051 static vtkParticleReader *New(); 00052 vtkTypeMacro(vtkParticleReader,vtkPolyDataAlgorithm); 00053 void PrintSelf(ostream& os, vtkIndent indent); 00054 00056 00057 vtkSetStringMacro(FileName); 00058 vtkGetStringMacro(FileName); 00060 00062 00073 void SetDataByteOrderToBigEndian(); 00074 void SetDataByteOrderToLittleEndian(); 00075 int GetDataByteOrder(); 00076 void SetDataByteOrder(int); 00077 const char *GetDataByteOrderAsString(); 00079 00081 00083 vtkSetMacro(SwapBytes,int); 00084 int GetSwapBytes() {return this->SwapBytes;} 00085 vtkBooleanMacro(SwapBytes,int); 00087 00089 00090 vtkSetMacro(HasScalar,int); 00091 vtkGetMacro(HasScalar,int); 00092 vtkBooleanMacro(HasScalar,int); 00094 00096 00100 vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY); 00101 vtkGetMacro(FileType, int); 00102 void SetFileTypeToUnknown() {this->SetFileType(FILE_TYPE_IS_UNKNOWN);} 00103 void SetFileTypeToText() {this->SetFileType(FILE_TYPE_IS_TEXT);} 00104 void SetFileTypeToBinary() {this->SetFileType(FILE_TYPE_IS_BINARY);} 00106 00108 00111 vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE); 00112 vtkGetMacro(DataType, int); 00113 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);} 00114 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);} 00116 00117 00118 protected: 00119 vtkParticleReader(); 00120 ~vtkParticleReader(); 00121 00122 void OpenFile(); 00123 00124 char *FileName; 00125 ifstream *File; 00126 00127 int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00128 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00129 00131 00139 int ProduceOutputFromTextFileDouble(vtkInformationVector *outputVector); 00140 int ProduceOutputFromTextFileFloat(vtkInformationVector *outputVector); 00142 00144 00146 int ProduceOutputFromBinaryFileDouble(vtkInformationVector *outputVector); 00147 int ProduceOutputFromBinaryFileFloat(vtkInformationVector *outputVector); 00149 00159 int DetermineFileType(); 00160 00162 void DoProgressUpdate( size_t & bytesRead, size_t & fileLength ); 00163 00164 //BTX 00166 00170 enum FILE_TYPE { FILE_TYPE_IS_UNKNOWN = 0, 00171 FILE_TYPE_IS_TEXT, FILE_TYPE_IS_BINARY }; 00172 //ETX 00174 00175 int HasScalar; 00177 int FileType; 00179 int DataType; 00180 00182 size_t Alliquot; 00184 size_t Count; 00185 00186 int SwapBytes; 00187 size_t NumberOfPoints; 00188 00189 private: 00190 vtkParticleReader(const vtkParticleReader&); // Not implemented. 00191 void operator=(const vtkParticleReader&); // Not implemented. 00192 }; 00193 00194 #endif