VTK
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 
119  void SetByteOrderToBigEndian();
120  void SetByteOrderToLittleEndian();
121  const char *GetByteOrderAsString();
123 
124  vtkSetMacro(ByteOrder, int);
125  vtkGetMacro(ByteOrder, int);
126 
128 
133  int GetNumberOfPointArrays();
134  int GetNumberOfCellArrays();
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 
143  void DisableAllCellArrays();
144  void EnableAllCellArrays();
145  void DisableAllPointArrays();
146  void EnableAllPointArrays();
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:
157  vtkAVSucdReader();
158  ~vtkAVSucdReader() override;
161 
162  char *FileName;
164 
173 
174  ifstream *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  long foffset; // offset in binary file
201  int veclen; // number of components in the node or cell variable
202  float min[3]; // pre-calculated data minima (max size 3 for vectors)
203  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
204  };
205 
208 
209 private:
210  struct idMapping;
211 
212  void ReadFile(vtkUnstructuredGrid *output);
213  void ReadGeometry(vtkUnstructuredGrid *output,
214  idMapping& nodeMap,
215  idMapping& cellMap);
216  void ReadNodeData(vtkUnstructuredGrid *output, const idMapping& nodeMap);
217  void ReadCellData(vtkUnstructuredGrid *output, const idMapping& cellMap);
218 
219  int ReadFloatBlock(int n, float *block);
220  int ReadIntBlock(int n, int *block);
221  void ReadXYZCoords(vtkFloatArray *coords, idMapping& nodeMap);
222  void ReadBinaryCellTopology(vtkIntArray *material, int *types,
223  vtkIdTypeArray *listcells);
224  void ReadASCIICellTopology(vtkIntArray *material,
225  vtkUnstructuredGrid *output,
226  const idMapping& nodeMap,
227  idMapping& cellMap);
228 
229  vtkAVSucdReader(const vtkAVSucdReader&) = delete;
230  void operator=(const vtkAVSucdReader&) = delete;
231 };
232 
233 #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:35
DataInfo * NodeDataInfo
dynamic, self-adjusting array of vtkIdType
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int vtkTypeBool
Definition: vtkABI.h:69
ifstream * FileStream
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
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:33
Store on/off settings for data arrays for a vtkSource.
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)