VTK
dox/IO/EnSight/vtkEnSightReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkEnSightReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00019 #ifndef __vtkEnSightReader_h
00020 #define __vtkEnSightReader_h
00021 
00022 #include "vtkIOEnSightModule.h" // For export macro
00023 #include "vtkGenericEnSightReader.h"
00024 
00025 
00026 class vtkDataSet;
00027 class vtkDataSetCollection;
00028 class vtkEnSightReaderCellIdsType;
00029 class vtkIdList;
00030 class vtkMultiBlockDataSet;
00031 
00032 class VTKIOENSIGHT_EXPORT vtkEnSightReader : public vtkGenericEnSightReader
00033 {
00034 public:
00035   vtkTypeMacro(vtkEnSightReader, vtkGenericEnSightReader);
00036   void PrintSelf(ostream& os, vtkIndent indent);
00037 
00038   //BTX
00039   enum ElementTypesList
00040   {
00041     POINT     = 0,
00042     BAR2      = 1,
00043     BAR3      = 2,
00044     NSIDED    = 3,
00045     TRIA3     = 4,
00046     TRIA6     = 5,
00047     QUAD4     = 6,
00048     QUAD8     = 7,
00049     NFACED    = 8,
00050     TETRA4    = 9,
00051     TETRA10   = 10,
00052     PYRAMID5  = 11,
00053     PYRAMID13 = 12,
00054     HEXA8     = 13,
00055     HEXA20    = 14,
00056     PENTA6    = 15,
00057     PENTA15   = 16,
00058     NUMBER_OF_ELEMENT_TYPES  = 17
00059   };
00060 
00061   enum VariableTypesList
00062   {
00063     SCALAR_PER_NODE            = 0,
00064     VECTOR_PER_NODE            = 1,
00065     TENSOR_SYMM_PER_NODE       = 2,
00066     SCALAR_PER_ELEMENT         = 3,
00067     VECTOR_PER_ELEMENT         = 4,
00068     TENSOR_SYMM_PER_ELEMENT    = 5,
00069     SCALAR_PER_MEASURED_NODE   = 6,
00070     VECTOR_PER_MEASURED_NODE   = 7,
00071     COMPLEX_SCALAR_PER_NODE    = 8,
00072     COMPLEX_VECTOR_PER_NODE    = 9,
00073     COMPLEX_SCALAR_PER_ELEMENT = 10,
00074     COMPLEX_VECTOR_PER_ELEMENT = 11
00075   };
00076 
00077   enum SectionTypeList
00078   {
00079     COORDINATES = 0,
00080     BLOCK       = 1,
00081     ELEMENT     = 2
00082   };
00083   //ETX
00084 
00086 
00088   vtkGetStringMacro(MeasuredFileName);
00090 
00092 
00094   vtkGetStringMacro(MatchFileName);
00096 
00098 
00106   vtkSetMacro(ParticleCoordinatesByIndex, int);
00107   vtkGetMacro(ParticleCoordinatesByIndex, int);
00108   vtkBooleanMacro(ParticleCoordinatesByIndex, int);
00110 
00111 protected:
00112   vtkEnSightReader();
00113   ~vtkEnSightReader();
00114 
00115   virtual int RequestInformation(vtkInformation*,
00116                                  vtkInformationVector**,
00117                                  vtkInformationVector*);
00118   virtual int RequestData(vtkInformation*,
00119                           vtkInformationVector**,
00120                           vtkInformationVector*);
00121 
00123 
00124   vtkSetStringMacro(MeasuredFileName);
00126 
00128 
00129   vtkSetStringMacro(MatchFileName);
00131 
00133 
00135   int ReadCaseFile();
00136   int ReadCaseFileGeometry(char* line);
00137   int ReadCaseFileVariable(char* line);
00138   int ReadCaseFileTime(char* line);
00139   int ReadCaseFileFile(char* line);
00141 
00142   // set in UpdateInformation to value returned from ReadCaseFile
00143   int CaseFileRead;
00144 
00146 
00148   virtual int ReadGeometryFile(const char* fileName, int timeStep,
00149                                vtkMultiBlockDataSet *output) = 0;
00151 
00153 
00155   virtual int ReadMeasuredGeometryFile(const char* fileName, int timeStep,
00156                                        vtkMultiBlockDataSet *output) = 0;
00158 
00161   int ReadVariableFiles(vtkMultiBlockDataSet *output);
00162 
00164 
00166   virtual int ReadScalarsPerNode(const char* fileName, const char* description,
00167                                  int timeStep, vtkMultiBlockDataSet *output,
00168                                  int measured = 0, int numberOfComponents = 1,
00169                                  int component = 0) = 0;
00171 
00173 
00175   virtual int ReadVectorsPerNode(const char* fileName, const char* description,
00176                                  int timeStep, vtkMultiBlockDataSet *output,
00177                                  int measured = 0) = 0;
00179 
00181 
00183   virtual int ReadTensorsPerNode(const char* fileName, const char* description,
00184                                  int timeStep, vtkMultiBlockDataSet *output) = 0;
00186 
00188 
00190   virtual int ReadScalarsPerElement(const char* fileName, const char* description,
00191                                     int timeStep, vtkMultiBlockDataSet *output,
00192                                     int numberOfComponents = 1,
00193                                     int component = 0) = 0;
00195 
00197 
00199   virtual int ReadVectorsPerElement(const char* fileName, const char* description,
00200                                     int timeStep, vtkMultiBlockDataSet *output) = 0;
00202 
00204 
00206   virtual int ReadTensorsPerElement(const char* fileName, const char* description,
00207                                     int timeStep, vtkMultiBlockDataSet *output) = 0;
00209 
00211 
00213   virtual int CreateUnstructuredGridOutput(int partId,
00214                                            char line[80],
00215                                            const char* name,
00216                                            vtkMultiBlockDataSet *output) = 0;
00218 
00220 
00222   virtual int CreateStructuredGridOutput(int partId,
00223                                          char line[80],
00224                                          const char* name,
00225                                          vtkMultiBlockDataSet *output) = 0;
00227 
00229   void AddVariableFileName(const char* fileName1, const char* fileName2 = NULL);
00230 
00232   void AddVariableDescription(const char* description);
00233 
00235   void AddVariableType();
00236 
00239   int GetElementType(const char* line);
00240 
00243  int GetSectionType(const char *line);
00244 
00246   void ReplaceWildcards(char* filename, int num);
00247 
00249   void RemoveLeadingBlanks(char *line);
00250 
00251   // Get the vtkIdList for the given output index and cell type.
00252   vtkIdList* GetCellIds(int index, int cellType);
00253 
00255 
00257   void AddToBlock(vtkMultiBlockDataSet* output,
00258                   unsigned int blockNo,
00259                   vtkDataSet* dataset);
00261 
00263 
00265   vtkDataSet* GetDataSetFromBlock(vtkMultiBlockDataSet* output,
00266                                   unsigned int blockNo);
00268 
00270 
00271   void SetBlockName(vtkMultiBlockDataSet* output, unsigned int blockNo,
00272     const char* name);
00274 
00275   char* MeasuredFileName;
00276   char* MatchFileName; // may not actually be necessary to read this file
00277 
00278   // pointer to lists of vtkIdLists (cell ids per element type per part)
00279   vtkEnSightReaderCellIdsType* CellIds;
00280 
00281   // part ids of unstructured outputs
00282   vtkIdList* UnstructuredPartIds;
00283 
00284   int VariableMode;
00285 
00286   // pointers to lists of filenames
00287   char** VariableFileNames; // non-complex
00288   char** ComplexVariableFileNames;
00289 
00290   // array of time sets
00291   vtkIdList *VariableTimeSetIds;
00292   vtkIdList *ComplexVariableTimeSetIds;
00293 
00294   // array of file sets
00295   vtkIdList *VariableFileSetIds;
00296   vtkIdList *ComplexVariableFileSetIds;
00297 
00298   // collection of filename numbers per time set
00299   vtkIdListCollection *TimeSetFileNameNumbers;
00300   vtkIdList *TimeSetsWithFilenameNumbers;
00301 
00302   // collection of filename numbers per file set
00303   vtkIdListCollection *FileSetFileNameNumbers;
00304   vtkIdList *FileSetsWithFilenameNumbers;
00305 
00306   // collection of number of steps per file per file set
00307   vtkIdListCollection *FileSetNumberOfSteps;
00308 
00309   // ids of the time and file sets
00310   vtkIdList *TimeSetIds;
00311   vtkIdList *FileSets;
00312 
00313   int GeometryTimeSet;
00314   int GeometryFileSet;
00315   int MeasuredTimeSet;
00316   int MeasuredFileSet;
00317 
00318   float GeometryTimeValue;
00319   float MeasuredTimeValue;
00320 
00321   int UseTimeSets;
00322   vtkSetMacro(UseTimeSets, int);
00323   vtkGetMacro(UseTimeSets, int);
00324   vtkBooleanMacro(UseTimeSets, int);
00325 
00326   int UseFileSets;
00327   vtkSetMacro(UseFileSets, int);
00328   vtkGetMacro(UseFileSets, int);
00329   vtkBooleanMacro(UseFileSets, int);
00330 
00331   int NumberOfGeometryParts;
00332 
00333   // global list of points for measured geometry
00334   int NumberOfMeasuredPoints;
00335 
00336   int NumberOfNewOutputs;
00337   int InitialRead;
00338 
00339   int CheckOutputConsistency();
00340 
00341   int ParticleCoordinatesByIndex;
00342 
00343   double ActualTimeValue;
00344 
00345 private:
00346   vtkEnSightReader(const vtkEnSightReader&);  // Not implemented.
00347   void operator=(const vtkEnSightReader&);  // Not implemented.
00348 };
00349 
00350 #endif