1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkEnSightGoldReader.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 =========================================================================*/ 15 /** 16 * @class vtkEnSightGoldReader 17 * @brief class to read EnSight Gold files 18 * 19 * vtkEnSightGoldReader is a class to read EnSight Gold files into vtk. 20 * Because the different parts of the EnSight data can be of various data 21 * types, this reader produces multiple outputs, one per part in the input 22 * file. 23 * All variable information is being stored in field data. The descriptions 24 * listed in the case file are used as the array names in the field data. 25 * For complex vector variables, the description is appended with _r (for the 26 * array of real values) and _i (for the array if imaginary values). Complex 27 * scalar variables are stored as a single array with 2 components, real and 28 * imaginary, listed in that order. 29 * @warning 30 * You must manually call Update on this reader and then connect the rest 31 * of the pipeline because (due to the nature of the file format) it is 32 * not possible to know ahead of time how many outputs you will have or 33 * what types they will be. 34 * This reader can only handle static EnSight datasets (both static geometry 35 * and variables). 36 * @par Thanks: 37 * Thanks to Yvan Fournier for providing the code to support nfaced elements. 38 */ 39 40 #ifndef vtkEnSightGoldReader_h 41 #define vtkEnSightGoldReader_h 42 43 #include "vtkEnSightReader.h" 44 #include "vtkIOEnSightModule.h" // For export macro 45 46 class vtkMultiBlockDataSet; 47 48 class VTKIOENSIGHT_EXPORT vtkEnSightGoldReader : public vtkEnSightReader 49 { 50 public: 51 static vtkEnSightGoldReader* New(); 52 vtkTypeMacro(vtkEnSightGoldReader, vtkEnSightReader); 53 void PrintSelf(ostream& os, vtkIndent indent) override; 54 55 protected: 56 vtkEnSightGoldReader(); 57 ~vtkEnSightGoldReader() override; 58 59 /** 60 * Read the geometry file. If an error occurred, 0 is returned; otherwise 1. 61 */ 62 int ReadGeometryFile(const char* fileName, int timeStep, vtkMultiBlockDataSet* output) override; 63 64 /** 65 * Read the measured geometry file. If an error occurred, 0 is returned; 66 * otherwise 1. 67 */ 68 int ReadMeasuredGeometryFile( 69 const char* fileName, int timeStep, vtkMultiBlockDataSet* output) override; 70 71 /** 72 * Read scalars per node for this dataset. If an error occurred, 0 is 73 * returned; otherwise 1. If there will be more than one component in 74 * the data array, it is assumed that 0 is the first component added. 75 */ 76 int ReadScalarsPerNode(const char* fileName, const char* description, int timeStep, 77 vtkMultiBlockDataSet* output, int measured = 0, int numberOfComponents = 1, 78 int component = 0) override; 79 80 /** 81 * Read vectors per node for this dataset. If an error occurred, 0 is 82 * returned; otherwise 1. 83 */ 84 int ReadVectorsPerNode(const char* fileName, const char* description, int timeStep, 85 vtkMultiBlockDataSet* output, int measured = 0) override; 86 87 /** 88 * Read asimmetric tensors per node for this dataset. If an error occurred, 0 is 89 * returned; otherwise 1. 90 */ 91 int ReadAsymmetricTensorsPerNode(const char* fileName, const char* description, int timeStep, 92 vtkMultiBlockDataSet* output) override; 93 94 /** 95 * Read tensors per node for this dataset. If an error occurred, 0 is 96 * returned; otherwise 1. 97 */ 98 int ReadTensorsPerNode(const char* fileName, const char* description, int timeStep, 99 vtkMultiBlockDataSet* output) override; 100 101 /** 102 * Read scalars per element for this dataset. If an error occurred, 0 is 103 * returned; otherwise 1. If there will be more than one componenet in the 104 * data array, it is assumed that 0 is the first component added. 105 */ 106 int ReadScalarsPerElement(const char* fileName, const char* description, int timeStep, 107 vtkMultiBlockDataSet* output, int numberOfComponents = 1, int component = 0) override; 108 109 /** 110 * Read vectors per element for this dataset. If an error occurred, 0 is 111 * returned; otherwise 1. 112 */ 113 int ReadVectorsPerElement(const char* fileName, const char* description, int timeStep, 114 vtkMultiBlockDataSet* output) override; 115 116 /** 117 * Read asymmetric tensors per element for this dataset. If an error occurred, 0 is 118 * returned; otherwise 1. 119 */ 120 int ReadAsymmetricTensorsPerElement(const char* fileName, const char* description, int timeStep, 121 vtkMultiBlockDataSet* output) override; 122 123 /** 124 * Read tensors per element for this dataset. If an error occurred, 0 is 125 * returned; otherwise 1. 126 */ 127 int ReadTensorsPerElement(const char* fileName, const char* description, int timeStep, 128 vtkMultiBlockDataSet* output) override; 129 130 /** 131 * Read an unstructured part (partId) from the geometry file and create a 132 * vtkUnstructuredGrid output. Return 0 if EOF reached. Return -1 if 133 * an error occurred. 134 */ 135 int CreateUnstructuredGridOutput( 136 int partId, char line[256], const char* name, vtkMultiBlockDataSet* output) override; 137 138 /** 139 * Read a structured part from the geometry file and create a 140 * vtkStructuredGrid output. Return 0 if EOF reached. 141 */ 142 int CreateStructuredGridOutput( 143 int partId, char line[256], const char* name, vtkMultiBlockDataSet* output) override; 144 145 /** 146 * Read a structured part from the geometry file and create a 147 * vtkRectilinearGrid output. Return 0 if EOF reached. 148 */ 149 int CreateRectilinearGridOutput( 150 int partId, char line[256], const char* name, vtkMultiBlockDataSet* output); 151 152 /** 153 * Read a structured part from the geometry file and create a 154 * vtkImageData output. Return 0 if EOF reached. 155 */ 156 int CreateImageDataOutput( 157 int partId, char line[256], const char* name, vtkMultiBlockDataSet* output); 158 159 int NodeIdsListed; 160 int ElementIdsListed; 161 162 class FileOffsetMapInternal; 163 FileOffsetMapInternal* FileOffsets; 164 165 private: 166 vtkEnSightGoldReader(const vtkEnSightGoldReader&) = delete; 167 void operator=(const vtkEnSightGoldReader&) = delete; 168 169 /** 170 * Opens a variable file name. This will compute the full path and then open 171 * it. `variableType` is simply used to report helpful error messages. 172 */ 173 bool OpenVariableFile(const char* fname, const char* variableType); 174 175 /** 176 * Jump forward to a particular timestep in the variable file, if 177 * applicable. 178 */ 179 bool SkipToTimeStep(const char* fileName, int timeStep); 180 181 class UndefPartialHelper; 182 friend class UndefPartialHelper; 183 }; 184 185 #endif 186