VTK
vtkParticleReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkParticleReader.h
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 =========================================================================*/
40 #ifndef vtkParticleReader_h
41 #define vtkParticleReader_h
42 
43 #include "vtkIOGeometryModule.h" // For export macro
44 #include "vtkPolyDataAlgorithm.h"
45 
46 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
47 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
48 
49 
50 class VTKIOGEOMETRY_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm
51 {
52 public:
53  static vtkParticleReader *New();
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
58 
61  vtkSetStringMacro(FileName);
62  vtkGetStringMacro(FileName);
64 
66 
80  void SetDataByteOrderToBigEndian();
81  void SetDataByteOrderToLittleEndian();
82  int GetDataByteOrder();
83  void SetDataByteOrder(int);
84  const char *GetDataByteOrderAsString();
86 
88 
92  vtkSetMacro(SwapBytes,vtkTypeBool);
93  vtkTypeBool GetSwapBytes() {return this->SwapBytes;}
94  vtkBooleanMacro(SwapBytes,vtkTypeBool);
96 
98 
101  vtkSetMacro(HasScalar,vtkTypeBool);
102  vtkGetMacro(HasScalar,vtkTypeBool);
103  vtkBooleanMacro(HasScalar,vtkTypeBool);
105 
107 
116  vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY);
117  vtkGetMacro(FileType, int);
118  void SetFileTypeToUnknown() {this->SetFileType(FILE_TYPE_IS_UNKNOWN);}
119  void SetFileTypeToText() {this->SetFileType(FILE_TYPE_IS_TEXT);}
120  void SetFileTypeToBinary() {this->SetFileType(FILE_TYPE_IS_BINARY);}
122 
124 
129  vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE);
130  vtkGetMacro(DataType, int);
131  void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}
132  void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}
134 
135 
136 protected:
138  ~vtkParticleReader() override;
139 
140  void OpenFile();
141 
142  char *FileName;
143  ifstream *File;
144 
147 
149 
159  int ProduceOutputFromTextFileDouble(vtkInformationVector *outputVector);
160  int ProduceOutputFromTextFileFloat(vtkInformationVector *outputVector);
162 
164 
168  int ProduceOutputFromBinaryFileDouble(vtkInformationVector *outputVector);
169  int ProduceOutputFromBinaryFileFloat(vtkInformationVector *outputVector);
171 
182  int DetermineFileType();
183 
187  void DoProgressUpdate( size_t & bytesRead, size_t & fileLength );
188 
197  enum FILE_TYPE { FILE_TYPE_IS_UNKNOWN = 0,
198  FILE_TYPE_IS_TEXT, FILE_TYPE_IS_BINARY };
199 
204  int FileType;
208  int DataType;
209 
213  size_t Alliquot;
217  size_t Count;
218 
221 
222 private:
223  vtkParticleReader(const vtkParticleReader&) = delete;
224  void operator=(const vtkParticleReader&) = delete;
225 };
226 
227 #endif
FILE_TYPE
Enumerate the supported file types.
vtkTypeBool GetSwapBytes()
Set/Get the byte swapping to explicitly swap the bytes of a file.
int FileType
Used to decide which reader should be used.
size_t Count
Count of the number of alliquots processed.
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
void SetFileTypeToText()
Get/Set the file type.
Read ASCII or binary particle data and (optionally) one scalar value associated with each particle...
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DOUBLE
Definition: vtkType.h:59
void SetDataTypeToFloat()
Get/Set the data type.
#define VTK_FLOAT
Definition: vtkType.h:58
Superclass for algorithms that produce only polydata as output.
size_t Alliquot
Set an alliquot of bytes.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
void SetFileTypeToBinary()
Get/Set the file type.
void SetDataTypeToDouble()
Get/Set the data type.
void SetFileTypeToUnknown()
Get/Set the file type.
Store zero or more vtkInformation instances.
int DataType
Used to specify the data type.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.