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 
29 
30 class vtkCallbackCommand;
34 
35 //BTX
36 class TranslationTableType;
37 //ETX
38 
39 //BTX
40 // Cell/Point Ids store mode:
41 // Sparse Mode is supposed to be for a large number of distributed processes (Unstructured)
42 // Non Sparse Mode is supposed to be for a small number of distributed processes (Unstructured)
43 // Implicit Mode is for Structured Data
45  {
50  };
51 //ETX
52 
54 {
55 public:
56  static vtkGenericEnSightReader *New();
58  void PrintSelf(ostream& os, vtkIndent indent);
59 
61 
62  void SetCaseFileName(const char* fileName);
63  vtkGetStringMacro(CaseFileName);
65 
67 
68  vtkSetStringMacro(FilePath);
69  vtkGetStringMacro(FilePath);
71 
73 
74  vtkGetMacro(EnSightVersion, int);
76 
78 
79  vtkGetMacro(NumberOfVariables, int);
80  vtkGetMacro(NumberOfComplexVariables, int);
82 
84 
85  int GetNumberOfVariables(int type); // returns -1 if unknown type specified
86  vtkGetMacro(NumberOfScalarsPerNode, int);
87  vtkGetMacro(NumberOfVectorsPerNode, int);
88  vtkGetMacro(NumberOfTensorsSymmPerNode, int);
89  vtkGetMacro(NumberOfScalarsPerElement, int);
90  vtkGetMacro(NumberOfVectorsPerElement, int);
91  vtkGetMacro(NumberOfTensorsSymmPerElement, int);
92  vtkGetMacro(NumberOfScalarsPerMeasuredNode, int);
93  vtkGetMacro(NumberOfVectorsPerMeasuredNode, int);
94  vtkGetMacro(NumberOfComplexScalarsPerNode, int);
95  vtkGetMacro(NumberOfComplexVectorsPerNode, int);
96  vtkGetMacro(NumberOfComplexScalarsPerElement, int);
97  vtkGetMacro(NumberOfComplexVectorsPerElement, int);
99 
101  const char* GetDescription(int n);
102 
104  const char* GetComplexDescription(int n);
105 
114  const char* GetDescription(int n, int type);
115 
117 
118  int GetVariableType(int n);
119  int GetComplexVariableType(int n);
121 
123 
124  virtual void SetTimeValue(float value);
125  vtkGetMacro(TimeValue, float);
127 
129 
130  vtkGetMacro(MinimumTimeValue, float);
131  vtkGetMacro(MaximumTimeValue, float);
133 
135 
136  vtkGetObjectMacro(TimeSets, vtkDataArrayCollection);
138 
143  int DetermineEnSightVersion(int quiet=0);
144 
146 
147  vtkBooleanMacro(ReadAllVariables, int);
148  vtkSetMacro(ReadAllVariables, int);
149  vtkGetMacro(ReadAllVariables, int);
151 
153 
155  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
156  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
158 
160 
161  int GetNumberOfPointArrays();
162  int GetNumberOfCellArrays();
164 
166 
168  const char* GetPointArrayName(int index);
169  const char* GetCellArrayName(int index);
171 
173 
175  int GetPointArrayStatus(const char* name);
176  int GetCellArrayStatus(const char* name);
177  void SetPointArrayStatus(const char* name, int status);
178  void SetCellArrayStatus(const char* name, int status);
180 
181  //BTX
183  {
184  ENSIGHT_6 = 0,
185  ENSIGHT_6_BINARY = 1,
186  ENSIGHT_GOLD = 2,
187  ENSIGHT_GOLD_BINARY = 3,
188  ENSIGHT_MASTER_SERVER = 4
189  };
190  //ETX
191 
193 
196  void SetByteOrderToBigEndian();
197  void SetByteOrderToLittleEndian();
198  vtkSetMacro(ByteOrder, int);
199  vtkGetMacro(ByteOrder, int);
200  const char *GetByteOrderAsString();
202 
203 //BTX
204  enum
205  {
206  FILE_BIG_ENDIAN=0,
207  FILE_LITTLE_ENDIAN=1,
208  FILE_UNKNOWN_ENDIAN=2
209  };
210 //ETX
211 
213 
215  vtkGetStringMacro(GeometryFileName);
217 
219 
227  vtkSetMacro(ParticleCoordinatesByIndex, int);
228  vtkGetMacro(ParticleCoordinatesByIndex, int);
229  vtkBooleanMacro(ParticleCoordinatesByIndex, int);
231 
234  static int CanReadFile(const char *casefilename);
235 
236 //THIB
237 vtkGenericEnSightReader* GetReader() { return this->Reader; }
238 
239 
240 protected:
243 
245  virtual int RequestInformation(vtkInformation*,
248  virtual int RequestData(vtkInformation*,
251 
254  int ReadLine(char result[256]);
255 
258  int ReadBinaryLine(char result[80]);
259 
260  // Internal function that skips blank lines and reads the 1st
261  // non-blank line it finds (up to 256 characters).
262  // Returns 0 is there was an error.
263  int ReadNextDataLine(char result[256]);
264 
266 
267  vtkSetStringMacro(GeometryFileName);
269 
271 
272  void AddVariableDescription(const char* description);
273  void AddComplexVariableDescription(const char* description);
275 
277 
278  void AddVariableType(int variableType);
279  void AddComplexVariableType(int variableType);
281 
283 
285  int ReplaceWildcards(char* fileName, int timeSet, int fileSet);
286  void ReplaceWildcardsHelper(char* fileName, int num);
288 
289  // Callback registered with the SelectionObserver.
290  static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
291  void* clientdata, void* calldata);
292  void SelectionModified();
293 
294  // Utility to create argument for vtkDataArraySelection::SetArrays.
295  char** CreateStringArray(int numStrings);
296  void DestroyStringArray(int numStrings, char** strings);
297 
298  // Fill the vtkDataArraySelection objects with the current set of
299  // EnSight variables.
300  void SetDataArraySelectionSetsFromVariables();
301 
302  // Fill the vtkDataArraySelection objects with the current set of
303  // arrays in the internal EnSight reader.
304  void SetDataArraySelectionSetsFromReader();
305 
306  // Fill the internal EnSight reader's vtkDataArraySelection objects
307  // from those in this object.
308  void SetReaderDataArraySelectionSetsFromSelf();
309 
310  istream* IS;
311  FILE *IFile;
313 
316  char* FilePath;
317 
318  // array of types (one entry per instance of variable type in case file)
321 
322  // pointers to lists of descriptions
325 
328 
329  // number of file names / descriptions per type
342 
343  float TimeValue;
346 
347  // Flag for whether TimeValue has been set.
349 
351  virtual void SetTimeSets(vtkDataArrayCollection*);
352 
354 
357 
358  // The EnSight file version being read. Valid after
359  // UpdateInformation. Value is -1 for unknown version.
361 
362  // The array selections. These map over the variables and complex
363  // variables to hide the details of EnSight behind VTK terminology.
366 
367  // The observer to modify this object when the array selections are
368  // modified.
370 
371  // Whether the SelectionModified callback should invoke Modified.
372  // This is used when we are copying to/from the internal reader.
374 
375  // Insert a partId and return the 'realId' that should be used.
376  int InsertNewPartId(int partId);
377 
378  // Wrapper around an stl map
379  TranslationTableType *TranslationTable;
380 
381 private:
382  vtkGenericEnSightReader(const vtkGenericEnSightReader&); // Not implemented.
383  void operator=(const vtkGenericEnSightReader&); // Not implemented.
384 };
385 
386 #endif
vtkDataArrayCollection * TimeSets
vtkCallbackCommand * SelectionObserver
abstract base class for most VTK objects
Definition: vtkObject.h:60
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:37
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.
#define VTK_IO_EXPORT
vtkDataArraySelection * CellDataArraySelection
class to read any type of EnSight files
vtkGenericEnSightReader * GetReader()
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)