VTK
vtkMPASReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMPASReader.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 =========================================================================*/
15 /*=========================================================================
16 
17 Copyright (c) 2002-2005 Los Alamos National Laboratory
18 
19 This software and ancillary information known as vtk_ext (and herein
20 called "SOFTWARE") is made available under the terms described below.
21 The SOFTWARE has been approved for release with associated LA_CC
22 Number 99-44, granted by Los Alamos National Laboratory in July 1999.
23 
24 Unless otherwise indicated, this SOFTWARE has been authored by an
25 employee or employees of the University of California, operator of the
26 Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
27 the United States Department of Energy.
28 
29 The United States Government has rights to use, reproduce, and
30 distribute this SOFTWARE. The public may copy, distribute, prepare
31 derivative works and publicly display this SOFTWARE without charge,
32 provided that this Notice and any statement of authorship are
33 reproduced on all copies.
34 
35 Neither the U. S. Government, the University of California, nor the
36 Advanced Computing Laboratory makes any warranty, either express or
37 implied, nor assumes any liability or responsibility for the use of
38 this SOFTWARE.
39 
40 If SOFTWARE is modified to produce derivative works, such modified
41 SOFTWARE should be clearly marked, so as not to confuse it with the
42 version available from Los Alamos National Laboratory.
43 
44 =========================================================================*/
77 #ifndef __vtkMPASReader_h
78 #define __vtkMPASReader_h
79 
80 #define MAX_VARS 100
81 #define MAX_VAR_NAME 100
82 
84 
85 class vtkCallbackCommand;
87 class vtkDoubleArray;
88 class vtkStdString;
89 class vtkStringArray;
90 
92 {
93  public:
94  static vtkMPASReader *New();
96  void PrintSelf(ostream& os, vtkIndent indent);
97 
99 
100  vtkSetStringMacro(FileName);
101  vtkGetStringMacro(FileName);
103 
105 
106  vtkGetMacro(maxCells, int);
108 
110 
111  vtkGetMacro(maxPoints, int);
113 
115 
116  vtkGetMacro(numCellVars, int);
117  vtkGetMacro(numPointVars, int);
119 
121 
125 
127 
130  int GetNumberOfPointArrays();
131  const char* GetPointArrayName(int index);
132  int GetPointArrayStatus(const char* name);
133  void SetPointArrayStatus(const char* name, int status);
134  void DisableAllPointArrays();
135  void EnableAllPointArrays();
137 
138  int GetNumberOfCellArrays();
139  const char* GetCellArrayName(int index);
140  int GetCellArrayStatus(const char* name);
141  void SetCellArrayStatus(const char* name, int status);
142  void DisableAllCellArrays();
143  void EnableAllCellArrays();
144 
145  void SetVerticalLevel(int level);
146  vtkGetVector2Macro(VerticalLevelRange, int);
147 
148  void SetLayerThickness(int val);
149  vtkGetVector2Macro(LayerThicknessRange, int);
150 
151  void SetCenterLon(int val);
152  vtkGetVector2Macro(CenterLonRange, int);
153 
154  void SetProjectLatLon(bool val);
155  vtkGetMacro(ProjectLatLon, bool);
156 
157  void SetIsAtmosphere(bool val);
158  vtkGetMacro(IsAtmosphere, bool);
159 
160  void SetIsZeroCentered(bool val);
161  vtkGetMacro(IsZeroCentered, bool);
162 
163  void SetShowMultilayerView(bool val);
164  vtkGetMacro(ShowMultilayerView, bool);
165 
167  static int CanReadFile(const char *filename);
168 
169  protected:
170  vtkMPASReader();
171  ~vtkMPASReader();
172  void DestroyData();
173 
174  char *FileName; // First field part file giving path
175  /*
176  int Rank; // Number of this processor
177  int TotalRank; // Number of processors
178  */
179 
180  // int NumberOfPieces; // Number of files in dataset
181  // vtkIdType NumberOfTuples; // Number of tuples in sub extent
182 
183  vtkStdString* VariableName; // Names of each variable
184  int* VariableType; // Scalar, vector or tensor
185 
186  int NumberOfTimeSteps; // Temporal domain
187  double* TimeSteps; // Times available for request
188  double dTime;
189 
190 
191  // Observer to modify this object when array selections are modified
193 
198 
199 
200  static void SelectionCallback(vtkObject* caller, unsigned long eid,
201  void* clientdata, void* calldata);
202 
205 
206  // params
207 
208  // Selected field of interest
211 
212  vtkDoubleArray** cellVarDataArray; // Actual data arrays
213  vtkDoubleArray** pointVarDataArray; // Actual data arrays
214 
216  int VerticalLevelRange[2];
217 
219  int LayerThicknessRange[2];
220 
222  int CenterLonRange[2];
223 
228 
230  bool doBugFix;
231  double centerRad;
232 
233 
234  // geometry
236  int numCells;
241  int currentExtraPoint; // current extra point
242  int currentExtraCell; // current extra cell
243  double* pointX; // x coord of point
244  double* pointY; // y coord of point
245  double* pointZ; // z coord of point
248  int* origConnections; // original connections
249  int* modConnections; // modified connections
250  int* cellMap; // maps from added cell to original cell #
251  int* pointMap; // maps from added point to original point #
252  int* maxLevelPoint; //
253  int maxCells; // max cells
254  int maxPoints; // max points
255  int verticalIndex; // for singleLayer, which vertical level
256 
257  // vars
260  double* pointVarData;
261  double* cellVarData;
262 
263  void SetDefaults();
264  int GetNcDims();
265  int CheckParams();
266  int GetNcVars(const char* cellDimName, const char* pointDimName);
267  int ReadAndOutputGrid(bool init);
268  int ReadAndOutputVariableData();
269  int BuildVarArrays();
270  int AllocSphereGeometry();
271  int AllocLatLonGeometry();
272  void ShiftLonData();
273  int AddMirrorPoint(int index, double dividerX);
274  void FixPoints();
275  int EliminateXWrap();
276  void OutputPoints(bool init);
277  void OutputCells(bool init);
278  unsigned char GetCellType();
279  void LoadGeometryData(int var, double dTime);
280  int LoadPointVarData(int variable, double dTime);
281  int LoadCellVarData(int variable, double dTime);
282  int RegenerateGeometry();
283 
284  private:
285  vtkMPASReader(const vtkMPASReader&); // Not implemented.
286  void operator=(const vtkMPASReader&); // Not implemented.
287  class Internal;
288  Internal *Internals;
289 
290 };
291 
292 #endif