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 #include "vtkIONetCDFModule.h" // For export macro
82 
83 #include "vtk_netcdfcpp_fwd.h" // Forward declarations for vtknetcdfcpp
84 
85 #include <string> // for std::string
86 
87 class vtkCallbackCommand;
89 class vtkDoubleArray;
90 class vtkStdString;
91 class vtkStringArray;
92 
93 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
94 {
95  public:
96  static vtkMPASReader *New();
98  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
99 
101 
104  vtkSetStringMacro(FileName);
105  vtkGetStringMacro(FileName);
107 
109 
112  vtkGetMacro(MaximumCells, int);
114 
116 
119  vtkGetMacro(MaximumPoints, int);
121 
123 
126  virtual int GetNumberOfCellVars();
127  virtual int GetNumberOfPointVars();
129 
131 
137 
139 
145  vtkSetMacro(UseDimensionedArrayNames, bool)
146  vtkGetMacro(UseDimensionedArrayNames, bool)
147  vtkBooleanMacro(UseDimensionedArrayNames, bool)
149 
151 
156  int GetNumberOfPointArrays();
157  const char* GetPointArrayName(int index);
158  int GetPointArrayStatus(const char* name);
159  void SetPointArrayStatus(const char* name, int status);
160  void DisableAllPointArrays();
161  void EnableAllPointArrays();
163 
164  int GetNumberOfCellArrays();
165  const char* GetCellArrayName(int index);
166  int GetCellArrayStatus(const char* name);
167  void SetCellArrayStatus(const char* name, int status);
168  void DisableAllCellArrays();
169  void EnableAllCellArrays();
170 
172 
180  int GetNumberOfDimensions();
181  std::string GetDimensionName(int idx);
182  vtkStringArray* GetAllDimensions();
183  int GetDimensionCurrentIndex(const std::string &dim);
184  void SetDimensionCurrentIndex(const std::string &dim, int idx);
185  int GetDimensionSize(const std::string &dim);
187 
189 
193  vtkSetMacro(VerticalDimension, std::string)
194  vtkGetMacro(VerticalDimension, std::string)
196 
198 
202  void SetVerticalLevel(int level);
203  int GetVerticalLevel();
205 
206  vtkGetVector2Macro(VerticalLevelRange, int)
207 
208  vtkSetMacro(LayerThickness, int)
209  vtkGetMacro(LayerThickness, int)
210  vtkGetVector2Macro(LayerThicknessRange, int)
211 
212  void SetCenterLon(int val);
213  vtkGetVector2Macro(CenterLonRange, int)
214 
215  vtkSetMacro(ProjectLatLon, bool)
216  vtkGetMacro(ProjectLatLon, bool)
217 
218  vtkSetMacro(IsAtmosphere, bool)
219  vtkGetMacro(IsAtmosphere, bool)
220 
221  vtkSetMacro(IsZeroCentered, bool)
222  vtkGetMacro(IsZeroCentered, bool)
223 
224  vtkSetMacro(ShowMultilayerView, bool)
225  vtkGetMacro(ShowMultilayerView, bool)
226 
230  static int CanReadFile(const char *filename);
231 
232  vtkMTimeType GetMTime() VTK_OVERRIDE;
233 
234  protected:
235  vtkMPASReader();
236  ~vtkMPASReader() VTK_OVERRIDE;
237  void ReleaseNcData();
238  void DestroyData();
239 
240  char *FileName; // First field part file giving path
241 
242  int NumberOfTimeSteps; // Temporal domain
243  double DTime; // The current time
244 
245  // Observer to modify this object when array selections are modified
246  vtkCallbackCommand* SelectionObserver;
247 
248  int RequestData(vtkInformation *, vtkInformationVector **,
249  vtkInformationVector *) VTK_OVERRIDE;
250  int RequestInformation(vtkInformation *, vtkInformationVector **,
251  vtkInformationVector *) VTK_OVERRIDE;
252 
253 
254  static void SelectionCallback(vtkObject* caller, unsigned long eid,
255  void* clientdata, void* calldata);
256 
257  // Selected field of interest
258  vtkDataArraySelection* PointDataArraySelection;
259  vtkDataArraySelection* CellDataArraySelection;
260 
265  void UpdateDimensions(bool force = false);
266 
267  std::string VerticalDimension;
268  int VerticalLevelRange[2];
269 
270  int LayerThickness;
271  int LayerThicknessRange[2];
272 
273  int CenterLon;
274  int CenterLonRange[2];
275 
277  {
280  Planar
281  };
282 
284 
285  bool ProjectLatLon; // User option
286  bool OnASphere; // Data file attribute
290 
292  bool DoBugFix;
293  double CenterRad;
294 
296 
297  // geometry
304  int CurrentExtraPoint; // current extra point
305  int CurrentExtraCell; // current extra cell
306  double* PointX; // x coord of point
307  double* PointY; // y coord of point
308  double* PointZ; // z coord of point
311  int* OrigConnections; // original connections
312  int* ModConnections; // modified connections
313  int* CellMap; // maps from added cell to original cell #
314  int* PointMap; // maps from added point to original point #
316  int MaximumCells; // max cells
317  int MaximumPoints; // max points
318 
319  void SetDefaults();
320  int GetNcDims();
321  int GetNcAtts();
322  int CheckParams();
323  int GetNcVars(const char* cellDimName, const char* pointDimName);
324  int ReadAndOutputGrid();
325  int BuildVarArrays();
326  int AllocSphericalGeometry();
327  int AllocProjectedGeometry();
328  int AllocPlanarGeometry();
329  void ShiftLonData();
330  int AddMirrorPoint(int index, double dividerX, double offset);
331  void FixPoints();
332  int EliminateXWrap();
333  void OutputPoints();
334  void OutputCells();
335  unsigned char GetCellType();
336 
344  bool ValidateDimensions(NcVar *var, bool silent, int ndims, ...);
345 
349  long GetCursorForDimension(const NcDim *dim);
350 
354  size_t GetCountForDimension(const NcDim *dim);
355 
361  long InitializeDimension(const NcDim *dim);
362 
363  vtkDataArray* LoadPointVarData(int variable);
364  vtkDataArray* LoadCellVarData(int variable);
365  vtkDataArray* LookupPointDataArray(int varIdx);
366  vtkDataArray* LookupCellDataArray(int varIdx);
367 
376  void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
377 
378  private:
379  vtkMPASReader(const vtkMPASReader&) VTK_DELETE_FUNCTION;
380  void operator=(const vtkMPASReader&) VTK_DELETE_FUNCTION;
381 
382  class Internal;
383  Internal *Internals;
384 
385  static int NcTypeToVtkType(int ncType);
386 
387  vtkDataArray* CreateDataArray(int ncType);
388  vtkIdType ComputeNumberOfTuples(NcVar *ncVar);
389 
390  template <typename ValueType>
391  bool LoadDataArray(NcVar *ncVar, vtkDataArray *array, bool resize = true);
392 
393  template <typename ValueType>
394  int LoadPointVarDataImpl(NcVar *ncVar, vtkDataArray *array);
395 
396  template <typename ValueType>
397  int LoadCellVarDataImpl(NcVar *ncVar, vtkDataArray *array);
398 };
399 
400 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
GeometryType Geometry
abstract base class for most VTK objects
Definition: vtkObject.h:53
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
static vtkUnstructuredGridAlgorithm * New()
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
int * OrigConnections
int vtkIdType
Definition: vtkType.h:345
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:93
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:33
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:48
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