/usr/include/vtk-7.1/vtkDataReader.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkDataReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkDataReader
* @brief helper superclass for objects that read vtk data files
*
* vtkDataReader is a helper superclass that reads the vtk data file header,
* dataset type, and attribute data (point and cell attributes such as
* scalars, vectors, normals, etc.) from a vtk data file. See text for
* the format of the various vtk file types.
*
* @sa
* vtkPolyDataReader vtkStructuredPointsReader vtkStructuredGridReader
* vtkUnstructuredGridReader vtkRectilinearGridReader
*/
#ifndef vtkDataReader_h
#define vtkDataReader_h
#include "vtkIOLegacyModule.h" // For export macro
#include "vtkAlgorithm.h"
#include "vtkStdString.h" // For API using strings
#define VTK_ASCII 1
#define VTK_BINARY 2
class vtkAbstractArray;
class vtkCharArray;
class vtkDataSet;
class vtkDataSetAttributes;
class vtkFieldData;
class vtkGraph;
class vtkPointSet;
class vtkRectilinearGrid;
class vtkTable;
class VTKIOLEGACY_EXPORT vtkDataReader : public vtkAlgorithm
{
public:
enum FieldType
{
POINT_DATA,
CELL_DATA,
FIELD_DATA
};
static vtkDataReader *New();
vtkTypeMacro(vtkDataReader,vtkAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Specify file name of vtk data file to read.
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
//@{
/**
* Is the file a valid vtk file of the passed dataset type ?
* The dataset type is passed as a lower case string.
*/
int IsFileValid(const char *dstype);
int IsFileStructuredPoints() {
return this->IsFileValid("structured_points");};
int IsFilePolyData() {
return this->IsFileValid("polydata");};
int IsFileStructuredGrid() {
return this->IsFileValid("structured_grid");};
int IsFileUnstructuredGrid() {
return this->IsFileValid("unstructured_grid");};
int IsFileRectilinearGrid() {
return this->IsFileValid("rectilinear_grid");};
//@}
//@{
/**
* Specify the InputString for use when reading from a character array.
* Optionally include the length for binary strings. Note that a copy
* of the string is made and stored. If this causes exceedingly large
* memory consumption, consider using InputArray instead.
*/
void SetInputString(const char *in);
vtkGetStringMacro(InputString);
void SetInputString(const char *in, int len);
vtkGetMacro(InputStringLength, int);
void SetBinaryInputString(const char *, int len);
void SetInputString(const vtkStdString& input)
{ this->SetBinaryInputString(input.c_str(), static_cast<int>(input.length())); }
//@}
//@{
/**
* Specify the vtkCharArray to be used when reading from a string.
* If set, this array has precedence over InputString.
* Use this instead of InputString to avoid the extra memory copy.
* It should be noted that if the underlying char* is owned by the
* user ( vtkCharArray::SetArray(array, 1); ) and is deleted before
* the reader, bad things will happen during a pipeline update.
*/
virtual void SetInputArray(vtkCharArray*);
vtkGetObjectMacro(InputArray, vtkCharArray);
//@}
//@{
/**
* Get the header from the vtk data file.
*/
vtkGetStringMacro(Header);
//@}
//@{
/**
* Enable reading from an InputString or InputArray instead of the default,
* a file.
*/
vtkSetMacro(ReadFromInputString,int);
vtkGetMacro(ReadFromInputString,int);
vtkBooleanMacro(ReadFromInputString,int);
//@}
//@{
/**
* Get the type of file (ASCII or BINARY). Returned value only valid
* after file has been read.
*/
vtkGetMacro(FileType,int);
//@}
/**
* How many attributes of various types are in this file? This
* requires reading the file, so the filename must be set prior
* to invoking this operation. (Note: file characteristics are
* cached, so only a single read is necessary to return file
* characteristics.)
*/
int GetNumberOfScalarsInFile()
{this->CharacterizeFile(); return this->NumberOfScalarsInFile;}
int GetNumberOfVectorsInFile()
{this->CharacterizeFile(); return this->NumberOfVectorsInFile;}
int GetNumberOfTensorsInFile()
{this->CharacterizeFile(); return this->NumberOfTensorsInFile;}
int GetNumberOfNormalsInFile()
{this->CharacterizeFile(); return this->NumberOfNormalsInFile;}
int GetNumberOfTCoordsInFile()
{this->CharacterizeFile(); return this->NumberOfTCoordsInFile;}
int GetNumberOfFieldDataInFile()
{this->CharacterizeFile(); return this->NumberOfFieldDataInFile;}
//@{
/**
* What is the name of the ith attribute of a certain type
* in this file? This requires reading the file, so the filename
* must be set prior to invoking this operation.
*/
const char *GetScalarsNameInFile(int i);
const char *GetVectorsNameInFile(int i);
const char *GetTensorsNameInFile(int i);
const char *GetNormalsNameInFile(int i);
const char *GetTCoordsNameInFile(int i);
const char *GetFieldDataNameInFile(int i);
//@}
//@{
/**
* Set the name of the scalar data to extract. If not specified, first
* scalar data encountered is extracted.
*/
vtkSetStringMacro(ScalarsName);
vtkGetStringMacro(ScalarsName);
//@}
//@{
/**
* Set the name of the vector data to extract. If not specified, first
* vector data encountered is extracted.
*/
vtkSetStringMacro(VectorsName);
vtkGetStringMacro(VectorsName);
//@}
//@{
/**
* Set the name of the tensor data to extract. If not specified, first
* tensor data encountered is extracted.
*/
vtkSetStringMacro(TensorsName);
vtkGetStringMacro(TensorsName);
//@}
//@{
/**
* Set the name of the normal data to extract. If not specified, first
* normal data encountered is extracted.
*/
vtkSetStringMacro(NormalsName);
vtkGetStringMacro(NormalsName);
//@}
//@{
/**
* Set the name of the texture coordinate data to extract. If not specified,
* first texture coordinate data encountered is extracted.
*/
vtkSetStringMacro(TCoordsName);
vtkGetStringMacro(TCoordsName);
//@}
//@{
/**
* Set the name of the lookup table data to extract. If not specified, uses
* lookup table named by scalar. Otherwise, this specification supersedes.
*/
vtkSetStringMacro(LookupTableName);
vtkGetStringMacro(LookupTableName);
//@}
//@{
/**
* Set the name of the field data to extract. If not specified, uses
* first field data encountered in file.
*/
vtkSetStringMacro(FieldDataName);
vtkGetStringMacro(FieldDataName);
//@}
//@{
/**
* Enable reading all scalars.
*/
vtkSetMacro(ReadAllScalars,int);
vtkGetMacro(ReadAllScalars,int);
vtkBooleanMacro(ReadAllScalars,int);
//@}
//@{
/**
* Enable reading all vectors.
*/
vtkSetMacro(ReadAllVectors,int);
vtkGetMacro(ReadAllVectors,int);
vtkBooleanMacro(ReadAllVectors,int);
//@}
//@{
/**
* Enable reading all normals.
*/
vtkSetMacro(ReadAllNormals,int);
vtkGetMacro(ReadAllNormals,int);
vtkBooleanMacro(ReadAllNormals,int);
//@}
//@{
/**
* Enable reading all tensors.
*/
vtkSetMacro(ReadAllTensors,int);
vtkGetMacro(ReadAllTensors,int);
vtkBooleanMacro(ReadAllTensors,int);
//@}
//@{
/**
* Enable reading all color scalars.
*/
vtkSetMacro(ReadAllColorScalars,int);
vtkGetMacro(ReadAllColorScalars,int);
vtkBooleanMacro(ReadAllColorScalars,int);
//@}
//@{
/**
* Enable reading all tcoords.
*/
vtkSetMacro(ReadAllTCoords,int);
vtkGetMacro(ReadAllTCoords,int);
vtkBooleanMacro(ReadAllTCoords,int);
//@}
//@{
/**
* Enable reading all fields.
*/
vtkSetMacro(ReadAllFields,int);
vtkGetMacro(ReadAllFields,int);
vtkBooleanMacro(ReadAllFields,int);
//@}
/**
* Open a vtk data file. Returns zero if error.
*/
int OpenVTKFile();
/**
* Read the header of a vtk data file. Returns 0 if error.
*/
int ReadHeader();
/**
* Read the cell data of a vtk data file. The number of cells (from the
* dataset) must match the number of cells defined in cell attributes (unless
* no geometry was defined).
*/
int ReadCellData(vtkDataSet *ds, int numCells);
/**
* Read the point data of a vtk data file. The number of points (from the
* dataset) must match the number of points defined in point attributes
* (unless no geometry was defined).
*/
int ReadPointData(vtkDataSet *ds, int numPts);
/**
* Read point coordinates. Return 0 if error.
*/
int ReadPoints(vtkPointSet *ps, int numPts);
/**
* Read point coordinates. Return 0 if error.
*/
int ReadPoints(vtkGraph *g, int numPts);
/**
* Read the vertex data of a vtk data file. The number of vertices (from the
* graph) must match the number of vertices defined in vertex attributes
* (unless no geometry was defined).
*/
int ReadVertexData(vtkGraph *g, int numVertices);
/**
* Read the edge data of a vtk data file. The number of edges (from the
* graph) must match the number of edges defined in edge attributes
* (unless no geometry was defined).
*/
int ReadEdgeData(vtkGraph *g, int numEdges);
/**
* Read the row data of a vtk data file.
*/
int ReadRowData(vtkTable *t, int numEdges);
/**
* Read a bunch of "cells". Return 0 if error.
*/
int ReadCells(int size, int *data);
/**
* Read a piece of the cells (for streaming compliance)
*/
int ReadCells(int size, int *data, int skip1, int read2, int skip3);
/**
* Read the coordinates for a rectilinear grid. The axes parameter specifies
* which coordinate axes (0,1,2) is being read.
*/
int ReadCoordinates(vtkRectilinearGrid *rg, int axes, int numCoords);
//@{
/**
* Helper functions for reading data.
*/
vtkAbstractArray *ReadArray(const char *dataType, int numTuples, int numComp);
vtkFieldData *ReadFieldData(FieldType fieldType = FIELD_DATA);
//@}
//@{
/**
* Return major and minor version of the file.
* Returns version 3.0 if the version cannot be read from file.
*/
vtkGetMacro(FileMajorVersion, int);
vtkGetMacro(FileMinorVersion, int);
//@}
//@{
/**
* Internal function to read in a value. Returns zero if there was an
* error.
*/
int Read(char *);
int Read(unsigned char *);
int Read(short *);
int Read(unsigned short *);
int Read(int *);
int Read(unsigned int *);
int Read(long *);
int Read(unsigned long *);
int Read(long long *result);
int Read(unsigned long long *result);
int Read(float *);
int Read(double *);
//@}
/**
* Read @a n character from the stream into @a str, then reset the stream
* position. Returns the number of characters actually read.
*/
size_t Peek(char *str, size_t n);
/**
* Close the vtk file.
*/
void CloseVTKFile();
/**
* Internal function to read in a line up to 256 characters.
* Returns zero if there was an error.
*/
int ReadLine(char result[256]);
/**
* Internal function to read in a string up to 256 characters.
* Returns zero if there was an error.
*/
int ReadString(char result[256]);
/**
* Helper method for reading in data.
*/
char *LowerCase(char *str, const size_t len=256);
/**
* Return the istream being used to read in the data.
*/
istream *GetIStream() {return this->IS;};
/**
* Read the meta information from the file. This needs to be public to it
* can be accessed by vtkDataSetReader.
*/
virtual int ReadMetaData(vtkInformation *) { return 1; }
protected:
vtkDataReader();
~vtkDataReader();
char *FileName;
int FileType;
istream *IS;
char *ScalarsName;
char *VectorsName;
char *TensorsName;
char *TCoordsName;
char *NormalsName;
char *LookupTableName;
char *FieldDataName;
char *ScalarLut;
int ReadFromInputString;
char *InputString;
int InputStringLength;
int InputStringPos;
void SetScalarLut(const char* lut);
vtkGetStringMacro(ScalarLut);
char *Header;
int ReadScalarData(vtkDataSetAttributes *a, int num);
int ReadVectorData(vtkDataSetAttributes *a, int num);
int ReadNormalData(vtkDataSetAttributes *a, int num);
int ReadTensorData(vtkDataSetAttributes *a, int num);
int ReadCoScalarData(vtkDataSetAttributes *a, int num);
int ReadLutData(vtkDataSetAttributes *a);
int ReadTCoordsData(vtkDataSetAttributes *a, int num);
int ReadGlobalIds(vtkDataSetAttributes *a, int num);
int ReadPedigreeIds(vtkDataSetAttributes *a, int num);
int ReadEdgeFlags(vtkDataSetAttributes *a, int num);
/**
* Format is detailed \ref IOLegacyInformationFormat "here".
*/
int ReadInformation(vtkInformation *info, int numKeys);
int ReadDataSetData(vtkDataSet *ds);
// This supports getting additional information from vtk files
int NumberOfScalarsInFile;
char **ScalarsNameInFile;
int ScalarsNameAllocSize;
int NumberOfVectorsInFile;
char **VectorsNameInFile;
int VectorsNameAllocSize;
int NumberOfTensorsInFile;
char **TensorsNameInFile;
int TensorsNameAllocSize;
int NumberOfTCoordsInFile;
char **TCoordsNameInFile;
int TCoordsNameAllocSize;
int NumberOfNormalsInFile;
char **NormalsNameInFile;
int NormalsNameAllocSize;
int NumberOfFieldDataInFile;
char **FieldDataNameInFile;
int FieldDataNameAllocSize;
vtkTimeStamp CharacteristicsTime;
int ReadAllScalars;
int ReadAllVectors;
int ReadAllNormals;
int ReadAllTensors;
int ReadAllColorScalars;
int ReadAllTCoords;
int ReadAllFields;
int FileMajorVersion;
int FileMinorVersion;
void InitializeCharacteristics();
int CharacterizeFile(); //read entire file, storing important characteristics
void CheckFor(const char* name, char *line, int &num, char** &array,
int& allocSize);
vtkCharArray* InputArray;
/**
* Decode a string. This method is the inverse of
* vtkWriter::EncodeString. Returns the length of the
* result string.
*/
int DecodeString(char *resname, const char* name);
virtual int ProcessRequest(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *)
{ return 1; }
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
vtkInformationVector *)
{ return 1; }
virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
vtkInformationVector *)
{ return 1; }
private:
vtkDataReader(const vtkDataReader&) VTK_DELETE_FUNCTION;
void operator=(const vtkDataReader&) VTK_DELETE_FUNCTION;
void ConvertGhostLevelsToGhostType(
FieldType fieldType, vtkAbstractArray *data) const;
};
#endif
|