VTK  9.3.1
vtkAVSucdReader.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
27 #ifndef vtkAVSucdReader_h
28 #define vtkAVSucdReader_h
29 
30 #include "vtkIOGeometryModule.h" // For export macro
32 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkIntArray;
35 class vtkFloatArray;
36 class vtkIdTypeArray;
38 
39 class VTKIOGEOMETRY_EXPORT vtkAVSucdReader : public vtkUnstructuredGridAlgorithm
40 {
41 public:
42  static vtkAVSucdReader* New();
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
47 
50  vtkSetFilePathMacro(FileName);
51  vtkGetFilePathMacro(FileName);
53 
55 
58  vtkSetMacro(BinaryFile, vtkTypeBool);
59  vtkGetMacro(BinaryFile, vtkTypeBool);
60  vtkBooleanMacro(BinaryFile, vtkTypeBool);
62 
64 
67  vtkGetMacro(NumberOfCells, int);
69 
71 
74  vtkGetMacro(NumberOfNodes, int);
76 
78 
81  vtkGetMacro(NumberOfNodeFields, int);
83 
85 
88  vtkGetMacro(NumberOfCellFields, int);
90 
92 
96  vtkGetMacro(NumberOfFields, int);
98 
100 
103  vtkGetMacro(NumberOfNodeComponents, int);
104  vtkGetMacro(NumberOfCellComponents, int);
106 
108 
111  void SetByteOrderToBigEndian();
112  void SetByteOrderToLittleEndian();
113  const char* GetByteOrderAsString();
115 
116  vtkSetMacro(ByteOrder, int);
117  vtkGetMacro(ByteOrder, int);
118 
120 
125  int GetNumberOfPointArrays();
126  int GetNumberOfCellArrays();
127  const char* GetPointArrayName(int index);
128  const char* GetCellArrayName(int index);
129  int GetPointArrayStatus(const char* name);
130  int GetCellArrayStatus(const char* name);
131  void SetPointArrayStatus(const char* name, int status);
132  void SetCellArrayStatus(const char* name, int status);
134 
135  void DisableAllCellArrays();
136  void EnableAllCellArrays();
137  void DisableAllPointArrays();
138  void EnableAllPointArrays();
139 
140  // get min and max value for the index-th value of a cell component
141  // index varies from 0 to (veclen - 1)
142  void GetCellDataRange(int cellComp, int index, float* min, float* max);
143 
144  // get min and max value for the index-th value of a node component
145  // index varies from 0 to (veclen - 1)
146  void GetNodeDataRange(int nodeComp, int index, float* min, float* max);
147 
148 protected:
149  vtkAVSucdReader();
150  ~vtkAVSucdReader() override;
153 
154  char* FileName;
156 
165 
166  istream* FileStream;
167 
170 
172  int GetLabel(char* string, int number, char* label);
173 
174  enum
175  {
176  FILE_BIG_ENDIAN = 0,
177  FILE_LITTLE_ENDIAN = 1
178  };
180  {
181  PT = 0,
182  LINE = 1,
183  TRI = 2,
184  QUAD = 3,
185  TET = 4,
186  PYR = 5,
187  PRISM = 6,
188  HEX = 7
189  };
190 
191  struct DataInfo
192  {
193  long foffset; // offset in binary file
194  int veclen; // number of components in the node or cell variable
195  float min[3]; // pre-calculated data minima (max size 3 for vectors)
196  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
197  };
198 
201 
202 private:
203  struct idMapping;
204 
205  void ReadFile(vtkUnstructuredGrid* output);
206  void ReadGeometry(vtkUnstructuredGrid* output, idMapping& nodeMap, idMapping& cellMap);
207  void ReadNodeData(vtkUnstructuredGrid* output, const idMapping& nodeMap);
208  void ReadCellData(vtkUnstructuredGrid* output, const idMapping& cellMap);
209 
210  int ReadFloatBlock(int n, float* block);
211  int ReadIntBlock(int n, int* block);
212  void ReadXYZCoords(vtkFloatArray* coords, idMapping& nodeMap);
213  void ReadBinaryCellTopology(vtkIntArray* material, int* types, vtkIdTypeArray* listcells);
214  void ReadASCIICellTopology(vtkIntArray* material, vtkUnstructuredGrid* output,
215  const idMapping& nodeMap, idMapping& cellMap);
216 
217  vtkAVSucdReader(const vtkAVSucdReader&) = delete;
218  void operator=(const vtkAVSucdReader&) = delete;
219 };
220 
221 VTK_ABI_NAMESPACE_END
222 #endif
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
Store vtkAlgorithm input/output information.
vtkDataArraySelection * PointDataArraySelection
static vtkUnstructuredGridAlgorithm * New()
vtkTypeBool BinaryFile
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
DataInfo * NodeDataInfo
dynamic, self-adjusting array of vtkIdType
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int vtkTypeBool
Definition: vtkABI.h:64
istream * FileStream
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
Store on/off settings for data arrays, etc.
dataset represents arbitrary combinations of all possible cell types
vtkDataArraySelection * CellDataArraySelection
Superclass for algorithms that produce only unstructured grid as output.
Store zero or more vtkInformation instances.
DataInfo * CellDataInfo
reads a dataset in AVS "UCD" format
#define max(a, b)