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 #include "vtkIONetCDFModule.h" // For export macro
85 
86 #include <string> // for std::string
87 
88 class vtkCallbackCommand;
90 class vtkDoubleArray;
91 class vtkStdString;
92 class vtkStringArray;
93 
94 class NcVar;
95 class NcDim;
96 
97 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
98 {
99  public:
100  static vtkMPASReader *New();
102  void PrintSelf(ostream& os, vtkIndent indent);
103 
105 
108  vtkSetStringMacro(FileName);
109  vtkGetStringMacro(FileName);
111 
113 
116  vtkGetMacro(MaximumCells, int);
118 
120 
123  vtkGetMacro(MaximumPoints, int);
125 
127 
130  virtual int GetNumberOfCellVars();
131  virtual int GetNumberOfPointVars();
133 
135 
141 
143 
149  vtkSetMacro(UseDimensionedArrayNames, bool)
150  vtkGetMacro(UseDimensionedArrayNames, bool)
151  vtkBooleanMacro(UseDimensionedArrayNames, bool)
153 
155 
160  int GetNumberOfPointArrays();
161  const char* GetPointArrayName(int index);
162  int GetPointArrayStatus(const char* name);
163  void SetPointArrayStatus(const char* name, int status);
164  void DisableAllPointArrays();
165  void EnableAllPointArrays();
167 
168  int GetNumberOfCellArrays();
169  const char* GetCellArrayName(int index);
170  int GetCellArrayStatus(const char* name);
171  void SetCellArrayStatus(const char* name, int status);
172  void DisableAllCellArrays();
173  void EnableAllCellArrays();
174 
176 
184  int GetNumberOfDimensions();
185  std::string GetDimensionName(int idx);
186  vtkStringArray* GetAllDimensions();
187  int GetDimensionCurrentIndex(const std::string &dim);
188  void SetDimensionCurrentIndex(const std::string &dim, int idx);
189  int GetDimensionSize(const std::string &dim);
191 
193 
197  vtkSetMacro(VerticalDimension, std::string)
198  vtkGetMacro(VerticalDimension, std::string)
200 
202 
206  void SetVerticalLevel(int level);
207  int GetVerticalLevel();
209 
210  vtkGetVector2Macro(VerticalLevelRange, int)
211 
212  vtkSetMacro(LayerThickness, int)
213  vtkGetMacro(LayerThickness, int)
214  vtkGetVector2Macro(LayerThicknessRange, int)
215 
216  void SetCenterLon(int val);
217  vtkGetVector2Macro(CenterLonRange, int)
218 
219  vtkSetMacro(ProjectLatLon, bool)
220  vtkGetMacro(ProjectLatLon, bool)
221 
222  vtkSetMacro(IsAtmosphere, bool)
223  vtkGetMacro(IsAtmosphere, bool)
224 
225  vtkSetMacro(IsZeroCentered, bool)
226  vtkGetMacro(IsZeroCentered, bool)
227 
228  vtkSetMacro(ShowMultilayerView, bool)
229  vtkGetMacro(ShowMultilayerView, bool)
230 
234  static int CanReadFile(const char *filename);
235 
236  vtkMTimeType GetMTime();
237 
238  protected:
239  vtkMPASReader();
240  ~vtkMPASReader();
241  void ReleaseNcData();
242  void DestroyData();
243 
244  char *FileName; // First field part file giving path
245 
246  int NumberOfTimeSteps; // Temporal domain
247  double DTime; // The current time
248 
249  // Observer to modify this object when array selections are modified
250  vtkCallbackCommand* SelectionObserver;
251 
252  int RequestData(vtkInformation *, vtkInformationVector **,
253  vtkInformationVector *);
254  int RequestInformation(vtkInformation *, vtkInformationVector **,
255  vtkInformationVector *);
256 
257 
258  static void SelectionCallback(vtkObject* caller, unsigned long eid,
259  void* clientdata, void* calldata);
260 
261  // Selected field of interest
262  vtkDataArraySelection* PointDataArraySelection;
263  vtkDataArraySelection* CellDataArraySelection;
264 
269  void UpdateDimensions(bool force = false);
270 
271  std::string VerticalDimension;
272  int VerticalLevelRange[2];
273 
274  int LayerThickness;
275  int LayerThicknessRange[2];
276 
277  int CenterLon;
278  int CenterLonRange[2];
279 
281  {
284  Planar
285  };
286 
288 
289  bool ProjectLatLon; // User option
290  bool OnASphere; // Data file attribute
294 
296  bool DoBugFix;
297  double CenterRad;
298 
300 
301  // geometry
308  int CurrentExtraPoint; // current extra point
309  int CurrentExtraCell; // current extra cell
310  double* PointX; // x coord of point
311  double* PointY; // y coord of point
312  double* PointZ; // z coord of point
315  int* OrigConnections; // original connections
316  int* ModConnections; // modified connections
317  int* CellMap; // maps from added cell to original cell #
318  int* PointMap; // maps from added point to original point #
320  int MaximumCells; // max cells
321  int MaximumPoints; // max points
322 
323  void SetDefaults();
324  int GetNcDims();
325  int GetNcAtts();
326  int CheckParams();
327  int GetNcVars(const char* cellDimName, const char* pointDimName);
328  int ReadAndOutputGrid();
329  int BuildVarArrays();
330  int AllocSphericalGeometry();
331  int AllocProjectedGeometry();
332  int AllocPlanarGeometry();
333  void ShiftLonData();
334  int AddMirrorPoint(int index, double dividerX, double offset);
335  void FixPoints();
336  int EliminateXWrap();
337  void OutputPoints();
338  void OutputCells();
339  unsigned char GetCellType();
340 
348  bool ValidateDimensions(NcVar *var, bool silent, int ndims, ...);
349 
353  long GetCursorForDimension(const NcDim *dim);
354 
358  size_t GetCountForDimension(const NcDim *dim);
359 
365  long InitializeDimension(const NcDim *dim);
366 
367  vtkDataArray* LoadPointVarData(int variable);
368  vtkDataArray* LoadCellVarData(int variable);
369  vtkDataArray* LookupPointDataArray(int varIdx);
370  vtkDataArray* LookupCellDataArray(int varIdx);
371 
380  void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
381 
382  private:
383  vtkMPASReader(const vtkMPASReader&) VTK_DELETE_FUNCTION;
384  void operator=(const vtkMPASReader&) VTK_DELETE_FUNCTION;
385 
386  class Internal;
387  Internal *Internals;
388 
389  static int NcTypeToVtkType(int ncType);
390 
391  vtkDataArray* CreateDataArray(int ncType);
392  vtkIdType ComputeNumberOfTuples(NcVar *ncVar);
393 
394  template <typename ValueType>
395  bool LoadDataArray(NcVar *ncVar, vtkDataArray *array, bool resize = true);
396 
397  template <typename ValueType>
398  int LoadPointVarDataImpl(NcVar *ncVar, vtkDataArray *array);
399 
400  template <typename ValueType>
401  int LoadCellVarDataImpl(NcVar *ncVar, vtkDataArray *array);
402 };
403 
404 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
GeometryType Geometry
abstract base class for most VTK objects
Definition: vtkObject.h:59
Store vtkAlgorithm input/output information.
static vtkUnstructuredGridAlgorithm * New()
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
int * OrigConnections
int vtkIdType
Definition: vtkType.h:287
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:97
dynamic, self-adjusting array of double
double * PointX
bool UseDimensionedArrayNames
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
supports function callbacks
double * PointY
a simple class to control print indentation
Definition: vtkIndent.h:39
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
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
Superclass for algorithms that produce only unstructured grid as output.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Store zero or more vtkInformation instances.
int * MaximumLevelPoint
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkUnstructuredGrid * GetOutput()
Get the output data object for a port on this algorithm.
int * ModConnections
bool ShowMultilayerView