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