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=========================================================================*/
29#ifndef vtkDataReader_h
30#define vtkDataReader_h
31
32#include "vtkIOLegacyModule.h" // For export macro
33#include "vtkAlgorithm.h"
34#include "vtkStdString.h" // For API using strings
35
36#define VTK_ASCII 1
37#define VTK_BINARY 2
38
40class vtkCharArray;
41class vtkDataSet;
43class vtkFieldData;
44class vtkGraph;
45class vtkPointSet;
47class vtkTable;
48
49class VTKIOLEGACY_EXPORT vtkDataReader : public vtkAlgorithm
50{
51public:
53 {
56 FIELD_DATA
57 };
58
59 static vtkDataReader *New();
61 void PrintSelf(ostream& os, vtkIndent indent);
62
64
67 vtkSetStringMacro(FileName);
70
72
76 int IsFileValid(const char *dstype);
78 return this->IsFileValid("structured_points");};
80 return this->IsFileValid("polydata");};
82 return this->IsFileValid("structured_grid");};
84 return this->IsFileValid("unstructured_grid");};
86 return this->IsFileValid("rectilinear_grid");};
88
90
96 void SetInputString(const char *in);
97 vtkGetStringMacro(InputString);
98 void SetInputString(const char *in, int len);
99 vtkGetMacro(InputStringLength, int);
100 void SetBinaryInputString(const char *, int len);
101 void SetInputString(const vtkStdString& input)
102 { this->SetBinaryInputString(input.c_str(), static_cast<int>(input.length())); }
104
106
115 vtkGetObjectMacro(InputArray, vtkCharArray);
117
119
124
126
130 vtkSetMacro(ReadFromInputString,int);
131 vtkGetMacro(ReadFromInputString,int);
132 vtkBooleanMacro(ReadFromInputString,int);
134
136
140 vtkGetMacro(FileType,int);
142
151 {this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
153 {this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
155 {this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
157 {this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
159 {this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
161 {this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
162
164
169 const char *GetScalarsNameInFile(int i);
170 const char *GetVectorsNameInFile(int i);
171 const char *GetTensorsNameInFile(int i);
172 const char *GetNormalsNameInFile(int i);
173 const char *GetTCoordsNameInFile(int i);
174 const char *GetFieldDataNameInFile(int i);
176
178
182 vtkSetStringMacro(ScalarsName);
183 vtkGetStringMacro(ScalarsName);
185
187
191 vtkSetStringMacro(VectorsName);
192 vtkGetStringMacro(VectorsName);
194
196
200 vtkSetStringMacro(TensorsName);
201 vtkGetStringMacro(TensorsName);
203
205
209 vtkSetStringMacro(NormalsName);
210 vtkGetStringMacro(NormalsName);
212
214
218 vtkSetStringMacro(TCoordsName);
219 vtkGetStringMacro(TCoordsName);
221
223
227 vtkSetStringMacro(LookupTableName);
228 vtkGetStringMacro(LookupTableName);
230
232
236 vtkSetStringMacro(FieldDataName);
237 vtkGetStringMacro(FieldDataName);
239
241
244 vtkSetMacro(ReadAllScalars,int);
245 vtkGetMacro(ReadAllScalars,int);
246 vtkBooleanMacro(ReadAllScalars,int);
248
250
253 vtkSetMacro(ReadAllVectors,int);
254 vtkGetMacro(ReadAllVectors,int);
255 vtkBooleanMacro(ReadAllVectors,int);
257
259
262 vtkSetMacro(ReadAllNormals,int);
263 vtkGetMacro(ReadAllNormals,int);
264 vtkBooleanMacro(ReadAllNormals,int);
266
268
271 vtkSetMacro(ReadAllTensors,int);
272 vtkGetMacro(ReadAllTensors,int);
273 vtkBooleanMacro(ReadAllTensors,int);
275
277
280 vtkSetMacro(ReadAllColorScalars,int);
281 vtkGetMacro(ReadAllColorScalars,int);
282 vtkBooleanMacro(ReadAllColorScalars,int);
284
286
289 vtkSetMacro(ReadAllTCoords,int);
290 vtkGetMacro(ReadAllTCoords,int);
291 vtkBooleanMacro(ReadAllTCoords,int);
293
295
298 vtkSetMacro(ReadAllFields,int);
299 vtkGetMacro(ReadAllFields,int);
300 vtkBooleanMacro(ReadAllFields,int);
302
307
312
318 int ReadCellData(vtkDataSet *ds, int numCells);
319
325 int ReadPointData(vtkDataSet *ds, int numPts);
326
330 int ReadPoints(vtkPointSet *ps, int numPts);
331
335 int ReadPoints(vtkGraph *g, int numPts);
336
342 int ReadVertexData(vtkGraph *g, int numVertices);
343
349 int ReadEdgeData(vtkGraph *g, int numEdges);
350
354 int ReadRowData(vtkTable *t, int numEdges);
355
359 int ReadCells(int size, int *data);
360
364 int ReadCells(int size, int *data, int skip1, int read2, int skip3);
365
370 int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
371
373
376 vtkAbstractArray *ReadArray(const char *dataType, int numTuples, int numComp);
377 vtkFieldData *ReadFieldData(FieldType fieldType = FIELD_DATA);
379
381
385 vtkGetMacro(FileMajorVersion, int);
386 vtkGetMacro(FileMinorVersion, int);
388
390
394 int Read(char *);
395 int Read(unsigned char *);
396 int Read(short *);
397 int Read(unsigned short *);
398 int Read(int *);
399 int Read(unsigned int *);
400 int Read(long *);
401 int Read(unsigned long *);
402 int Read(long long *result);
403 int Read(unsigned long long *result);
404 int Read(float *);
405 int Read(double *);
407
412 size_t Peek(char *str, size_t n);
413
414
419
424 int ReadLine(char result[256]);
425
430 int ReadString(char result[256]);
431
435 char *LowerCase(char *str, const size_t len=256);
436
440 istream *GetIStream() {return this->IS;};
441
446 virtual int ReadMetaData(vtkInformation *) { return 1; }
447
448protected:
451
452 char *FileName;
454 istream *IS;
455
464
469
470 void SetScalarLut(const char* lut);
472
473 char *Header;
474
485
490
492
493 // This supports getting additional information from vtk files
513
523
525 int CharacterizeFile(); //read entire file, storing important characteristics
526 void CheckFor(const char* name, char *line, int &num, char** &array,
527 int& allocSize);
528
530
536 int DecodeString(char *resname, const char* name);
537
542 { return 1; }
545 { return 1; }
548 { return 1; }
549
550private:
551 vtkDataReader(const vtkDataReader&) VTK_DELETE_FUNCTION;
552 void operator=(const vtkDataReader&) VTK_DELETE_FUNCTION;
553
554 void ConvertGhostLevelsToGhostType(
555 FieldType fieldType, vtkAbstractArray *data) const;
556};
557
558#endif
Abstract superclass for all arrays.
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:60
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:39
helper superclass for objects that read vtk data files
Definition: vtkDataReader.h:50
char * InputString
int ReadVectorData(vtkDataSetAttributes *a, int num)
int Read(char *)
Internal function to read in a value.
int Read(unsigned long long *result)
int GetNumberOfVectorsInFile()
const char * GetFieldDataNameInFile(int i)
const char * GetScalarsNameInFile(int i)
What is the name of the ith attribute of a certain type in this file? This requires reading the file,...
int ReadTensorData(vtkDataSetAttributes *a, int num)
virtual int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
int ReadString(char result[256])
Internal function to read in a string up to 256 characters.
void SetScalarLut(const char *lut)
int ReadCoScalarData(vtkDataSetAttributes *a, int num)
char * LowerCase(char *str, const size_t len=256)
Helper method for reading in data.
virtual void SetInputArray(vtkCharArray *)
Specify the vtkCharArray to be used when reading from a string.
int ReadEdgeFlags(vtkDataSetAttributes *a, int num)
char ** NormalsNameInFile
int ReadEdgeData(vtkGraph *g, int numEdges)
Read the edge data of a vtk data file.
int Read(unsigned short *)
void CheckFor(const char *name, char *line, int &num, char **&array, int &allocSize)
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
int TCoordsNameAllocSize
int ScalarsNameAllocSize
char * VectorsName
int IsFileRectilinearGrid()
Definition: vtkDataReader.h:85
vtkAbstractArray * ReadArray(const char *dataType, int numTuples, int numComp)
Helper functions for reading data.
void SetInputString(const char *in)
Specify the InputString for use when reading from a character array.
int Read(short *)
virtual int ReadMetaData(vtkInformation *)
Read the meta information from the file.
int NumberOfTensorsInFile
vtkTimeStamp CharacteristicsTime
int ReadDataSetData(vtkDataSet *ds)
int ReadPoints(vtkGraph *g, int numPts)
Read point coordinates.
int ReadHeader()
Read the header of a vtk data file.
int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords)
Read the coordinates for a rectilinear grid.
int Read(long *)
char ** TensorsNameInFile
char * TCoordsName
void InitializeCharacteristics()
int Read(unsigned long *)
istream * GetIStream()
Return the istream being used to read in the data.
const char * GetNormalsNameInFile(int i)
int DecodeString(char *resname, const char *name)
Decode a string.
void SetBinaryInputString(const char *, int len)
int ReadCells(int size, int *data)
Read a bunch of "cells".
int ReadScalarData(vtkDataSetAttributes *a, int num)
void SetInputString(const char *in, int len)
int NumberOfVectorsInFile
int ReadNormalData(vtkDataSetAttributes *a, int num)
int ReadPedigreeIds(vtkDataSetAttributes *a, int num)
int Read(float *)
char * NormalsName
int GetNumberOfTensorsInFile()
int CharacterizeFile()
const char * GetTCoordsNameInFile(int i)
int ReadCells(int size, int *data, int skip1, int read2, int skip3)
Read a piece of the cells (for streaming compliance)
int ReadInformation(vtkInformation *info, int numKeys)
Format is detailed here.
int Read(double *)
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int NormalsNameAllocSize
int Read(int *)
static vtkDataReader * New()
int ReadPointData(vtkDataSet *ds, int numPts)
Read the point data of a vtk data file.
char * LookupTableName
int ReadRowData(vtkTable *t, int numEdges)
Read the row data of a vtk data file.
void CloseVTKFile()
Close the vtk file.
char * TensorsName
int IsFileStructuredGrid()
Definition: vtkDataReader.h:81
int GetNumberOfNormalsInFile()
int ReadTCoordsData(vtkDataSetAttributes *a, int num)
int NumberOfNormalsInFile
char ** ScalarsNameInFile
vtkFieldData * ReadFieldData(FieldType fieldType=FIELD_DATA)
int TensorsNameAllocSize
int ReadGlobalIds(vtkDataSetAttributes *a, int num)
char * FieldDataName
int NumberOfScalarsInFile
int ReadLine(char result[256])
Internal function to read in a line up to 256 characters.
int ReadLutData(vtkDataSetAttributes *a)
size_t Peek(char *str, size_t n)
Read n character from the stream into str, then reset the stream position.
char ** FieldDataNameInFile
int Read(unsigned int *)
int VectorsNameAllocSize
int OpenVTKFile()
Open a vtk data file.
istream * IS
int IsFileValid(const char *dstype)
Is the file a valid vtk file of the passed dataset type ? The dataset type is passed as a lower case ...
char * ScalarsName
int NumberOfFieldDataInFile
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int IsFileStructuredPoints()
Definition: vtkDataReader.h:77
int ReadCellData(vtkDataSet *ds, int numCells)
Read the cell data of a vtk data file.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int GetNumberOfTCoordsInFile()
const char * GetVectorsNameInFile(int i)
int GetNumberOfFieldDataInFile()
int Read(unsigned char *)
const char * GetTensorsNameInFile(int i)
char ** VectorsNameInFile
void SetInputString(const vtkStdString &input)
char ** TCoordsNameInFile
int ReadVertexData(vtkGraph *g, int numVertices)
Read the vertex data of a vtk data file.
int IsFilePolyData()
Definition: vtkDataReader.h:79
int NumberOfTCoordsInFile
int GetNumberOfScalarsInFile()
How many attributes of various types are in this file? This requires reading the file,...
int Read(long long *result)
int FieldDataNameAllocSize
int ReadPoints(vtkPointSet *ps, int numPts)
Read point coordinates.
int IsFileUnstructuredGrid()
Definition: vtkDataReader.h:83
vtkCharArray * InputArray
represent and manipulate attribute data in a dataset
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
represent and manipulate fields of data
Definition: vtkFieldData.h:57
Base class for graph data types.
Definition: vtkGraph.h:288
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
abstract class for specifying dataset behavior
Definition: vtkPointSet.h:43
a dataset that is topologically regular with variable spacing in the three coordinate directions
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:69
record modification and/or execution time
Definition: vtkTimeStamp.h:36
@ info
Definition: vtkX3D.h:376
@ name
Definition: vtkX3D.h:219
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
#define IS