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

vtkGenericEnSightReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGenericEnSightReader.h,v $
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 =========================================================================*/
00038 #ifndef __vtkGenericEnSightReader_h
00039 #define __vtkGenericEnSightReader_h
00040 
00041 #include "vtkDataSetSource.h"
00042 
00043 class vtkCallbackCommand;
00044 class vtkDataArrayCollection;
00045 class vtkDataArraySelection;
00046 class vtkIdListCollection;
00047 
00048 class VTK_IO_EXPORT vtkGenericEnSightReader : public vtkDataSetSource
00049 {
00050 public:
00051   static vtkGenericEnSightReader *New();
00052   vtkTypeRevisionMacro(vtkGenericEnSightReader, vtkDataSetSource);
00053   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00056 
00057   void SetCaseFileName(const char* fileName);
00058   vtkGetStringMacro(CaseFileName);
00060 
00062 
00063   vtkSetStringMacro(FilePath);
00064   vtkGetStringMacro(FilePath);
00066   
00067   virtual void Update();
00068   virtual void ExecuteInformation();
00069   
00071 
00072   int GetNumberOfVariables() { return this->NumberOfVariables; }
00073   int GetNumberOfComplexVariables() { return this->NumberOfComplexVariables; }
00075 
00077 
00078   int GetNumberOfVariables(int type); // returns -1 if unknown type specified
00079   vtkGetMacro(NumberOfScalarsPerNode, int);
00080   vtkGetMacro(NumberOfVectorsPerNode, int);
00081   vtkGetMacro(NumberOfTensorsSymmPerNode, int);
00082   vtkGetMacro(NumberOfScalarsPerElement, int);
00083   vtkGetMacro(NumberOfVectorsPerElement, int);
00084   vtkGetMacro(NumberOfTensorsSymmPerElement, int);
00085   vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
00086   vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
00087   vtkGetMacro(NumberOfComplexScalarsPerNode, int);
00088   vtkGetMacro(NumberOfComplexVectorsPerNode, int);
00089   vtkGetMacro(NumberOfComplexScalarsPerElement, int);
00090   vtkGetMacro(NumberOfComplexVectorsPerElement, int);
00092 
00094   char* GetDescription(int n);
00095   
00097   char* GetComplexDescription(int n);
00098   
00107   char* GetDescription(int n, int type);
00108   
00110 
00111   int GetVariableType(int n);
00112   int GetComplexVariableType(int n);
00114   
00116 
00117   virtual void SetTimeValue(float value);
00118   vtkGetMacro(TimeValue, float);
00120 
00122 
00123   vtkGetMacro(MinimumTimeValue, float);
00124   vtkGetMacro(MaximumTimeValue, float);
00126   
00128 
00129   vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
00131 
00136   int DetermineEnSightVersion();
00137 
00139 
00140   vtkBooleanMacro(ReadAllVariables, int);
00141   vtkSetMacro(ReadAllVariables, int);
00142   vtkGetMacro(ReadAllVariables, int);
00144   
00146 
00148   vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
00149   vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
00151   
00153 
00154   int GetNumberOfPointArrays();
00155   int GetNumberOfCellArrays();
00157   
00159 
00161   const char* GetPointArrayName(int index);
00162   const char* GetCellArrayName(int index);
00164   
00166 
00168   int GetPointArrayStatus(const char* name);
00169   int GetCellArrayStatus(const char* name);
00170   void SetPointArrayStatus(const char* name, int status);  
00171   void SetCellArrayStatus(const char* name, int status);  
00173   
00174   //BTX
00175   enum FileTypes
00176   {
00177     ENSIGHT_6             = 0,
00178     ENSIGHT_6_BINARY      = 1,
00179     ENSIGHT_GOLD          = 2,
00180     ENSIGHT_GOLD_BINARY   = 3,
00181     ENSIGHT_MASTER_SERVER = 4
00182   };
00183   //ETX
00184 
00186 
00189   void SetByteOrderToBigEndian();
00190   void SetByteOrderToLittleEndian();
00191   vtkSetMacro(ByteOrder, int);
00192   vtkGetMacro(ByteOrder, int);
00193   const char *GetByteOrderAsString();
00195 
00196 //BTX
00197   enum 
00198   {
00199     FILE_BIG_ENDIAN=0,
00200     FILE_LITTLE_ENDIAN=1,
00201     FILE_UNKNOWN_ENDIAN=2
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   // Callback registered with the SelectionObserver.
00250   static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
00251                                         void* clientdata, void* calldata);
00252   void SelectionModified();
00253   
00254   // Utility to create argument for vtkDataArraySelection::SetArrays.
00255   char** CreateStringArray(int numStrings);
00256   void DestroyStringArray(int numStrings, char** strings);
00257 
00258   // Fill the vtkDataArraySelection objects with the current set of
00259   // EnSight variables.
00260   void SetDataArraySelectionSetsFromVariables();
00261   
00262   // Fill the vtkDataArraySelection objects with the current set of
00263   // arrays in the internal EnSight reader.
00264   void SetDataArraySelectionSetsFromReader();
00265   
00266   // Fill the internal EnSight reader's vtkDataArraySelection objects
00267   // from those in this object.
00268   void SetReaderDataArraySelectionSetsFromSelf();
00269   
00270   istream* IS;
00271   FILE *IFile;
00272   vtkGenericEnSightReader *Reader;
00273   
00274   char* CaseFileName;
00275   char* GeometryFileName;
00276   char* FilePath;
00277 
00278   // array of types (one entry per instance of variable type in case file)
00279   int* VariableTypes;
00280   int* ComplexVariableTypes;
00281   
00282   // pointers to lists of descriptions
00283   char** VariableDescriptions;
00284   char** ComplexVariableDescriptions;
00285   
00286   int NumberOfVariables;
00287   int NumberOfComplexVariables;
00288   
00289   // number of file names / descriptions per type
00290   int NumberOfScalarsPerNode;
00291   int NumberOfVectorsPerNode;
00292   int NumberOfTensorsSymmPerNode;
00293   int NumberOfScalarsPerElement;
00294   int NumberOfVectorsPerElement;
00295   int NumberOfTensorsSymmPerElement;
00296   int NumberOfScalarsPerMeasuredNode;
00297   int NumberOfVectorsPerMeasuredNode;
00298   int NumberOfComplexScalarsPerNode;
00299   int NumberOfComplexVectorsPerNode;  
00300   int NumberOfComplexScalarsPerElement;
00301   int NumberOfComplexVectorsPerElement;
00302   
00303   float TimeValue;
00304   float MinimumTimeValue;
00305   float MaximumTimeValue;
00306   
00307   // Flag for whether TimeValue has been set.
00308   int TimeValueInitialized;
00309   
00310   vtkDataArrayCollection *TimeSets;
00311   virtual void SetTimeSets(vtkDataArrayCollection*);
00312 
00313   int ReadAllVariables;
00314 
00315   int ByteOrder;
00316   
00317   // The EnSight file version being read.  Valid after
00318   // UpdateInformation.  Value is -1 for unknown version.
00319   int EnSightVersion;
00320   
00321   // The array selections.  These map over the variables and complex
00322   // variables to hide the details of EnSight behind VTK terminology.
00323   vtkDataArraySelection* PointDataArraySelection;
00324   vtkDataArraySelection* CellDataArraySelection;
00325   
00326   // The observer to modify this object when the array selections are
00327   // modified.
00328   vtkCallbackCommand* SelectionObserver;
00329   
00330   // Whether the SelectionModified callback should invoke Modified.
00331   // This is used when we are copying to/from the internal reader.
00332   int SelectionModifiedDoNotCallModified;
00333   
00334 private:
00335   vtkGenericEnSightReader(const vtkGenericEnSightReader&);  // Not implemented.
00336   void operator=(const vtkGenericEnSightReader&);  // Not implemented.
00337 };
00338 
00339 #endif