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 =========================================================================*/
34 #ifndef vtkParticleReader_h
35 #define vtkParticleReader_h
36 
37 #include "vtkIOGeometryModule.h" // For export macro
38 #include "vtkPolyDataAlgorithm.h"
39 
40 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
41 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
42 
43 
44 class VTKIOGEOMETRY_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm
45 {
46 public:
47  static vtkParticleReader *New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52 
55  vtkSetStringMacro(FileName);
56  vtkGetStringMacro(FileName);
58 
60 
74  void SetDataByteOrderToBigEndian();
75  void SetDataByteOrderToLittleEndian();
76  int GetDataByteOrder();
77  void SetDataByteOrder(int);
78  const char *GetDataByteOrderAsString();
80 
82 
86  vtkSetMacro(SwapBytes,vtkTypeBool);
87  vtkTypeBool GetSwapBytes() {return this->SwapBytes;}
88  vtkBooleanMacro(SwapBytes,vtkTypeBool);
90 
92 
95  vtkSetMacro(HasScalar,vtkTypeBool);
96  vtkGetMacro(HasScalar,vtkTypeBool);
97  vtkBooleanMacro(HasScalar,vtkTypeBool);
99 
101 
110  vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY);
111  vtkGetMacro(FileType, int);
112  void SetFileTypeToUnknown() {this->SetFileType(FILE_TYPE_IS_UNKNOWN);}
113  void SetFileTypeToText() {this->SetFileType(FILE_TYPE_IS_TEXT);}
114  void SetFileTypeToBinary() {this->SetFileType(FILE_TYPE_IS_BINARY);}
116 
118 
123  vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE);
124  vtkGetMacro(DataType, int);
125  void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}
126  void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}
128 
129 
130 protected:
132  ~vtkParticleReader() override;
133 
134  void OpenFile();
135 
136  char *FileName;
137  ifstream *File;
138 
141 
143 
153  int ProduceOutputFromTextFileDouble(vtkInformationVector *outputVector);
154  int ProduceOutputFromTextFileFloat(vtkInformationVector *outputVector);
156 
158 
162  int ProduceOutputFromBinaryFileDouble(vtkInformationVector *outputVector);
163  int ProduceOutputFromBinaryFileFloat(vtkInformationVector *outputVector);
165 
176  int DetermineFileType();
177 
181  void DoProgressUpdate( size_t & bytesRead, size_t & fileLength );
182 
191  enum FILE_TYPE { FILE_TYPE_IS_UNKNOWN = 0,
192  FILE_TYPE_IS_TEXT, FILE_TYPE_IS_BINARY };
193 
198  int FileType;
202  int DataType;
203 
207  size_t Alliquot;
211  size_t Count;
212 
215 
216 private:
217  vtkParticleReader(const vtkParticleReader&) = delete;
218  void operator=(const vtkParticleReader&) = delete;
219 };
220 
221 #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:33
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.