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 =========================================================================*/
00042 #ifndef __vtkGenericEnSightReader_h
00043 #define __vtkGenericEnSightReader_h
00044 
00045 #include "vtkDataSetSource.h"
00046 
00047 class vtkDataArrayCollection;
00048 class vtkIdListCollection;
00049 
00050 
00051 class VTK_IO_EXPORT vtkGenericEnSightReader : public vtkDataSetSource
00052 {
00053 public:
00054   static vtkGenericEnSightReader *New();
00055   vtkTypeRevisionMacro(vtkGenericEnSightReader, vtkDataSetSource);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00060   void SetCaseFileName(const char* fileName);
00061   vtkGetStringMacro(CaseFileName);
00063 
00065 
00066   vtkSetStringMacro(FilePath);
00067   vtkGetStringMacro(FilePath);
00069   
00070   virtual void Update();
00071   virtual void ExecuteInformation();
00072   
00074 
00075   int GetNumberOfVariables() { return this->NumberOfVariables; }
00076   int GetNumberOfComplexVariables() { return this->NumberOfComplexVariables; }
00078 
00080 
00081   int GetNumberOfVariables(int type); // returns -1 if unknown type specified
00082   vtkGetMacro(NumberOfScalarsPerNode, int);
00083   vtkGetMacro(NumberOfVectorsPerNode, int);
00084   vtkGetMacro(NumberOfTensorsSymmPerNode, int);
00085   vtkGetMacro(NumberOfScalarsPerElement, int);
00086   vtkGetMacro(NumberOfVectorsPerElement, int);
00087   vtkGetMacro(NumberOfTensorsSymmPerElement, int);
00088   vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
00089   vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
00090   vtkGetMacro(NumberOfComplexScalarsPerNode, int);
00091   vtkGetMacro(NumberOfComplexVectorsPerNode, int);
00092   vtkGetMacro(NumberOfComplexScalarsPerElement, int);
00093   vtkGetMacro(NumberOfComplexVectorsPerElement, int);
00095 
00097   char* GetDescription(int n);
00098   
00100   char* GetComplexDescription(int n);
00101   
00110   char* GetDescription(int n, int type);
00111   
00113 
00114   int GetVariableType(int n);
00115   int GetComplexVariableType(int n);
00117   
00119 
00120   vtkSetMacro(TimeValue, float);
00121   vtkGetMacro(TimeValue, float);
00123 
00125 
00126   vtkGetMacro(MinimumTimeValue, float);
00127   vtkGetMacro(MaximumTimeValue, float);
00129   
00131 
00132   vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
00134 
00139   int DetermineEnSightVersion();
00140 
00142 
00143   vtkBooleanMacro(ReadAllVariables, int);
00144   vtkSetMacro(ReadAllVariables, int);
00145   vtkGetMacro(ReadAllVariables, int);
00147   
00149 
00151   void AddVariableName(char* variableName, int attributeType);
00152   void AddPointVariableName(char* variableName);
00153   void AddCellVariableName(char* variableName);
00155   
00157   void RemoveAllVariableNames();
00158   
00160 
00161   void RemoveAllPointVariableNames();
00162   void RemoveAllCellVariableNames();
00164 
00167   int IsRequestedVariable(char *variableName, int attributeType);
00168   
00170 
00171   int GetNumberOfPointArrays();
00172   int GetNumberOfCellArrays();
00174   
00175   //BTX
00176   enum FileTypes
00177   {
00178     ENSIGHT_6             = 0,
00179     ENSIGHT_6_BINARY      = 1,
00180     ENSIGHT_GOLD          = 2,
00181     ENSIGHT_GOLD_BINARY   = 3,
00182     ENSIGHT_MASTER_SERVER = 4
00183   };
00184   //ETX
00185 
00187 
00190   void SetByteOrderToBigEndian();
00191   void SetByteOrderToLittleEndian();
00192   vtkSetMacro(ByteOrder, int);
00193   vtkGetMacro(ByteOrder, int);
00194   const char *GetByteOrderAsString();
00196 
00197 //BTX
00198   enum 
00199   {
00200     FILE_BIG_ENDIAN=0,
00201     FILE_LITTLE_ENDIAN=1
00202   };
00203 //ETX
00204 
00205 protected:
00206   vtkGenericEnSightReader();
00207   ~vtkGenericEnSightReader();
00208 
00209   void Execute();
00210   
00213   int ReadLine(char result[256]);
00214 
00217   int ReadBinaryLine(char result[80]);
00218   
00219   // Internal function that skips blank lines and reads the 1st
00220   // non-blank line it finds (up to 256 characters).
00221   // Returns 0 is there was an error.
00222   int ReadNextDataLine(char result[256]);
00223 
00225 
00226   vtkSetStringMacro(GeometryFileName);
00227   vtkGetStringMacro(GeometryFileName);
00229   
00231 
00232   void AddVariableDescription(char* description);
00233   void AddComplexVariableDescription(char* description);
00235 
00237 
00238   void AddVariableType(int variableType);
00239   void AddComplexVariableType(int variableType);
00241 
00243 
00245   void ReplaceWildcards(char* fileName, int timeSet, int fileSet);
00246   void ReplaceWildcardsHelper(char* fileName, int num);
00248   
00249   istream* IS;
00250   FILE *IFile;
00251   vtkGenericEnSightReader *Reader;
00252   
00253   char* CaseFileName;
00254   char* GeometryFileName;
00255   char* FilePath;
00256 
00257   // array of types (one entry per instance of variable type in case file)
00258   int* VariableTypes;
00259   int* ComplexVariableTypes;
00260   
00261   // pointers to lists of descriptions
00262   char** VariableDescriptions;
00263   char** ComplexVariableDescriptions;
00264   
00265   int NumberOfVariables;
00266   int NumberOfComplexVariables;
00267   
00268   // number of file names / descriptions per type
00269   int NumberOfScalarsPerNode;
00270   int NumberOfVectorsPerNode;
00271   int NumberOfTensorsSymmPerNode;
00272   int NumberOfScalarsPerElement;
00273   int NumberOfVectorsPerElement;
00274   int NumberOfTensorsSymmPerElement;
00275   int NumberOfScalarsPerMeasuredNode;
00276   int NumberOfVectorsPerMeasuredNode;
00277   int NumberOfComplexScalarsPerNode;
00278   int NumberOfComplexVectorsPerNode;  
00279   int NumberOfComplexScalarsPerElement;
00280   int NumberOfComplexVectorsPerElement;
00281   
00282   float TimeValue;
00283   float MinimumTimeValue;
00284   float MaximumTimeValue;
00285   
00286   vtkDataArrayCollection *TimeSets;
00287   virtual void SetTimeSets(vtkDataArrayCollection*);
00288 
00289   int ReadAllVariables;
00290   int NumberOfRequestedPointVariables;
00291   int NumberOfRequestedCellVariables;
00292   char** RequestedPointVariables;
00293   char** RequestedCellVariables;
00294 
00295   int ByteOrder;
00296   
00297 private:
00298   vtkGenericEnSightReader(const vtkGenericEnSightReader&);  // Not implemented.
00299   void operator=(const vtkGenericEnSightReader&);  // Not implemented.
00300 };
00301 
00302 #endif