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 =========================================================================*/
41 #ifndef __vtkAVSucdReader_h
42 #define __vtkAVSucdReader_h
43 
45 
46 class vtkIntArray;
47 class vtkFloatArray;
48 class vtkIdTypeArray;
50 
52 {
53 public:
54  static vtkAVSucdReader *New();
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59 
60  vtkSetStringMacro(FileName);
61  vtkGetStringMacro(FileName);
63 
65 
67  vtkSetMacro(BinaryFile, int);
68  vtkGetMacro(BinaryFile, int);
69  vtkBooleanMacro(BinaryFile, int);
71 
73 
74  vtkGetMacro(NumberOfCells,int);
76 
78 
79  vtkGetMacro(NumberOfNodes,int);
81 
83 
84  vtkGetMacro(NumberOfNodeFields,int);
86 
88 
89  vtkGetMacro(NumberOfCellFields,int);
91 
93 
95  vtkGetMacro(NumberOfFields,int);
97 
99 
100  vtkGetMacro(NumberOfNodeComponents,int);
101  vtkGetMacro(NumberOfCellComponents,int);
103 
105 
106  void SetByteOrderToBigEndian();
107  void SetByteOrderToLittleEndian();
108  const char *GetByteOrderAsString();
110 
111  vtkSetMacro(ByteOrder, int);
112  vtkGetMacro(ByteOrder, int);
113 
115 
118  int GetNumberOfPointArrays();
119  int GetNumberOfCellArrays();
120  const char* GetPointArrayName(int index);
121  const char* GetCellArrayName(int index);
122  int GetPointArrayStatus(const char* name);
123  int GetCellArrayStatus(const char* name);
124  void SetPointArrayStatus(const char* name, int status);
125  void SetCellArrayStatus(const char* name, int status);
127 
128  void DisableAllCellArrays();
129  void EnableAllCellArrays();
130  void DisableAllPointArrays();
131  void EnableAllPointArrays();
132 
133  // get min and max value for the index-th value of a cell component
134  // index varies from 0 to (veclen - 1)
135  void GetCellDataRange(int cellComp, int index, float *min, float *max);
136 
137  // get min and max value for the index-th value of a node component
138  // index varies from 0 to (veclen - 1)
139  void GetNodeDataRange(int nodeComp, int index, float *min, float *max);
140 
141 protected:
142  vtkAVSucdReader();
143  ~vtkAVSucdReader();
146 
147  char *FileName;
149 
158 
159  ifstream *FileStream;
160 
163 
166  int GetLabel(char *string, int number, char *label);
167  //BTX
168  enum
169  {
170  FILE_BIG_ENDIAN=0,
171  FILE_LITTLE_ENDIAN=1
172  };
174  {
175  PT = 0,
176  LINE = 1,
177  TRI = 2,
178  QUAD = 3,
179  TET = 4,
180  PYR = 5,
181  PRISM = 6,
182  HEX = 7
183  };
184 
185  struct DataInfo {
186  long foffset; // offset in binary file
187  int veclen; // number of components in the node or cell variable
188  float min[3]; // pre-calculated data minima (max size 3 for vectors)
189  float max[3]; // pre-calculated data maxima (max size 3 for vectors)
190  };
191  //ETX
192 
195 
196 private:
197  void ReadFile(vtkUnstructuredGrid *output);
198  void ReadGeometry(vtkUnstructuredGrid *output);
199  void ReadNodeData(vtkUnstructuredGrid *output);
200  void ReadCellData(vtkUnstructuredGrid *output);
201 
202  int ReadFloatBlock(int n, float *block);
203  int ReadIntBlock(int n, int *block);
204  void ReadXYZCoords(vtkFloatArray *coords);
205  void ReadBinaryCellTopology(vtkIntArray *material, int *types,
206  vtkIdTypeArray *listcells);
207  void ReadASCIICellTopology(vtkIntArray *material, vtkUnstructuredGrid *output);
208 
209  vtkAVSucdReader(const vtkAVSucdReader&); // Not implemented.
210  void operator=(const vtkAVSucdReader&); // Not implemented.
211 };
212 
213 #endif