VTK  9.3.1
vtkParticleReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
28 #ifndef vtkParticleReader_h
29 #define vtkParticleReader_h
30 
31 #include "vtkIOGeometryModule.h" // For export macro
32 #include "vtkPolyDataAlgorithm.h"
33 
34 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
35 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class VTKIOGEOMETRY_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm
39 {
40 public:
41  static vtkParticleReader* New();
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
46 
49  vtkSetFilePathMacro(FileName);
50  vtkGetFilePathMacro(FileName);
52 
54 
68  void SetDataByteOrderToBigEndian();
69  void SetDataByteOrderToLittleEndian();
70  int GetDataByteOrder();
71  void SetDataByteOrder(int);
72  const char* GetDataByteOrderAsString();
74 
76 
80  vtkSetMacro(SwapBytes, vtkTypeBool);
81  vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
82  vtkBooleanMacro(SwapBytes, vtkTypeBool);
84 
86 
89  vtkSetMacro(HasScalar, vtkTypeBool);
90  vtkGetMacro(HasScalar, vtkTypeBool);
91  vtkBooleanMacro(HasScalar, vtkTypeBool);
93 
95 
104  vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY);
105  vtkGetMacro(FileType, int);
106  void SetFileTypeToUnknown() { this->SetFileType(FILE_TYPE_IS_UNKNOWN); }
107  void SetFileTypeToText() { this->SetFileType(FILE_TYPE_IS_TEXT); }
108  void SetFileTypeToBinary() { this->SetFileType(FILE_TYPE_IS_BINARY); }
110 
112 
117  vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE);
118  vtkGetMacro(DataType, int);
119  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
120  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
122 
123 protected:
125  ~vtkParticleReader() override;
126 
127  void OpenFile();
128 
129  char* FileName;
130  istream* File;
131 
134 
136 
146  int ProduceOutputFromTextFileDouble(vtkInformationVector* outputVector);
147  int ProduceOutputFromTextFileFloat(vtkInformationVector* outputVector);
149 
151 
155  int ProduceOutputFromBinaryFileDouble(vtkInformationVector* outputVector);
156  int ProduceOutputFromBinaryFileFloat(vtkInformationVector* outputVector);
158 
169  int DetermineFileType();
170 
174  void DoProgressUpdate(size_t& bytesRead, size_t& fileLength);
175 
184  {
185  FILE_TYPE_IS_UNKNOWN = 0,
187  FILE_TYPE_IS_BINARY
188  };
189 
194  int FileType;
198  int DataType;
199 
203  size_t Alliquot;
207  size_t Count;
208 
211 
212 private:
213  vtkParticleReader(const vtkParticleReader&) = delete;
214  void operator=(const vtkParticleReader&) = delete;
215 };
216 
217 VTK_ABI_NAMESPACE_END
218 #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:64
#define VTK_DOUBLE
Definition: vtkType.h:43
void SetDataTypeToFloat()
Get/Set the data type.
#define VTK_FLOAT
Definition: vtkType.h:42
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:28
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.