VTK
vtkDataReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDataReader.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 =========================================================================*/
28 #ifndef vtkDataReader_h
29 #define vtkDataReader_h
30 
31 #include "vtkIOLegacyModule.h" // For export macro
32 #include "vtkAlgorithm.h"
33 #include "vtkStdString.h" // For API using strings
34 
35 #define VTK_ASCII 1
36 #define VTK_BINARY 2
37 
38 class vtkAbstractArray;
39 class vtkCharArray;
40 class vtkDataSet;
42 class vtkFieldData;
43 class vtkGraph;
44 class vtkPointSet;
45 class vtkRectilinearGrid;
46 class vtkTable;
47 
49 {
50 public:
51  enum FieldType
52  {
55  FIELD_DATA
56  };
57 
58  static vtkDataReader *New();
59  vtkTypeMacro(vtkDataReader,vtkAlgorithm);
60  void PrintSelf(ostream& os, vtkIndent indent);
61 
63 
64  vtkSetStringMacro(FileName);
65  vtkGetStringMacro(FileName);
67 
69 
71  int IsFileValid(const char *dstype);
73  return this->IsFileValid("structured_points");};
75  return this->IsFileValid("polydata");};
77  return this->IsFileValid("structured_grid");};
79  return this->IsFileValid("unstructured_grid");};
81  return this->IsFileValid("rectilinear_grid");};
83 
85 
89  void SetInputString(const char *in);
90  vtkGetStringMacro(InputString);
91  void SetInputString(const char *in, int len);
92  vtkGetMacro(InputStringLength, int);
93  void SetBinaryInputString(const char *, int len);
94  void SetInputString(const vtkStdString& input)
95  { this->SetBinaryInputString(input.c_str(), static_cast<int>(input.length())); }
97 
99 
105  virtual void SetInputArray(vtkCharArray*);
106  vtkGetObjectMacro(InputArray, vtkCharArray);
108 
110 
111  vtkGetStringMacro(Header);
113 
115 
117  vtkSetMacro(ReadFromInputString,int);
118  vtkGetMacro(ReadFromInputString,int);
119  vtkBooleanMacro(ReadFromInputString,int);
121 
123 
125  vtkGetMacro(FileType,int);
127 
129 
134  {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
136  {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
138  {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
140  {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
142  {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
144  {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
146 
148 
151  const char *GetScalarsNameInFile(int i);
152  const char *GetVectorsNameInFile(int i);
153  const char *GetTensorsNameInFile(int i);
154  const char *GetNormalsNameInFile(int i);
155  const char *GetTCoordsNameInFile(int i);
156  const char *GetFieldDataNameInFile(int i);
158 
160 
162  vtkSetStringMacro(ScalarsName);
163  vtkGetStringMacro(ScalarsName);
165 
167 
169  vtkSetStringMacro(VectorsName);
170  vtkGetStringMacro(VectorsName);
172 
174 
176  vtkSetStringMacro(TensorsName);
177  vtkGetStringMacro(TensorsName);
179 
181 
183  vtkSetStringMacro(NormalsName);
184  vtkGetStringMacro(NormalsName);
186 
188 
190  vtkSetStringMacro(TCoordsName);
191  vtkGetStringMacro(TCoordsName);
193 
195 
198  vtkSetStringMacro(LookupTableName);
199  vtkGetStringMacro(LookupTableName);
201 
203 
205  vtkSetStringMacro(FieldDataName);
206  vtkGetStringMacro(FieldDataName);
208 
210 
211  vtkSetMacro(ReadAllScalars,int);
212  vtkGetMacro(ReadAllScalars,int);
213  vtkBooleanMacro(ReadAllScalars,int);
215 
217 
218  vtkSetMacro(ReadAllVectors,int);
219  vtkGetMacro(ReadAllVectors,int);
220  vtkBooleanMacro(ReadAllVectors,int);
222 
224 
225  vtkSetMacro(ReadAllNormals,int);
226  vtkGetMacro(ReadAllNormals,int);
227  vtkBooleanMacro(ReadAllNormals,int);
229 
231 
232  vtkSetMacro(ReadAllTensors,int);
233  vtkGetMacro(ReadAllTensors,int);
234  vtkBooleanMacro(ReadAllTensors,int);
236 
238 
239  vtkSetMacro(ReadAllColorScalars,int);
240  vtkGetMacro(ReadAllColorScalars,int);
241  vtkBooleanMacro(ReadAllColorScalars,int);
243 
245 
246  vtkSetMacro(ReadAllTCoords,int);
247  vtkGetMacro(ReadAllTCoords,int);
248  vtkBooleanMacro(ReadAllTCoords,int);
250 
252 
253  vtkSetMacro(ReadAllFields,int);
254  vtkGetMacro(ReadAllFields,int);
255  vtkBooleanMacro(ReadAllFields,int);
257 
259  int OpenVTKFile();
260 
262  int ReadHeader();
263 
267  int ReadCellData(vtkDataSet *ds, int numCells);
268 
272  int ReadPointData(vtkDataSet *ds, int numPts);
273 
275  int ReadPoints(vtkPointSet *ps, int numPts);
276 
278  int ReadPoints(vtkGraph *g, int numPts);
279 
283  int ReadVertexData(vtkGraph *g, int numVertices);
284 
288  int ReadEdgeData(vtkGraph *g, int numEdges);
289 
291  int ReadRowData(vtkTable *t, int numEdges);
292 
294  int ReadCells(int size, int *data);
295 
297  int ReadCells(int size, int *data, int skip1, int read2, int skip3);
298 
301  int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
302 
304 
305  vtkAbstractArray *ReadArray(const char *dataType, int numTuples, int numComp);
306  vtkFieldData *ReadFieldData(FieldType fieldType = FIELD_DATA);
308 
310 
312  vtkGetMacro(FileMajorVersion, int);
313  vtkGetMacro(FileMinorVersion, int);
315 
316 //BTX
318 
320  int Read(char *);
321  int Read(unsigned char *);
322  int Read(short *);
323  int Read(unsigned short *);
324  int Read(int *);
325  int Read(unsigned int *);
326  int Read(long *);
327  int Read(unsigned long *);
328  int Read(long long *result);
329  int Read(unsigned long long *result);
330  int Read(float *);
331  int Read(double *);
332 //ETX
334 
336  void CloseVTKFile();
337 
338 //BTX
341  int ReadLine(char result[256]);
342 
345  int ReadString(char result[256]);
346 
348  char *LowerCase(char *str, const size_t len=256);
349 
351 
352  istream *GetIStream() {return this->IS;};
353 //ETX
355 
358  virtual int ReadMetaData(vtkInformation *) { return 1; }
359 
360 protected:
361  vtkDataReader();
362  ~vtkDataReader();
363 
364  char *FileName;
365  int FileType;
366  istream *IS;
367 
368  char *ScalarsName;
369  char *VectorsName;
370  char *TensorsName;
371  char *TCoordsName;
372  char *NormalsName;
375  char *ScalarLut;
376 
378  char *InputString;
381 
382  void SetScalarLut(const char* lut);
383  vtkGetStringMacro(ScalarLut);
384 
385  char *Header;
386 
387  int ReadScalarData(vtkDataSetAttributes *a, int num);
388  int ReadVectorData(vtkDataSetAttributes *a, int num);
389  int ReadNormalData(vtkDataSetAttributes *a, int num);
390  int ReadTensorData(vtkDataSetAttributes *a, int num);
391  int ReadCoScalarData(vtkDataSetAttributes *a, int num);
392  int ReadLutData(vtkDataSetAttributes *a);
393  int ReadTCoordsData(vtkDataSetAttributes *a, int num);
394  int ReadGlobalIds(vtkDataSetAttributes *a, int num);
395  int ReadPedigreeIds(vtkDataSetAttributes *a, int num);
396  int ReadEdgeFlags(vtkDataSetAttributes *a, int num);
397 
398  int ReadDataSetData(vtkDataSet *ds);
399 
400  // This supports getting additional information from vtk files
420 
430 
431  void InitializeCharacteristics();
432  int CharacterizeFile(); //read entire file, storing important characteristics
433  void CheckFor(const char* name, char *line, int &num, char** &array,
434  int& allocSize);
435 
437 
440  int DecodeString(char *resname, const char* name);
441 
446  { return 1; }
449  { return 1; }
452  { return 1; }
453 
454 private:
455  vtkDataReader(const vtkDataReader&); // Not implemented.
456  void operator=(const vtkDataReader&); // Not implemented.
457 
458  void ConvertGhostLevelsToGhostType(
459  FieldType fieldType, vtkAbstractArray *data) const;
460 };
461 
462 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
int GetNumberOfScalarsInFile()
a dataset that is topologically regular with variable spacing in the three coordinate directions ...
int NumberOfScalarsInFile
char * FieldDataName
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
Abstract superclass for all arrays.
void SetInputString(const vtkStdString &input)
Definition: vtkDataReader.h:94
int IsFilePolyData()
Definition: vtkDataReader.h:74
char ** ScalarsNameInFile
int IsFileRectilinearGrid()
Definition: vtkDataReader.h:80
record modification and/or execution time
Definition: vtkTimeStamp.h:34
int NumberOfTensorsInFile
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int NumberOfFieldDataInFile
virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo)
int GetNumberOfTCoordsInFile()
char * LookupTableName
char * NormalsName
int GetNumberOfNormalsInFile()
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:41
int NormalsNameAllocSize
int IsFileStructuredGrid()
Definition: vtkDataReader.h:76
int TensorsNameAllocSize
#define VTKIOLEGACY_EXPORT
vtkTimeStamp CharacteristicsTime
char ** TensorsNameInFile
int GetNumberOfFieldDataInFile()
Base class for graph data types.
Definition: vtkGraph.h:288
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:42
helper superclass for objects that read vtk data files
Definition: vtkDataReader.h:48
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:61
char * ScalarsName
int TCoordsNameAllocSize
a simple class to control print indentation
Definition: vtkIndent.h:38
istream * GetIStream()
char ** FieldDataNameInFile
int ScalarsNameAllocSize
represent and manipulate attribute data in a dataset
int NumberOfNormalsInFile
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
char * TensorsName
int GetNumberOfVectorsInFile()
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
char * TCoordsName
char * InputString
int IsFileUnstructuredGrid()
Definition: vtkDataReader.h:78
char ** VectorsNameInFile
int IsFileStructuredPoints()
Definition: vtkDataReader.h:72
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
int VectorsNameAllocSize
char ** NormalsNameInFile
virtual int ReadMetaData(vtkInformation *)
vtkCharArray * InputArray
istream * IS
char * VectorsName
char ** TCoordsNameInFile
int FieldDataNameAllocSize
int GetNumberOfTensorsInFile()
int NumberOfTCoordsInFile
#define IS
represent and manipulate fields of data
Definition: vtkFieldData.h:55
int NumberOfVectorsInFile
void PrintSelf(ostream &os, vtkIndent indent)