VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkParticleReader.h,v $ 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 =========================================================================*/ 00036 #ifndef __vtkParticleReader_h 00037 #define __vtkParticleReader_h 00038 00039 #include "vtkPolyDataAlgorithm.h" 00040 00041 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0 00042 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1 00043 00044 00045 class VTK_IO_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm 00046 { 00047 public: 00048 static vtkParticleReader *New(); 00049 vtkTypeRevisionMacro(vtkParticleReader,vtkPolyDataAlgorithm); 00050 void PrintSelf(ostream& os, vtkIndent indent); 00051 00053 00054 vtkSetStringMacro(FileName); 00055 vtkGetStringMacro(FileName); 00057 00059 00070 void SetDataByteOrderToBigEndian(); 00071 void SetDataByteOrderToLittleEndian(); 00072 int GetDataByteOrder(); 00073 void SetDataByteOrder(int); 00074 const char *GetDataByteOrderAsString(); 00076 00078 00080 vtkSetMacro(SwapBytes,int); 00081 int GetSwapBytes() {return this->SwapBytes;} 00082 vtkBooleanMacro(SwapBytes,int); 00084 00086 00087 vtkSetMacro(HasScalar,int); 00088 vtkGetMacro(HasScalar,int); 00089 vtkBooleanMacro(HasScalar,int); 00091 00093 00097 vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY); 00098 vtkGetMacro(FileType, int); 00099 void SetFileTypeToUnknown() {this->SetFileType(FILE_TYPE_IS_UNKNOWN);} 00100 void SetFileTypeToText() {this->SetFileType(FILE_TYPE_IS_TEXT);} 00101 void SetFileTypeToBinary() {this->SetFileType(FILE_TYPE_IS_BINARY);} 00103 00105 00108 vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE); 00109 vtkGetMacro(DataType, int); 00110 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);} 00111 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);} 00113 00114 00115 protected: 00116 vtkParticleReader(); 00117 ~vtkParticleReader(); 00118 00119 void OpenFile(); 00120 00121 char *FileName; 00122 ifstream *File; 00123 00124 int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00125 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00126 00128 00136 int ProduceOutputFromTextFileDouble(vtkInformationVector *outputVector); 00137 int ProduceOutputFromTextFileFloat(vtkInformationVector *outputVector); 00139 00141 00143 int ProduceOutputFromBinaryFileDouble(vtkInformationVector *outputVector); 00144 int ProduceOutputFromBinaryFileFloat(vtkInformationVector *outputVector); 00146 00156 int DetermineFileType(); 00157 00159 void DoProgressUpdate( size_t & bytesRead, size_t & fileLength ); 00160 00161 //BTX 00163 00167 enum FILE_TYPE { FILE_TYPE_IS_UNKNOWN = 0, 00168 FILE_TYPE_IS_TEXT, FILE_TYPE_IS_BINARY }; 00169 //ETX 00171 00172 int HasScalar; 00174 00175 int FileType; 00176 // Description: 00177 // Used to specify the data type. 00178 int DataType; 00180 00182 00183 size_t Alliquot; 00184 // Description: 00185 // Count of the number of alliquots processed. 00186 size_t Count; 00188 00189 int SwapBytes; 00190 size_t NumberOfPoints; 00191 00192 private: 00193 vtkParticleReader(const vtkParticleReader&); // Not implemented. 00194 void operator=(const vtkParticleReader&); // Not implemented. 00195 }; 00196 00197 #endif