Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

IO/vtkGenericEnSightReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGenericEnSightReader.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00029 #ifndef __vtkGenericEnSightReader_h
00030 #define __vtkGenericEnSightReader_h
00031 
00032 #include "vtkDataSetSource.h"
00033 
00034 class vtkDataArrayCollection;
00035 class vtkIdListCollection;
00036 
00037 
00038 class VTK_IO_EXPORT vtkGenericEnSightReader : public vtkDataSetSource
00039 {
00040 public:
00041   static vtkGenericEnSightReader *New();
00042   vtkTypeRevisionMacro(vtkGenericEnSightReader, vtkDataSetSource);
00043   void PrintSelf(ostream& os, vtkIndent indent);
00044 
00046 
00047   void SetCaseFileName(const char* fileName);
00048   vtkGetStringMacro(CaseFileName);
00050 
00052 
00053   vtkSetStringMacro(FilePath);
00054   vtkGetStringMacro(FilePath);
00056   
00057   virtual void Update();
00058   virtual void ExecuteInformation();
00059   
00061 
00062   int GetNumberOfVariables() { return this->NumberOfVariables; }
00063   int GetNumberOfComplexVariables() { return this->NumberOfComplexVariables; }
00065 
00067 
00068   int GetNumberOfVariables(int type); // returns -1 if unknown type specified
00069   vtkGetMacro(NumberOfScalarsPerNode, int);
00070   vtkGetMacro(NumberOfVectorsPerNode, int);
00071   vtkGetMacro(NumberOfTensorsSymmPerNode, int);
00072   vtkGetMacro(NumberOfScalarsPerElement, int);
00073   vtkGetMacro(NumberOfVectorsPerElement, int);
00074   vtkGetMacro(NumberOfTensorsSymmPerElement, int);
00075   vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
00076   vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
00077   vtkGetMacro(NumberOfComplexScalarsPerNode, int);
00078   vtkGetMacro(NumberOfComplexVectorsPerNode, int);
00079   vtkGetMacro(NumberOfComplexScalarsPerElement, int);
00080   vtkGetMacro(NumberOfComplexVectorsPerElement, int);
00082 
00084   char* GetDescription(int n);
00085   
00087   char* GetComplexDescription(int n);
00088   
00097   char* GetDescription(int n, int type);
00098   
00100 
00101   int GetVariableType(int n);
00102   int GetComplexVariableType(int n);
00104   
00106 
00107   vtkSetMacro(TimeValue, float);
00108   vtkGetMacro(TimeValue, float);
00110 
00112 
00113   vtkGetMacro(MinimumTimeValue, float);
00114   vtkGetMacro(MaximumTimeValue, float);
00116   
00118 
00119   vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
00121 
00126   int DetermineEnSightVersion();
00127 
00129 
00130   vtkBooleanMacro(ReadAllVariables, int);
00131   vtkSetMacro(ReadAllVariables, int);
00132   vtkGetMacro(ReadAllVariables, int);
00134   
00136 
00138   void AddVariableName(char* variableName, int attributeType);
00139   void AddPointVariableName(char* variableName);
00140   void AddCellVariableName(char* variableName);
00142   
00144   void RemoveAllVariableNames();
00145   
00147 
00148   void RemoveAllPointVariableNames();
00149   void RemoveAllCellVariableNames();
00151 
00154   int IsRequestedVariable(char *variableName, int attributeType);
00155   
00157 
00158   int GetNumberOfPointArrays();
00159   int GetNumberOfCellArrays();
00161   
00162   //BTX
00163   enum FileTypes
00164   {
00165     ENSIGHT_6             = 0,
00166     ENSIGHT_6_BINARY      = 1,
00167     ENSIGHT_GOLD          = 2,
00168     ENSIGHT_GOLD_BINARY   = 3,
00169     ENSIGHT_MASTER_SERVER = 4
00170   };
00171   //ETX
00172 
00174 
00177   void SetByteOrderToBigEndian();
00178   void SetByteOrderToLittleEndian();
00179   vtkSetMacro(ByteOrder, int);
00180   vtkGetMacro(ByteOrder, int);
00181   const char *GetByteOrderAsString();
00183 
00184 //BTX
00185   enum 
00186   {
00187     FILE_BIG_ENDIAN=0,
00188     FILE_LITTLE_ENDIAN=1
00189   };
00190 //ETX
00191 
00192 protected:
00193   vtkGenericEnSightReader();
00194   ~vtkGenericEnSightReader();
00195 
00196   void Execute();
00197   
00200   int ReadLine(char result[256]);
00201 
00204   int ReadBinaryLine(char result[80]);
00205   
00206   // Internal function that skips blank lines and reads the 1st
00207   // non-blank line it finds (up to 256 characters).
00208   // Returns 0 is there was an error.
00209   int ReadNextDataLine(char result[256]);
00210 
00212 
00213   vtkSetStringMacro(GeometryFileName);
00214   vtkGetStringMacro(GeometryFileName);
00216   
00218 
00219   void AddVariableDescription(char* description);
00220   void AddComplexVariableDescription(char* description);
00222 
00224 
00225   void AddVariableType(int variableType);
00226   void AddComplexVariableType(int variableType);
00228 
00230 
00232   void ReplaceWildcards(char* fileName, int timeSet, int fileSet);
00233   void ReplaceWildcardsHelper(char* fileName, int num);
00235   
00236   istream* IS;
00237   FILE *IFile;
00238   vtkGenericEnSightReader *Reader;
00239   
00240   char* CaseFileName;
00241   char* GeometryFileName;
00242   char* FilePath;
00243 
00244   // array of types (one entry per instance of variable type in case file)
00245   int* VariableTypes;
00246   int* ComplexVariableTypes;
00247   
00248   // pointers to lists of descriptions
00249   char** VariableDescriptions;
00250   char** ComplexVariableDescriptions;
00251   
00252   int NumberOfVariables;
00253   int NumberOfComplexVariables;
00254   
00255   // number of file names / descriptions per type
00256   int NumberOfScalarsPerNode;
00257   int NumberOfVectorsPerNode;
00258   int NumberOfTensorsSymmPerNode;
00259   int NumberOfScalarsPerElement;
00260   int NumberOfVectorsPerElement;
00261   int NumberOfTensorsSymmPerElement;
00262   int NumberOfScalarsPerMeasuredNode;
00263   int NumberOfVectorsPerMeasuredNode;
00264   int NumberOfComplexScalarsPerNode;
00265   int NumberOfComplexVectorsPerNode;  
00266   int NumberOfComplexScalarsPerElement;
00267   int NumberOfComplexVectorsPerElement;
00268   
00269   float TimeValue;
00270   float MinimumTimeValue;
00271   float MaximumTimeValue;
00272   
00273   vtkDataArrayCollection *TimeSets;
00274   virtual void SetTimeSets(vtkDataArrayCollection*);
00275 
00276   int ReadAllVariables;
00277   int NumberOfRequestedPointVariables;
00278   int NumberOfRequestedCellVariables;
00279   char** RequestedPointVariables;
00280   char** RequestedCellVariables;
00281 
00282   int ByteOrder;
00283   
00284 private:
00285   vtkGenericEnSightReader(const vtkGenericEnSightReader&);  // Not implemented.
00286   void operator=(const vtkGenericEnSightReader&);  // Not implemented.
00287 };
00288 
00289 #endif