VTK
vtkGenericEnSightReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGenericEnSightReader.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 =========================================================================*/
25 #ifndef vtkGenericEnSightReader_h
26 #define vtkGenericEnSightReader_h
27 
28 #include "vtkIOEnSightModule.h" // For export macro
30 
31 class vtkCallbackCommand;
35 
36 //BTX
37 class TranslationTableType;
38 //ETX
39 
40 //BTX
41 // Cell/Point Ids store mode:
42 // Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
43 // Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
44 // Implicit Mode is for Structured Data
46  {
51  };
52 //ETX
53 
55 {
56 public:
57  static vtkGenericEnSightReader *New();
59  void PrintSelf(ostream& os, vtkIndent indent);
60 
62 
63  void SetCaseFileName(const char* fileName);
64  vtkGetStringMacro(CaseFileName);
66 
68 
69  vtkSetStringMacro(FilePath);
70  vtkGetStringMacro(FilePath);
72 
74 
75  vtkGetMacro(EnSightVersion, int);
77 
79 
80  vtkGetMacro(NumberOfVariables, int);
81  vtkGetMacro(NumberOfComplexVariables, int);
83 
85 
86  int GetNumberOfVariables(int type); // returns -1 if unknown type specified
87  vtkGetMacro(NumberOfScalarsPerNode, int);
88  vtkGetMacro(NumberOfVectorsPerNode, int);
89  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
90  vtkGetMacro(NumberOfScalarsPerElement, int);
91  vtkGetMacro(NumberOfVectorsPerElement, int);
92  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
93  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
94  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
95  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
96  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
97  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
98  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
100 
102  const char* GetDescription(int n);
103 
105  const char* GetComplexDescription(int n);
106 
115  const char* GetDescription(int n, int type);
116 
118 
119  int GetVariableType(int n);
120  int GetComplexVariableType(int n);
122 
124 
125  virtual void SetTimeValue(float value);
126  vtkGetMacro(TimeValue, float);
128 
130 
131  vtkGetMacro(MinimumTimeValue, float);
132  vtkGetMacro(MaximumTimeValue, float);
134 
136 
137  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
139 
144  int DetermineEnSightVersion(int quiet=0);
145 
147 
148  vtkBooleanMacro(ReadAllVariables, int);
149  vtkSetMacro(ReadAllVariables, int);
150  vtkGetMacro(ReadAllVariables, int);
152 
154 
156  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
157  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
159 
161 
162  int GetNumberOfPointArrays();
163  int GetNumberOfCellArrays();
165 
167 
169  const char* GetPointArrayName(int index);
170  const char* GetCellArrayName(int index);
172 
174 
176  int GetPointArrayStatus(const char* name);
177  int GetCellArrayStatus(const char* name);
178  void SetPointArrayStatus(const char* name, int status);
179  void SetCellArrayStatus(const char* name, int status);
181 
182  //BTX
184  {
185  ENSIGHT_6 = 0,
186  ENSIGHT_6_BINARY = 1,
187  ENSIGHT_GOLD = 2,
188  ENSIGHT_GOLD_BINARY = 3,
189  ENSIGHT_MASTER_SERVER = 4
190  };
191  //ETX
192 
194 
197  void SetByteOrderToBigEndian();
198  void SetByteOrderToLittleEndian();
199  vtkSetMacro(ByteOrder, int);
200  vtkGetMacro(ByteOrder, int);
201  const char *GetByteOrderAsString();
203 
204 //BTX
205  enum
206  {
207  FILE_BIG_ENDIAN=0,
208  FILE_LITTLE_ENDIAN=1,
209  FILE_UNKNOWN_ENDIAN=2
210  };
211 //ETX
212 
214 
216  vtkGetStringMacro(GeometryFileName);
218 
220 
228  vtkSetMacro(ParticleCoordinatesByIndex, int);
229  vtkGetMacro(ParticleCoordinatesByIndex, int);
230  vtkBooleanMacro(ParticleCoordinatesByIndex, int);
232 
235  static int CanReadFile(const char *casefilename);
236 
237 //THIB
238 vtkGenericEnSightReader* GetReader() { return this->Reader; }
239 
240 
241 protected:
244 
246  virtual int RequestInformation(vtkInformation*,
249  virtual int RequestData(vtkInformation*,
252 
256  virtual void ClearForNewCaseFileName();
257 
260  int ReadLine(char result[256]);
261 
264  int ReadBinaryLine(char result[80]);
265 
266  // Internal function that skips blank lines and reads the 1st
267  // non-blank line it finds (up to 256 characters).
268  // Returns 0 is there was an error.
269  int ReadNextDataLine(char result[256]);
270 
272 
273  vtkSetStringMacro(GeometryFileName);
275 
277 
278  void AddVariableDescription(const char* description);
279  void AddComplexVariableDescription(const char* description);
281 
283 
284  void AddVariableType(int variableType);
285  void AddComplexVariableType(int variableType);
287 
289 
291  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
292  void ReplaceWildcardsHelper(char* fileName, int num);
294 
295  // Callback registered with the SelectionObserver.
296  static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
297  void* clientdata, void* calldata);
298  void SelectionModified();
299 
300  // Utility to create argument for vtkDataArraySelection::SetArrays.
301  char** CreateStringArray(int numStrings);
302  void DestroyStringArray(int numStrings, char** strings);
303 
304  // Fill the vtkDataArraySelection objects with the current set of
305  // EnSight variables.
306  void SetDataArraySelectionSetsFromVariables();
307 
308  // Fill the vtkDataArraySelection objects with the current set of
309  // arrays in the internal EnSight reader.
310  void SetDataArraySelectionSetsFromReader();
311 
312  // Fill the internal EnSight reader's vtkDataArraySelection objects
313  // from those in this object.
314  void SetReaderDataArraySelectionSetsFromSelf();
315 
316  istream* IS;
317  FILE *IFile;
319 
322  char* FilePath;
323 
324  // array of types (one entry per instance of variable type in case file)
327 
328  // pointers to lists of descriptions
331 
334 
335  // number of file names / descriptions per type
348 
349  float TimeValue;
352 
353  // Flag for whether TimeValue has been set.
355 
357  virtual void SetTimeSets(vtkDataArrayCollection*);
358 
360 
363 
364  // The EnSight file version being read. Valid after
365  // UpdateInformation. Value is -1 for unknown version.
367 
368  // The array selections. These map over the variables and complex
369  // variables to hide the details of EnSight behind VTK terminology.
372 
373  // The observer to modify this object when the array selections are
374  // modified.
376 
377  // Whether the SelectionModified callback should invoke Modified.
378  // This is used when we are copying to/from the internal reader.
380 
381  // Insert a partId and return the 'realId' that should be used.
382  int InsertNewPartId(int partId);
383 
384  // Wrapper around an stl map
385  TranslationTableType *TranslationTable;
386 
387 private:
388  vtkGenericEnSightReader(const vtkGenericEnSightReader&); // Not implemented.
389  void operator=(const vtkGenericEnSightReader&); // Not implemented.
390 };
391 
392 #endif
vtkDataArrayCollection * TimeSets
vtkCallbackCommand * SelectionObserver
abstract base class for most VTK objects
Definition: vtkObject.h:61
Store vtkAlgorithm input/output information.
EnsightReaderCellIdMode
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
static vtkMultiBlockDataSetAlgorithm * New()
vtkDataArraySelection * PointDataArraySelection
virtual int FillOutputPortInformation(int port, vtkInformation *info)
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:38
Store on/off settings for data arrays for a vtkSource.
TranslationTableType * TranslationTable
vtkGenericEnSightReader * Reader
maintain an unordered list of dataarray objects
maintain an unordered list of dataarray objects
void PrintSelf(ostream &os, vtkIndent indent)
Store zero or more vtkInformation instances.
vtkDataArraySelection * CellDataArraySelection
#define VTKIOENSIGHT_EXPORT
class to read any type of EnSight files
vtkGenericEnSightReader * GetReader()
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)