vtkEnSightReader.h 10.2 KB
Newer Older
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkEnSightReader.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
/**
 * @class   vtkEnSightReader
 * @brief   superclass for EnSight file readers
*/
19

20 21
#ifndef vtkEnSightReader_h
#define vtkEnSightReader_h
22

23
#include "vtkIOEnSightModule.h" // For export macro
24
#include "vtkGenericEnSightReader.h"
25

26

27
class vtkDataSet;
28
class vtkDataSetCollection;
29
class vtkEnSightReaderCellIdsType;
30 31
class vtkIdList;
class vtkMultiBlockDataSet;
32

33
class VTKIOENSIGHT_EXPORT vtkEnSightReader : public vtkGenericEnSightReader
34 35
{
public:
36
  vtkTypeMacro(vtkEnSightReader, vtkGenericEnSightReader);
37
  void PrintSelf(ostream& os, vtkIndent indent) override;
38

39 40 41 42 43 44 45 46 47 48
  enum ElementTypesList
  {
    POINT     = 0,
    BAR2      = 1,
    BAR3      = 2,
    NSIDED    = 3,
    TRIA3     = 4,
    TRIA6     = 5,
    QUAD4     = 6,
    QUAD8     = 7,
49 50 51 52 53 54 55 56 57 58
    NFACED    = 8,
    TETRA4    = 9,
    TETRA10   = 10,
    PYRAMID5  = 11,
    PYRAMID13 = 12,
    HEXA8     = 13,
    HEXA20    = 14,
    PENTA6    = 15,
    PENTA15   = 16,
    NUMBER_OF_ELEMENT_TYPES  = 17
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  };

  enum VariableTypesList
  {
    SCALAR_PER_NODE            = 0,
    VECTOR_PER_NODE            = 1,
    TENSOR_SYMM_PER_NODE       = 2,
    SCALAR_PER_ELEMENT         = 3,
    VECTOR_PER_ELEMENT         = 4,
    TENSOR_SYMM_PER_ELEMENT    = 5,
    SCALAR_PER_MEASURED_NODE   = 6,
    VECTOR_PER_MEASURED_NODE   = 7,
    COMPLEX_SCALAR_PER_NODE    = 8,
    COMPLEX_VECTOR_PER_NODE    = 9,
    COMPLEX_SCALAR_PER_ELEMENT = 10,
    COMPLEX_VECTOR_PER_ELEMENT = 11
  };
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
76 77 78 79 80 81 82

  enum SectionTypeList
  {
    COORDINATES = 0,
    BLOCK       = 1,
    ELEMENT     = 2
  };
83

84 85 86 87 88
  //@{
  /**
   * Get the Measured file name. Made public to allow access from
   * apps requiring detailed info about the Data contents
   */
89
  vtkGetStringMacro(MeasuredFileName);
90
  //@}
91

92 93 94 95 96
  //@{
  /**
   * Get the Match file name. Made public to allow access from
   * apps requiring detailed info about the Data contents
   */
97
  vtkGetStringMacro(MatchFileName);
98 99
  //@}

100 101
protected:
  vtkEnSightReader();
102
  ~vtkEnSightReader() override;
103

104
  int RequestInformation(vtkInformation*,
105
                                 vtkInformationVector**,
106
                                 vtkInformationVector*) override;
107
  int RequestData(vtkInformation*,
108
                          vtkInformationVector**,
109
                          vtkInformationVector*) override;
110

111
  void ClearForNewCaseFileName() override;
112

113 114 115 116
  //@{
  /**
   * Set the Measured file name.
   */
117
  vtkSetStringMacro(MeasuredFileName);
118
  //@}
119

120 121 122 123
  //@{
  /**
   * Set the Match file name.
   */
124
  vtkSetStringMacro(MatchFileName);
125
  //@}
126

127 128 129 130
  //@{
  /**
   * Read the case file.  If an error occurred, 0 is returned; otherwise 1.
   */
131
  int ReadCaseFile();
132 133 134 135
  int ReadCaseFileGeometry(char* line);
  int ReadCaseFileVariable(char* line);
  int ReadCaseFileTime(char* line);
  int ReadCaseFileFile(char* line);
136
  //@}
137 138 139

  // set in UpdateInformation to value returned from ReadCaseFile
  int CaseFileRead;
140

141 142 143
  /**
   * Read the geometry file.  If an error occurred, 0 is returned; otherwise 1.
   */
144
  virtual int ReadGeometryFile(const char* fileName, int timeStep,
145
                               vtkMultiBlockDataSet *output) = 0;
146

147 148 149 150
  /**
   * Read the measured geometry file.  If an error occurred, 0 is returned;
   * otherwise 1.
   */
151
  virtual int ReadMeasuredGeometryFile(const char* fileName, int timeStep,
152
                                       vtkMultiBlockDataSet *output) = 0;
153

154 155 156
  /**
   * Read the variable files. If an error occurred, 0 is returned; otherwise 1.
   */
157
  int ReadVariableFiles(vtkMultiBlockDataSet *output);
158

159 160 161 162
  /**
   * Read scalars per node for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
163
  virtual int ReadScalarsPerNode(const char* fileName, const char* description,
164
                                 int timeStep, vtkMultiBlockDataSet *output,
165
                                 int measured = 0, int numberOfComponents = 1,
166
                                 int component = 0) = 0;
167

168 169 170 171
  /**
   * Read vectors per node for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
172
  virtual int ReadVectorsPerNode(const char* fileName, const char* description,
173
                                 int timeStep, vtkMultiBlockDataSet *output,
174
                                 int measured = 0) = 0;
175

176 177 178 179
  /**
   * Read tensors per node for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
180
  virtual int ReadTensorsPerNode(const char* fileName, const char* description,
181
                                 int timeStep, vtkMultiBlockDataSet *output) = 0;
182

183 184 185 186
  /**
   * Read scalars per element for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
187
  virtual int ReadScalarsPerElement(const char* fileName, const char* description,
188
                                    int timeStep, vtkMultiBlockDataSet *output,
189
                                    int numberOfComponents = 1,
190
                                    int component = 0) = 0;
191

192 193 194 195
  /**
   * Read vectors per element for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
196
  virtual int ReadVectorsPerElement(const char* fileName, const char* description,
197
                                    int timeStep, vtkMultiBlockDataSet *output) = 0;
198

199 200 201 202
  /**
   * Read tensors per element for this dataset.  If an error occurred, 0 is
   * returned; otherwise 1.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
203
  virtual int ReadTensorsPerElement(const char* fileName, const char* description,
204
                                    int timeStep, vtkMultiBlockDataSet *output) = 0;
205

206 207 208 209
  /**
   * Read an unstructured part (partId) from the geometry file and create a
   * vtkUnstructuredGrid output.  Return 0 if EOF reached.
   */
210
  virtual int CreateUnstructuredGridOutput(int partId,
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
211
                                           char line[80],
212
                                           const char* name,
213
                                           vtkMultiBlockDataSet *output) = 0;
214

215 216 217 218
  /**
   * Read a structured part from the geometry file and create a
   * vtkStructuredGridOutput.  Return 0 if EOF reached.
   */
219
  virtual int CreateStructuredGridOutput(int partId,
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
220
                                         char line[80],
221
                                         const char* name,
222
                                         vtkMultiBlockDataSet *output) = 0;
223

224 225 226
  /**
   * Add another file name to the list for a particular variable type.
   */
227
  void AddVariableFileName(const char* fileName1, const char* fileName2 = nullptr);
228

229 230 231
  /**
   * Add another description to the list for a particular variable type.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
232
  void AddVariableDescription(const char* description);
233

234 235 236
  /**
   * Record the variable type for the variable line just read.
   */
237 238
  void AddVariableType();

239 240 241 242
  /**
   * Determine the element type from a line read a file.  Return -1 for
   * invalid element type.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
243 244
  int GetElementType(const char* line);

245 246 247 248
  /**
   * Determine the section type from a line read a file.  Return -1 for
   * invalid section type.
   */
Mathieu Malaterre's avatar
ENH:  
Mathieu Malaterre committed
249
 int GetSectionType(const char *line);
250

251 252 253
  /**
   * Replace the *'s in the filename with the given filename number.
   */
254
  void ReplaceWildcards(char* filename, int num);
255

256 257 258
  /**
   * Remove leading blank spaces from a string.
   */
259 260
  void RemoveLeadingBlanks(char *line);

261 262
  // Get the vtkIdList for the given output index and cell type.
  vtkIdList* GetCellIds(int index, int cellType);
263

264 265 266 267
  /**
   * Convenience method use to convert the readers from VTK 5 multiblock API
   * to the current composite data infrastructure.
   */
268 269
  void AddToBlock(vtkMultiBlockDataSet* output,
                  unsigned int blockNo,
270
                  vtkDataSet* dataset);
271

272 273 274 275
  /**
   * Convenience method use to convert the readers from VTK 5 multiblock API
   * to the current composite data infrastructure.
   */
276
  vtkDataSet* GetDataSetFromBlock(vtkMultiBlockDataSet* output,
277
                                  unsigned int blockNo);
278

279 280 281
  /**
   * Set the name of a block.
   */
282
  void SetBlockName(vtkMultiBlockDataSet* output, unsigned int blockNo,
283
    const char* name);
284

285 286 287 288
  char* MeasuredFileName;
  char* MatchFileName; // may not actually be necessary to read this file

  // pointer to lists of vtkIdLists (cell ids per element type per part)
289
  vtkEnSightReaderCellIdsType* CellIds;
290

291 292
  // part ids of unstructured outputs
  vtkIdList* UnstructuredPartIds;
293

294
  int VariableMode;
295

296 297 298
  // pointers to lists of filenames
  char** VariableFileNames; // non-complex
  char** ComplexVariableFileNames;
299

300
  // array of time sets
301 302
  vtkIdList *VariableTimeSetIds;
  vtkIdList *ComplexVariableTimeSetIds;
303

304
  // array of file sets
305 306
  vtkIdList *VariableFileSetIds;
  vtkIdList *ComplexVariableFileSetIds;
307

308
  // collection of filename numbers per time set
309
  vtkIdListCollection *TimeSetFileNameNumbers;
310
  vtkIdList *TimeSetsWithFilenameNumbers;
311

312
  // collection of filename numbers per file set
313
  vtkIdListCollection *FileSetFileNameNumbers;
314
  vtkIdList *FileSetsWithFilenameNumbers;
315

316
  // collection of number of steps per file per file set
317
  vtkIdListCollection *FileSetNumberOfSteps;
318

319
  // ids of the time and file sets
320
  vtkIdList *TimeSetIds;
321
  vtkIdList *FileSets;
322

323 324 325 326
  int GeometryTimeSet;
  int GeometryFileSet;
  int MeasuredTimeSet;
  int MeasuredFileSet;
327

328 329
  float GeometryTimeValue;
  float MeasuredTimeValue;
330

331 332 333 334 335 336 337 338 339
  vtkTypeBool UseTimeSets;
  vtkSetMacro(UseTimeSets, vtkTypeBool);
  vtkGetMacro(UseTimeSets, vtkTypeBool);
  vtkBooleanMacro(UseTimeSets, vtkTypeBool);

  vtkTypeBool UseFileSets;
  vtkSetMacro(UseFileSets, vtkTypeBool);
  vtkGetMacro(UseFileSets, vtkTypeBool);
  vtkBooleanMacro(UseFileSets, vtkTypeBool);
340

341
  int NumberOfGeometryParts;
342

343 344
  // global list of points for measured geometry
  int NumberOfMeasuredPoints;
345

346 347
  int NumberOfNewOutputs;
  int InitialRead;
348

349
  int CheckOutputConsistency();
350

351 352
  double ActualTimeValue;

353
private:
354 355
  vtkEnSightReader(const vtkEnSightReader&) = delete;
  void operator=(const vtkEnSightReader&) = delete;
356 357 358
};

#endif