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 =========================================================================*/
38 #ifndef __vtkAVSucdReader_h
39 #define __vtkAVSucdReader_h
40 
42 
43 class vtkIntArray;
44 class vtkFloatArray;
45 class vtkIdTypeArray;
47 
49 {
50 public:
51  static vtkAVSucdReader *New();
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
56 
57  vtkSetStringMacro(FileName);
58  vtkGetStringMacro(FileName);
60 
62 
64  vtkSetMacro(BinaryFile, int);
65  vtkGetMacro(BinaryFile, int);
66  vtkBooleanMacro(BinaryFile, int);
68 
70 
71  vtkGetMacro(NumberOfCells,int);
73 
75 
76  vtkGetMacro(NumberOfNodes,int);
78 
80 
81  vtkGetMacro(NumberOfNodeFields,int);
83 
85 
86  vtkGetMacro(NumberOfCellFields,int);
88 
90 
92  vtkGetMacro(NumberOfFields,int);
94 
96 
97  vtkGetMacro(NumberOfNodeComponents,int);
98  vtkGetMacro(NumberOfCellComponents,int);
100 
102 
103  void SetByteOrderToBigEndian();
104  void SetByteOrderToLittleEndian();
105  const char *GetByteOrderAsString();
107 
108  vtkSetMacro(ByteOrder, int);
109  vtkGetMacro(ByteOrder, int);
110 
112 
115  int GetNumberOfPointArrays();
116  int GetNumberOfCellArrays();
117  const char* GetPointArrayName(int index);
118  const char* GetCellArrayName(int index);
119  int GetPointArrayStatus(const char* name);
120  int GetCellArrayStatus(const char* name);
121  void SetPointArrayStatus(const char* name, int status);
122  void SetCellArrayStatus(const char* name, int status);
124 
125  void DisableAllCellArrays();
126  void EnableAllCellArrays();
127  void DisableAllPointArrays();
128  void EnableAllPointArrays();
129 
130  // get min and max value for the index-th value of a cell component
131  // index varies from 0 to (veclen - 1)
132  void GetCellDataRange(int cellComp, int index, float *min, float *max);
133 
134  // get min and max value for the index-th value of a node component
135  // index varies from 0 to (veclen - 1)
136  void GetNodeDataRange(int nodeComp, int index, float *min, float *max);
137 
138 protected:
139  vtkAVSucdReader();
140  ~vtkAVSucdReader();
143 
144  char *FileName;
146 
155 
156  ifstream *FileStream;
157 
160 
163  int GetLabel(char *string, int number, char *label);
164  //BTX
165  enum
166  {
167  FILE_BIG_ENDIAN=0,
168  FILE_LITTLE_ENDIAN=1
169  };
171  {
172  PT = 0,
173  LINE = 1,
174  TRI = 2,
175  QUAD = 3,
176  TET = 4,
177  PYR = 5,
178  PRISM = 6,
179  HEX = 7
180  };
181 
182  struct DataInfo {
183  long foffset; // offset in binary file
184  int veclen; // number of components in the node or cell variable
185  float min[3]; // pre-calculated data minima (max size 3 for vectors)
186  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
187  };
188  //ETX
189 
192 
193 private:
194  void ReadFile(vtkUnstructuredGrid *output);
195  void ReadGeometry(vtkUnstructuredGrid *output);
196  void ReadNodeData(vtkUnstructuredGrid *output);
197  void ReadCellData(vtkUnstructuredGrid *output);
198 
199  int ReadFloatBlock(int n, float *block);
200  int ReadIntBlock(int n, int *block);
201  void ReadXYZCoords(vtkFloatArray *coords);
202  void ReadBinaryCellTopology(vtkIntArray *material, int *types,
203  vtkIdTypeArray *listcells);
204  void ReadASCIICellTopology(vtkIntArray *material, vtkUnstructuredGrid *output);
205 
206  vtkAVSucdReader(const vtkAVSucdReader&); // Not implemented.
207  void operator=(const vtkAVSucdReader&); // Not implemented.
208 };
209 
210 #endif