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 =========================================================================*/
80 #ifndef __vtkMPASReader_h
81 #define __vtkMPASReader_h
82 
83 #define MAX_VARS 100
84 #define MAX_VAR_NAME 100
85 
87 
88 class vtkCallbackCommand;
90 class vtkDoubleArray;
91 class vtkStdString;
92 class vtkStringArray;
93 
95 {
96  public:
97  static vtkMPASReader *New();
99  void PrintSelf(ostream& os, vtkIndent indent);
100 
102 
103  vtkSetStringMacro(FileName);
104  vtkGetStringMacro(FileName);
106 
108 
109  vtkGetMacro(MaximumCells, int);
111 
113 
114  vtkGetMacro(MaximumPoints, int);
116 
118 
119  vtkGetMacro(NumberOfCellVars, int);
120  vtkGetMacro(NumberOfPointVars, int);
122 
124 
128 
130 
133  int GetNumberOfPointArrays();
134  const char* GetPointArrayName(int index);
135  int GetPointArrayStatus(const char* name);
136  void SetPointArrayStatus(const char* name, int status);
137  void DisableAllPointArrays();
138  void EnableAllPointArrays();
140 
141  int GetNumberOfCellArrays();
142  const char* GetCellArrayName(int index);
143  int GetCellArrayStatus(const char* name);
144  void SetCellArrayStatus(const char* name, int status);
145  void DisableAllCellArrays();
146  void EnableAllCellArrays();
147 
148  void SetVerticalLevel(int level);
149  vtkGetVector2Macro(VerticalLevelRange, int);
150 
151  void SetLayerThickness(int val);
152  vtkGetVector2Macro(LayerThicknessRange, int);
153 
154  void SetCenterLon(int val);
155  vtkGetVector2Macro(CenterLonRange, int);
156 
157  void SetProjectLatLon(bool val);
158  vtkGetMacro(ProjectLatLon, bool);
159 
160  void SetIsAtmosphere(bool val);
161  vtkGetMacro(IsAtmosphere, bool);
162 
163  void SetIsZeroCentered(bool val);
164  vtkGetMacro(IsZeroCentered, bool);
165 
166  void SetShowMultilayerView(bool val);
167  vtkGetMacro(ShowMultilayerView, bool);
168 
170  static int CanReadFile(const char *filename);
171 
172  protected:
173  vtkMPASReader();
174  ~vtkMPASReader();
175  void DestroyData();
176 
177  char *FileName; // First field part file giving path
178  /*
179  int Rank; // Number of this processor
180  int TotalRank; // Number of processors
181  */
182 
183  // int NumberOfPieces; // Number of files in dataset
184  // vtkIdType NumberOfTuples; // Number of tuples in sub extent
185 
186  vtkStdString* VariableName; // Names of each variable
187  int* VariableType; // Scalar, vector or tensor
188 
189  int NumberOfTimeSteps; // Temporal domain
190  double* TimeSteps; // Times available for request
191  double DTime;
192 
193 
194  // Observer to modify this object when array selections are modified
196 
201 
202 
203  static void SelectionCallback(vtkObject* caller, unsigned long eid,
204  void* clientdata, void* calldata);
205 
208 
209  // params
210 
211  // Selected field of interest
214 
215  vtkDoubleArray** CellVarDataArray; // Actual data arrays
216  vtkDoubleArray** PointVarDataArray; // Actual data arrays
217 
219  int VerticalLevelRange[2];
220 
222  int LayerThicknessRange[2];
223 
225  int CenterLonRange[2];
226 
231 
233  bool DoBugFix;
234  double CenterRad;
235 
236 
237  // geometry
244  int CurrentExtraPoint; // current extra point
245  int CurrentExtraCell; // current extra cell
246  double* PointX; // x coord of point
247  double* PointY; // y coord of point
248  double* PointZ; // z coord of point
251  int* OrigConnections; // original connections
252  int* ModConnections; // modified connections
253  int* CellMap; // maps from added cell to original cell #
254  int* PointMap; // maps from added point to original point #
256  int MaximumCells; // max cells
257  int MaximumPoints; // max points
258  int VerticalIndex; // for singleLayer, which vertical level
259 
260  // vars
263  double* PointVarData;
264 
265  void SetDefaults();
266  int GetNcDims();
267  int CheckParams();
268  int GetNcVars(const char* cellDimName, const char* pointDimName);
269  int ReadAndOutputGrid(bool init);
270  int ReadAndOutputVariableData();
271  int BuildVarArrays();
272  int AllocSphereGeometry();
273  int AllocLatLonGeometry();
274  void ShiftLonData();
275  int AddMirrorPoint(int index, double dividerX);
276  void FixPoints();
277  int EliminateXWrap();
278  void OutputPoints(bool init);
279  void OutputCells(bool init);
280  unsigned char GetCellType();
281  void LoadGeometryData(int var, double dTime);
282  int LoadPointVarData(int variable, double dTime);
283  int LoadCellVarData(int variable, double dTime);
284  int RegenerateGeometry();
285 
286  private:
287  vtkMPASReader(const vtkMPASReader&); // Not implemented.
288  void operator=(const vtkMPASReader&); // Not implemented.
289  class Internal;
290  Internal *Internals;
291 
292 };
293 
294 #endif