VTK  9.0.2
vtkAVSucdReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAVSucdReader.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 =========================================================================*/
36 #ifndef vtkAVSucdReader_h
37 #define vtkAVSucdReader_h
38 
39 #include "vtkIOGeometryModule.h" // For export macro
41 
42 class vtkIntArray;
43 class vtkFloatArray;
44 class vtkIdTypeArray;
46 
47 class VTKIOGEOMETRY_EXPORT vtkAVSucdReader : public vtkUnstructuredGridAlgorithm
48 {
49 public:
50  static vtkAVSucdReader* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
58  vtkSetStringMacro(FileName);
59  vtkGetStringMacro(FileName);
61 
63 
66  vtkSetMacro(BinaryFile, vtkTypeBool);
67  vtkGetMacro(BinaryFile, vtkTypeBool);
68  vtkBooleanMacro(BinaryFile, vtkTypeBool);
70 
72 
75  vtkGetMacro(NumberOfCells, int);
77 
79 
82  vtkGetMacro(NumberOfNodes, int);
84 
86 
89  vtkGetMacro(NumberOfNodeFields, int);
91 
93 
96  vtkGetMacro(NumberOfCellFields, int);
98 
100 
104  vtkGetMacro(NumberOfFields, int);
106 
108 
111  vtkGetMacro(NumberOfNodeComponents, int);
112  vtkGetMacro(NumberOfCellComponents, int);
114 
116 
121  const char* GetByteOrderAsString();
123 
124  vtkSetMacro(ByteOrder, int);
125  vtkGetMacro(ByteOrder, int);
126 
128 
135  const char* GetPointArrayName(int index);
136  const char* GetCellArrayName(int index);
137  int GetPointArrayStatus(const char* name);
138  int GetCellArrayStatus(const char* name);
139  void SetPointArrayStatus(const char* name, int status);
140  void SetCellArrayStatus(const char* name, int status);
142 
147 
148  // get min and max value for the index-th value of a cell component
149  // index varies from 0 to (veclen - 1)
150  void GetCellDataRange(int cellComp, int index, float* min, float* max);
151 
152  // get min and max value for the index-th value of a node component
153  // index varies from 0 to (veclen - 1)
154  void GetNodeDataRange(int nodeComp, int index, float* min, float* max);
155 
156 protected:
158  ~vtkAVSucdReader() override;
161 
162  char* FileName;
164 
173 
174  istream* FileStream;
175 
178 
180  int GetLabel(char* string, int number, char* label);
181 
182  enum
183  {
184  FILE_BIG_ENDIAN = 0,
185  FILE_LITTLE_ENDIAN = 1
186  };
188  {
189  PT = 0,
190  LINE = 1,
191  TRI = 2,
192  QUAD = 3,
193  TET = 4,
194  PYR = 5,
195  PRISM = 6,
196  HEX = 7
197  };
198 
199  struct DataInfo
200  {
201  long foffset; // offset in binary file
202  int veclen; // number of components in the node or cell variable
203  float min[3]; // pre-calculated data minima (max size 3 for vectors)
204  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
205  };
206 
209 
210 private:
211  struct idMapping;
212 
213  void ReadFile(vtkUnstructuredGrid* output);
214  void ReadGeometry(vtkUnstructuredGrid* output, idMapping& nodeMap, idMapping& cellMap);
215  void ReadNodeData(vtkUnstructuredGrid* output, const idMapping& nodeMap);
216  void ReadCellData(vtkUnstructuredGrid* output, const idMapping& cellMap);
217 
218  int ReadFloatBlock(int n, float* block);
219  int ReadIntBlock(int n, int* block);
220  void ReadXYZCoords(vtkFloatArray* coords, idMapping& nodeMap);
221  void ReadBinaryCellTopology(vtkIntArray* material, int* types, vtkIdTypeArray* listcells);
222  void ReadASCIICellTopology(vtkIntArray* material, vtkUnstructuredGrid* output,
223  const idMapping& nodeMap, idMapping& cellMap);
224 
225  vtkAVSucdReader(const vtkAVSucdReader&) = delete;
226  void operator=(const vtkAVSucdReader&) = delete;
227 };
228 
229 #endif
reads a dataset in AVS "UCD" format
const char * GetByteOrderAsString()
void DisableAllPointArrays()
void SetCellArrayStatus(const char *name, int status)
void SetPointArrayStatus(const char *name, int status)
DataInfo * CellDataInfo
vtkDataArraySelection * CellDataArraySelection
DataInfo * NodeDataInfo
void DisableAllCellArrays()
int GetNumberOfPointArrays()
The following methods allow selective reading of solutions fields.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
int GetNumberOfCellArrays()
void EnableAllPointArrays()
vtkTypeBool BinaryFile
void SetByteOrderToBigEndian()
Set/Get the endian-ness of the binary file.
int GetLabel(char *string, int number, char *label)
void SetByteOrderToLittleEndian()
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetCellArrayName(int index)
static vtkAVSucdReader * New()
istream * FileStream
void GetNodeDataRange(int nodeComp, int index, float *min, float *max)
void EnableAllCellArrays()
void GetCellDataRange(int cellComp, int index, float *min, float *max)
int GetPointArrayStatus(const char *name)
~vtkAVSucdReader() override
int GetCellArrayStatus(const char *name)
const char * GetPointArrayName(int index)
vtkDataArraySelection * PointDataArraySelection
Store on/off settings for data arrays for a vtkSource.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
Superclass for algorithms that produce only unstructured grid as output.
dataset represents arbitrary combinations of all possible cell types
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define max(a, b)