VTK  9.0.1
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 class VTKIOGEOMETRY_EXPORT vtkParticleReader : public vtkPolyDataAlgorithm
44 {
45 public:
46  static vtkParticleReader* New();
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
51 
54  vtkSetStringMacro(FileName);
55  vtkGetStringMacro(FileName);
57 
59 
73  void SetDataByteOrderToBigEndian();
74  void SetDataByteOrderToLittleEndian();
75  int GetDataByteOrder();
76  void SetDataByteOrder(int);
77  const char* GetDataByteOrderAsString();
79 
81 
85  vtkSetMacro(SwapBytes, vtkTypeBool);
86  vtkTypeBool GetSwapBytes() { return this->SwapBytes; }
87  vtkBooleanMacro(SwapBytes, vtkTypeBool);
89 
91 
94  vtkSetMacro(HasScalar, vtkTypeBool);
95  vtkGetMacro(HasScalar, vtkTypeBool);
96  vtkBooleanMacro(HasScalar, vtkTypeBool);
98 
100 
109  vtkSetClampMacro(FileType, int, FILE_TYPE_IS_UNKNOWN, FILE_TYPE_IS_BINARY);
110  vtkGetMacro(FileType, int);
111  void SetFileTypeToUnknown() { this->SetFileType(FILE_TYPE_IS_UNKNOWN); }
112  void SetFileTypeToText() { this->SetFileType(FILE_TYPE_IS_TEXT); }
113  void SetFileTypeToBinary() { this->SetFileType(FILE_TYPE_IS_BINARY); }
115 
117 
122  vtkSetClampMacro(DataType, int, VTK_FLOAT, VTK_DOUBLE);
123  vtkGetMacro(DataType, int);
124  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
125  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
127 
128 protected:
130  ~vtkParticleReader() override;
131 
132  void OpenFile();
133 
134  char* FileName;
135  istream* File;
136 
139 
141 
151  int ProduceOutputFromTextFileDouble(vtkInformationVector* outputVector);
152  int ProduceOutputFromTextFileFloat(vtkInformationVector* outputVector);
154 
156 
160  int ProduceOutputFromBinaryFileDouble(vtkInformationVector* outputVector);
161  int ProduceOutputFromBinaryFileFloat(vtkInformationVector* outputVector);
163 
174  int DetermineFileType();
175 
179  void DoProgressUpdate(size_t& bytesRead, size_t& fileLength);
180 
190  {
191  FILE_TYPE_IS_UNKNOWN = 0,
193  FILE_TYPE_IS_BINARY
194  };
195 
200  int FileType;
204  int DataType;
205 
209  size_t Alliquot;
213  size_t Count;
214 
217 
218 private:
219  vtkParticleReader(const vtkParticleReader&) = delete;
220  void operator=(const vtkParticleReader&) = delete;
221 };
222 
223 #endif
vtkParticleReader::GetSwapBytes
vtkTypeBool GetSwapBytes()
Definition: vtkParticleReader.h:86
vtkParticleReader::FILE_TYPE_IS_TEXT
@ FILE_TYPE_IS_TEXT
Definition: vtkParticleReader.h:192
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkParticleReader::File
istream * File
Definition: vtkParticleReader.h:135
vtkParticleReader::NumberOfPoints
size_t NumberOfPoints
Definition: vtkParticleReader.h:216
vtkParticleReader::FileType
int FileType
Used to decide which reader should be used.
Definition: vtkParticleReader.h:200
vtkPolyDataAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyDataAlgorithm.h
vtkParticleReader::SetFileTypeToText
void SetFileTypeToText()
Definition: vtkParticleReader.h:112
vtkParticleReader::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkParticleReader.h:124
vtkPolyDataAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkParticleReader::Alliquot
size_t Alliquot
Set an alliquot of bytes.
Definition: vtkParticleReader.h:209
vtkParticleReader::FileName
char * FileName
Definition: vtkParticleReader.h:134
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:52
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:53
vtkParticleReader::SetFileTypeToUnknown
void SetFileTypeToUnknown()
Definition: vtkParticleReader.h:111
vtkParticleReader
Read ASCII or binary particle data and (optionally) one scalar value associated with each particle.
Definition: vtkParticleReader.h:43
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkParticleReader::SetFileTypeToBinary
void SetFileTypeToBinary()
Definition: vtkParticleReader.h:113
vtkParticleReader::SwapBytes
vtkTypeBool SwapBytes
Definition: vtkParticleReader.h:215
vtkParticleReader::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkParticleReader.h:125
vtkParticleReader::DataType
int DataType
Used to specify the data type.
Definition: vtkParticleReader.h:204
vtkParticleReader::HasScalar
vtkTypeBool HasScalar
Definition: vtkParticleReader.h:196
vtkParticleReader::FILE_TYPE
FILE_TYPE
Enumerate the supported file types.
Definition: vtkParticleReader.h:189
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPolyDataAlgorithm::New
static vtkPolyDataAlgorithm * New()
vtkPolyDataAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkParticleReader::Count
size_t Count
Count of the number of alliquots processed.
Definition: vtkParticleReader.h:213
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41