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 =========================================================================*/
42 #ifndef vtkAVSucdReader_h
43 #define vtkAVSucdReader_h
44 
45 #include "vtkIOGeometryModule.h" // For export macro
47 
48 class vtkIntArray;
49 class vtkFloatArray;
50 class vtkIdTypeArray;
52 
53 class VTKIOGEOMETRY_EXPORT vtkAVSucdReader : public vtkUnstructuredGridAlgorithm
54 {
55 public:
56  static vtkAVSucdReader *New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
64  vtkSetStringMacro(FileName);
65  vtkGetStringMacro(FileName);
67 
69 
72  vtkSetMacro(BinaryFile, vtkTypeBool);
73  vtkGetMacro(BinaryFile, vtkTypeBool);
74  vtkBooleanMacro(BinaryFile, vtkTypeBool);
76 
78 
81  vtkGetMacro(NumberOfCells,int);
83 
85 
88  vtkGetMacro(NumberOfNodes,int);
90 
92 
95  vtkGetMacro(NumberOfNodeFields,int);
97 
99 
102  vtkGetMacro(NumberOfCellFields,int);
104 
106 
110  vtkGetMacro(NumberOfFields,int);
112 
114 
117  vtkGetMacro(NumberOfNodeComponents,int);
118  vtkGetMacro(NumberOfCellComponents,int);
120 
122 
125  void SetByteOrderToBigEndian();
126  void SetByteOrderToLittleEndian();
127  const char *GetByteOrderAsString();
129 
130  vtkSetMacro(ByteOrder, int);
131  vtkGetMacro(ByteOrder, int);
132 
134 
139  int GetNumberOfPointArrays();
140  int GetNumberOfCellArrays();
141  const char* GetPointArrayName(int index);
142  const char* GetCellArrayName(int index);
143  int GetPointArrayStatus(const char* name);
144  int GetCellArrayStatus(const char* name);
145  void SetPointArrayStatus(const char* name, int status);
146  void SetCellArrayStatus(const char* name, int status);
148 
149  void DisableAllCellArrays();
150  void EnableAllCellArrays();
151  void DisableAllPointArrays();
152  void EnableAllPointArrays();
153 
154  // get min and max value for the index-th value of a cell component
155  // index varies from 0 to (veclen - 1)
156  void GetCellDataRange(int cellComp, int index, float *min, float *max);
157 
158  // get min and max value for the index-th value of a node component
159  // index varies from 0 to (veclen - 1)
160  void GetNodeDataRange(int nodeComp, int index, float *min, float *max);
161 
162 protected:
163  vtkAVSucdReader();
164  ~vtkAVSucdReader() override;
167 
168  char *FileName;
170 
179 
180  ifstream *FileStream;
181 
184 
186  int GetLabel(char *string, int number, char *label);
187 
188  enum
189  {
190  FILE_BIG_ENDIAN=0,
191  FILE_LITTLE_ENDIAN=1
192  };
194  {
195  PT = 0,
196  LINE = 1,
197  TRI = 2,
198  QUAD = 3,
199  TET = 4,
200  PYR = 5,
201  PRISM = 6,
202  HEX = 7
203  };
204 
205  struct DataInfo {
206  long foffset; // offset in binary file
207  int veclen; // number of components in the node or cell variable
208  float min[3]; // pre-calculated data minima (max size 3 for vectors)
209  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
210  };
211 
214 
215 private:
216  struct idMapping;
217 
218  void ReadFile(vtkUnstructuredGrid *output);
219  void ReadGeometry(vtkUnstructuredGrid *output,
220  idMapping& nodeMap,
221  idMapping& cellMap);
222  void ReadNodeData(vtkUnstructuredGrid *output, const idMapping& nodeMap);
223  void ReadCellData(vtkUnstructuredGrid *output, const idMapping& cellMap);
224 
225  int ReadFloatBlock(int n, float *block);
226  int ReadIntBlock(int n, int *block);
227  void ReadXYZCoords(vtkFloatArray *coords, idMapping& nodeMap);
228  void ReadBinaryCellTopology(vtkIntArray *material, int *types,
229  vtkIdTypeArray *listcells);
230  void ReadASCIICellTopology(vtkIntArray *material,
231  vtkUnstructuredGrid *output,
232  const idMapping& nodeMap,
233  idMapping& cellMap);
234 
235  vtkAVSucdReader(const vtkAVSucdReader&) = delete;
236  void operator=(const vtkAVSucdReader&) = delete;
237 };
238 
239 #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:41
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:45
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:39
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)