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 =========================================================================*/
79 #ifndef vtkMPASReader_h
80 #define vtkMPASReader_h
81 
82 #include "vtkIONetCDFModule.h" // For export macro
84 
85 #include <string> // for std::string
86 
87 class vtkCallbackCommand;
89 class vtkDoubleArray;
90 class vtkStdString;
91 class vtkStringArray;
92 
93 class NcVar;
94 class NcDim;
95 
97 {
98  public:
99  static vtkMPASReader *New();
101  void PrintSelf(ostream& os, vtkIndent indent);
102 
104 
105  vtkSetStringMacro(FileName);
106  vtkGetStringMacro(FileName);
108 
110 
111  vtkGetMacro(MaximumCells, int);
113 
115 
116  vtkGetMacro(MaximumPoints, int);
118 
120 
121  virtual int GetNumberOfCellVars();
122  virtual int GetNumberOfPointVars();
124 
126 
130 
132 
136  vtkSetMacro(UseDimensionedArrayNames, bool)
137  vtkGetMacro(UseDimensionedArrayNames, bool)
138  vtkBooleanMacro(UseDimensionedArrayNames, bool)
140 
142 
145  int GetNumberOfPointArrays();
146  const char* GetPointArrayName(int index);
147  int GetPointArrayStatus(const char* name);
148  void SetPointArrayStatus(const char* name, int status);
149  void DisableAllPointArrays();
150  void EnableAllPointArrays();
152 
153  int GetNumberOfCellArrays();
154  const char* GetCellArrayName(int index);
155  int GetCellArrayStatus(const char* name);
156  void SetCellArrayStatus(const char* name, int status);
157  void DisableAllCellArrays();
158  void EnableAllCellArrays();
159 
161 
168  int GetNumberOfDimensions();
169  std::string GetDimensionName(int idx);
170  vtkStringArray* GetAllDimensions();
171  int GetDimensionCurrentIndex(const std::string &dim);
172  void SetDimensionCurrentIndex(const std::string &dim, int idx);
173  int GetDimensionSize(const std::string &dim);
175 
177 
179  vtkSetMacro(VerticalDimension, std::string)
180  vtkGetMacro(VerticalDimension, std::string)
182 
184 
186  void SetVerticalLevel(int level);
187  int GetVerticalLevel();
189 
190  vtkGetVector2Macro(VerticalLevelRange, int)
191 
192  vtkSetMacro(LayerThickness, int)
193  vtkGetMacro(LayerThickness, int)
194  vtkGetVector2Macro(LayerThicknessRange, int)
195 
196  void SetCenterLon(int val);
197  vtkGetVector2Macro(CenterLonRange, int)
198 
199  vtkSetMacro(ProjectLatLon, bool)
200  vtkGetMacro(ProjectLatLon, bool)
201 
202  vtkSetMacro(IsAtmosphere, bool)
203  vtkGetMacro(IsAtmosphere, bool)
204 
205  vtkSetMacro(IsZeroCentered, bool)
206  vtkGetMacro(IsZeroCentered, bool)
207 
208  vtkSetMacro(ShowMultilayerView, bool)
209  vtkGetMacro(ShowMultilayerView, bool)
210 
212  static int CanReadFile(const char *filename);
213 
214  unsigned long GetMTime();
215 
216  protected:
217  vtkMPASReader();
218  ~vtkMPASReader();
219  void ReleaseNcData();
220  void DestroyData();
221 
222  char *FileName; // First field part file giving path
223 
224  int NumberOfTimeSteps; // Temporal domain
225  double DTime; // The current time
226 
227  // Observer to modify this object when array selections are modified
228  vtkCallbackCommand* SelectionObserver;
229 
230  int RequestData(vtkInformation *, vtkInformationVector **,
231  vtkInformationVector *);
232  int RequestInformation(vtkInformation *, vtkInformationVector **,
233  vtkInformationVector *);
234 
235 
236  static void SelectionCallback(vtkObject* caller, unsigned long eid,
237  void* clientdata, void* calldata);
238 
239  // Selected field of interest
240  vtkDataArraySelection* PointDataArraySelection;
241  vtkDataArraySelection* CellDataArraySelection;
242 
245  void UpdateDimensions(bool force = false);
246 
247  std::string VerticalDimension;
248  int VerticalLevelRange[2];
249 
250  int LayerThickness;
251  int LayerThicknessRange[2];
252 
253  int CenterLon;
254  int CenterLonRange[2];
255 
257  {
260  Planar
261  };
262 
264 
265  bool ProjectLatLon; // User option
266  bool OnASphere; // Data file attribute
270 
272  bool DoBugFix;
273  double CenterRad;
274 
276 
277  // geometry
284  int CurrentExtraPoint; // current extra point
285  int CurrentExtraCell; // current extra cell
286  double* PointX; // x coord of point
287  double* PointY; // y coord of point
288  double* PointZ; // z coord of point
291  int* OrigConnections; // original connections
292  int* ModConnections; // modified connections
293  int* CellMap; // maps from added cell to original cell #
294  int* PointMap; // maps from added point to original point #
296  int MaximumCells; // max cells
297  int MaximumPoints; // max points
298 
299  void SetDefaults();
300  int GetNcDims();
301  int GetNcAtts();
302  int CheckParams();
303  int GetNcVars(const char* cellDimName, const char* pointDimName);
304  int ReadAndOutputGrid();
305  int BuildVarArrays();
306  int AllocSphericalGeometry();
307  int AllocProjectedGeometry();
308  int AllocPlanarGeometry();
309  void ShiftLonData();
310  int AddMirrorPoint(int index, double dividerX, double offset);
311  void FixPoints();
312  int EliminateXWrap();
313  void OutputPoints();
314  void OutputCells();
315  unsigned char GetCellType();
316 
322  bool ValidateDimensions(NcVar *var, bool silent, int ndims, ...);
323 
325  long GetCursorForDimension(const NcDim *dim);
326 
328  size_t GetCountForDimension(const NcDim *dim);
329 
334  long InitializeDimension(const NcDim *dim);
335 
336  vtkDataArray* LoadPointVarData(int variable);
337  vtkDataArray* LoadCellVarData(int variable);
338  vtkDataArray* LookupPointDataArray(int varIdx);
339  vtkDataArray* LookupCellDataArray(int varIdx);
340 
346  void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
347 
348  private:
349  vtkMPASReader(const vtkMPASReader&); // Not implemented.
350  void operator=(const vtkMPASReader&); // Not implemented.
351 
352  class Internal;
353  Internal *Internals;
354 
355  static int NcTypeToVtkType(int ncType);
356 
357  vtkDataArray* CreateDataArray(int ncType);
358  vtkIdType ComputeNumberOfTuples(NcVar *ncVar);
359 
360  template <typename ValueType>
361  bool LoadDataArray(NcVar *ncVar, vtkDataArray *array, bool resize = true);
362 
363  template <typename ValueType>
364  int LoadPointVarDataImpl(NcVar *ncVar, vtkDataArray *array);
365 
366  template <typename ValueType>
367  int LoadCellVarDataImpl(NcVar *ncVar, vtkDataArray *array);
368 };
369 
370 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
GeometryType Geometry
abstract base class for most VTK objects
Definition: vtkObject.h:61
Store vtkAlgorithm input/output information.
static vtkUnstructuredGridAlgorithm * New()
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
int * OrigConnections
int vtkIdType
Definition: vtkType.h:247
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:96
dynamic, self-adjusting array of double
double * PointX
bool UseDimensionedArrayNames
supports function callbacks
double * PointY
a simple class to control print indentation
Definition: vtkIndent.h:38
Store on/off settings for data arrays for a vtkSource.
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
void PrintSelf(ostream &os, vtkIndent indent)
Superclass for algorithms that produce only unstructured grid as output.
Store zero or more vtkInformation instances.
#define VTKIONETCDF_EXPORT
int * MaximumLevelPoint
vtkUnstructuredGrid * GetOutput()
int * ModConnections
bool ShowMultilayerView