vtkEnSight6BinaryReader.h 7.09 KB
Newer Older
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkEnSight6BinaryReader.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

=========================================================================*/
// .NAME vtkEnSight6BinaryReader - class to read binary EnSight6 files
// .SECTION Description
// vtkEnSight6BinaryReader is a class to read binary EnSight6 files into vtk.
// Because the different parts of the EnSight data can be of various data
// types, this reader produces multiple outputs, one per part in the input
// file.
// All variable information is being stored in field data.  The descriptions
// listed in the case file are used as the array names in the field data.
// For complex vector variables, the description is appended with _r (for the
// array of real values) and _i (for the array if imaginary values).  Complex
// scalar variables are stored as a single array with 2 components, real and
// imaginary, listed in that order.
// .SECTION Caveats
// You must manually call Update on this reader and then connect the rest
// of the pipeline because (due to the nature of the file format) it is
// not possible to know ahead of time how many outputs you will have or
// what types they will be.
// This reader can only handle static EnSight datasets (both static geometry
// and variables).

35 36
#ifndef vtkEnSight6BinaryReader_h
#define vtkEnSight6BinaryReader_h
37

38
#include "vtkIOEnSightModule.h" // For export macro
39 40
#include "vtkEnSightReader.h"

41
class vtkMultiBlockDataSet;
42
class vtkIdTypeArray;
Andy Cedilnik's avatar
Andy Cedilnik committed
43
class vtkPoints;
44

45
class VTKIOENSIGHT_EXPORT vtkEnSight6BinaryReader : public vtkEnSightReader
46 47 48
{
public:
  static vtkEnSight6BinaryReader *New();
49
  vtkTypeMacro(vtkEnSight6BinaryReader, vtkEnSightReader);
50
  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
51

52 53 54
protected:
  vtkEnSight6BinaryReader();
  ~vtkEnSight6BinaryReader();
55 56 57

  // Returns 1 if successful.  Sets file size as a side action.
  int OpenFile(const char* filename);
58

59 60
  // Description:
  // Read the geometry file.  If an error occurred, 0 is returned; otherwise 1.
61
  virtual int ReadGeometryFile(const char* fileName, int timeStep,
62
                               vtkMultiBlockDataSet *output);
63

64 65 66
  // Description:
  // Read the measured geometry file.  If an error occurred, 0 is returned;
  // otherwise 1.
67
  virtual int ReadMeasuredGeometryFile(const char* fileName, int timeStep,
68
                                       vtkMultiBlockDataSet *output);
69

70 71 72 73
  // Description:
  // Read scalars per node for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.  If there will be more than one component in
  // the scalars array, we assume that 0 is the first component added to the array.
Mathieu Malaterre's avatar
Mathieu Malaterre committed
74
  virtual int ReadScalarsPerNode(const char* fileName, const char* description,
75
                                 int timeStep, vtkMultiBlockDataSet *output,
76
                                 int measured = 0, int numberOfComponents = 1,
77
                                 int component = 0);
78

79 80 81
  // Description:
  // Read vectors per node for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.
Mathieu Malaterre's avatar
Mathieu Malaterre committed
82
  virtual int ReadVectorsPerNode(const char* fileName, const char* description,
83
                                 int timeStep, vtkMultiBlockDataSet *output,
84
                                 int measured = 0);
85 86 87 88

  // Description:
  // Read tensors per node for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.
Mathieu Malaterre's avatar
Mathieu Malaterre committed
89
  virtual int ReadTensorsPerNode(const char* fileName, const char* description,
90
                                 int timeStep, vtkMultiBlockDataSet *output);
91 92 93 94 95

  // Description:
  // Read scalars per element for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.  If there will be more than one component in the
  // scalars array, we assume that 0 is the first component added to the array.
96 97
  virtual int ReadScalarsPerElement(const char* fileName,
                                    const char* description, int timeStep,
98
                                    vtkMultiBlockDataSet *output,
99
                                    int numberOfComponents = 1,
100
                                    int component = 0);
101 102 103 104

  // Description:
  // Read vectors per element for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.
Mathieu Malaterre's avatar
Mathieu Malaterre committed
105
  virtual int ReadVectorsPerElement(const char* fileName, const char* description,
106
                                    int timeStep, vtkMultiBlockDataSet *output);
107 108 109 110

  // Description:
  // Read tensors per element for this dataset.  If an error occurred, 0 is
  // returned; otherwise 1.
Mathieu Malaterre's avatar
Mathieu Malaterre committed
111
  virtual int ReadTensorsPerElement(const char* fileName, const char* description,
112
                                    int timeStep, vtkMultiBlockDataSet *output);
113 114 115 116

  // Description:
  // Read an unstructured part (partId) from the geometry file and create a
  // vtkUnstructuredGrid output.  Return 0 if EOF reached.
117
  virtual int CreateUnstructuredGridOutput(int partId,
118
                                           char line[256],
119
                                           const char* name,
120
                                           vtkMultiBlockDataSet *output);
121

122 123 124
  // Description:
  // Read a structured part from the geometry file and create a
  // vtkStructuredGridOutput.  Return 0 if EOF reached.
125
  virtual int CreateStructuredGridOutput(int partId,
126
                                         char line[256],
127
                                         const char* name,
128
                                         vtkMultiBlockDataSet *output);
129

130 131 132 133 134 135 136
  // Description:
  // Internal function to read in a line up to 80 characters.
  // Returns zero if there was an error.
  int ReadLine(char result[80]);

  // Description:
  // Internal function to read in a single integer.
137
  // Tries to determine the byte order of this file.
138
  // Returns zero if there was an error.
139
  int ReadIntNumber(int *result);
140 141 142 143 144 145 146 147 148 149 150

  // Description:
  // Internal function to read in an integer array.
  // Returns zero if there was an error.
  int ReadIntArray(int *result, int numInts);

  // Description:
  // Internal function to read in a float array.
  // Returns zero if there was an error.
  int ReadFloatArray(float *result, int numFloats);

151 152
  // Description:
  // Read to the next time step in the geometry file.
153
  int SkipTimeStep();
154 155
  int SkipStructuredGrid(char line[256]);
  int SkipUnstructuredGrid(char line[256]);
156

157 158 159
  // global list of points for the unstructured parts of the model
  int NumberOfUnstructuredPoints;
  vtkPoints* UnstructuredPoints;
160
  vtkIdTypeArray* UnstructuredNodeIds; // matching of node ids to point ids
161

162
  int ElementIdsListed;
163 164 165

  // The size of the file is used to choose byte order.
  int FileSize;
166

167
  ifstream *IFile;
168
private:
169
  vtkEnSight6BinaryReader(const vtkEnSight6BinaryReader&) VTK_DELETE_FUNCTION;
170
  void operator=(const vtkEnSight6BinaryReader&) VTK_DELETE_FUNCTION;
171 172 173
};

#endif
174