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 "vtkIOGeometryModule.h" // For export macro 00043 #include "vtkPolyDataAlgorithm.h" 00044 00045 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0 00046 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1 00047 00048 00049 class VTKIOGEOMETRY_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm 00050 { 00051 public: 00052 static vtkParticleReader *New(); 00053 vtkTypeMacro(vtkParticleReader,vtkPolyDataAlgorithm); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00057 00058 vtkSetStringMacro(FileName); 00059 vtkGetStringMacro(FileName); 00061 00063 00074 void SetDataByteOrderToBigEndian(); 00075 void SetDataByteOrderToLittleEndian(); 00076 int GetDataByteOrder(); 00077 void SetDataByteOrder(int); 00078 const char *GetDataByteOrderAsString(); 00080 00082 00084 vtkSetMacro(SwapBytes,int); 00085 int GetSwapBytes() {return this->SwapBytes;} 00086 vtkBooleanMacro(SwapBytes,int); 00088 00090 00091 vtkSetMacro(HasScalar,int); 00092 vtkGetMacro(HasScalar,int); 00093 vtkBooleanMacro(HasScalar,int); 00095 00097 00101 vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY); 00102 vtkGetMacro(FileType, int); 00103 void SetFileTypeToUnknown() {this->SetFileType(FILE_TYPE_IS_UNKNOWN);} 00104 void SetFileTypeToText() {this->SetFileType(FILE_TYPE_IS_TEXT);} 00105 void SetFileTypeToBinary() {this->SetFileType(FILE_TYPE_IS_BINARY);} 00107 00109 00112 vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE); 00113 vtkGetMacro(DataType, int); 00114 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);} 00115 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);} 00117 00118 00119 protected: 00120 vtkParticleReader(); 00121 ~vtkParticleReader(); 00122 00123 void OpenFile(); 00124 00125 char *FileName; 00126 ifstream *File; 00127 00128 int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00129 int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00130 00132 00140 int ProduceOutputFromTextFileDouble(vtkInformationVector *outputVector); 00141 int ProduceOutputFromTextFileFloat(vtkInformationVector *outputVector); 00143 00145 00147 int ProduceOutputFromBinaryFileDouble(vtkInformationVector *outputVector); 00148 int ProduceOutputFromBinaryFileFloat(vtkInformationVector *outputVector); 00150 00160 int DetermineFileType(); 00161 00163 void DoProgressUpdate( size_t & bytesRead, size_t & fileLength ); 00164 00165 //BTX 00167 00171 enum FILE_TYPE { FILE_TYPE_IS_UNKNOWN = 0, 00172 FILE_TYPE_IS_TEXT, FILE_TYPE_IS_BINARY }; 00173 //ETX 00175 00176 int HasScalar; 00178 int FileType; 00180 int DataType; 00181 00183 size_t Alliquot; 00185 size_t Count; 00186 00187 int SwapBytes; 00188 size_t NumberOfPoints; 00189 00190 private: 00191 vtkParticleReader(const vtkParticleReader&); // Not implemented. 00192 void operator=(const vtkParticleReader&); // Not implemented. 00193 }; 00194 00195 #endif