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 "vtk_netcdfcpp_fwd.h" // Forward declarations for vtknetcdfcpp
87 
88 #include <string> // for std::string
89 
90 class vtkCallbackCommand;
92 class vtkDoubleArray;
93 class vtkStdString;
94 class vtkStringArray;
95 
96 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
97 {
98  public:
99  static vtkMPASReader *New();
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
104 
107  vtkSetStringMacro(FileName);
108  vtkGetStringMacro(FileName);
110 
112 
115  vtkGetMacro(MaximumCells, int);
117 
119 
122  vtkGetMacro(MaximumPoints, int);
124 
126 
129  virtual int GetNumberOfCellVars();
130  virtual int GetNumberOfPointVars();
132 
134 
140 
142 
148  vtkSetMacro(UseDimensionedArrayNames, bool)
149  vtkGetMacro(UseDimensionedArrayNames, bool)
150  vtkBooleanMacro(UseDimensionedArrayNames, bool)
152 
154 
159  int GetNumberOfPointArrays();
160  const char* GetPointArrayName(int index);
161  int GetPointArrayStatus(const char* name);
162  void SetPointArrayStatus(const char* name, int status);
163  void DisableAllPointArrays();
164  void EnableAllPointArrays();
166 
167  int GetNumberOfCellArrays();
168  const char* GetCellArrayName(int index);
169  int GetCellArrayStatus(const char* name);
170  void SetCellArrayStatus(const char* name, int status);
171  void DisableAllCellArrays();
172  void EnableAllCellArrays();
173 
175 
183  int GetNumberOfDimensions();
184  std::string GetDimensionName(int idx);
185  vtkStringArray* GetAllDimensions();
186  int GetDimensionCurrentIndex(const std::string &dim);
187  void SetDimensionCurrentIndex(const std::string &dim, int idx);
188  int GetDimensionSize(const std::string &dim);
190 
192 
196  vtkSetMacro(VerticalDimension, std::string)
197  vtkGetMacro(VerticalDimension, std::string)
199 
201 
205  void SetVerticalLevel(int level);
206  int GetVerticalLevel();
208 
209  vtkGetVector2Macro(VerticalLevelRange, int)
210 
211  vtkSetMacro(LayerThickness, int)
212  vtkGetMacro(LayerThickness, int)
213  vtkGetVector2Macro(LayerThicknessRange, int)
214 
215  void SetCenterLon(int val);
216  vtkGetVector2Macro(CenterLonRange, int)
217 
218  vtkSetMacro(ProjectLatLon, bool)
219  vtkGetMacro(ProjectLatLon, bool)
220 
221  vtkSetMacro(IsAtmosphere, bool)
222  vtkGetMacro(IsAtmosphere, bool)
223 
224  vtkSetMacro(IsZeroCentered, bool)
225  vtkGetMacro(IsZeroCentered, bool)
226 
227  vtkSetMacro(ShowMultilayerView, bool)
228  vtkGetMacro(ShowMultilayerView, bool)
229 
230 
233  static int CanReadFile(const char *filename);
234 
235  vtkMTimeType GetMTime() override;
236 
237  protected:
238  vtkMPASReader();
239  ~vtkMPASReader() override;
240  void ReleaseNcData();
241  void DestroyData();
242 
243  char *FileName; // First field part file giving path
244 
245  int NumberOfTimeSteps; // Temporal domain
246  double DTime; // The current time
247 
248  // Observer to modify this object when array selections are modified
250 
252  vtkInformationVector *) override;
254  vtkInformationVector *) override;
255 
256 
257  static void SelectionCallback(vtkObject* caller, unsigned long eid,
258  void* clientdata, void* calldata);
259 
260  // Selected field of interest
263 
268  void UpdateDimensions(bool force = false);
269 
271  int VerticalLevelRange[2];
272 
274  int LayerThicknessRange[2];
275 
277  int CenterLonRange[2];
278 
280  {
283  Planar
284  };
285 
287 
288  bool ProjectLatLon; // User option
289  bool OnASphere; // Data file attribute
293 
295  bool DoBugFix;
296  double CenterRad;
297 
299 
300  // geometry
307  int CurrentExtraPoint; // current extra point
308  int CurrentExtraCell; // current extra cell
309  double* PointX; // x coord of point
310  double* PointY; // y coord of point
311  double* PointZ; // z coord of point
314  int* OrigConnections; // original connections
315  int* ModConnections; // modified connections
316  int* CellMap; // maps from added cell to original cell #
317  int* PointMap; // maps from added point to original point #
319  int MaximumCells; // max cells
320  int MaximumPoints; // max points
321 
322  void SetDefaults();
323  int GetNcDims();
324  int GetNcAtts();
325  int CheckParams();
326  int GetNcVars(const char* cellDimName, const char* pointDimName);
327  int ReadAndOutputGrid();
328  int BuildVarArrays();
329  int AllocSphericalGeometry();
330  int AllocProjectedGeometry();
331  int AllocPlanarGeometry();
332  void ShiftLonData();
333  int AddMirrorPoint(int index, double dividerX, double offset);
334  void FixPoints();
335  int EliminateXWrap();
336  void OutputPoints();
337  void OutputCells();
338  unsigned char GetCellType();
339 
347  bool ValidateDimensions(NcVar *var, bool silent, int ndims, ...);
348 
352  long GetCursorForDimension(const NcDim *dim);
353 
357  size_t GetCountForDimension(const NcDim *dim);
358 
364  long InitializeDimension(const NcDim *dim);
365 
366  vtkDataArray* LoadPointVarData(int variable);
367  vtkDataArray* LoadCellVarData(int variable);
368  vtkDataArray* LookupPointDataArray(int varIdx);
369  vtkDataArray* LookupCellDataArray(int varIdx);
370 
379  void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
380 
381  private:
382  vtkMPASReader(const vtkMPASReader&) = delete;
383  void operator=(const vtkMPASReader&) = delete;
384 
385  class Internal;
386  Internal *Internals;
387 
388  static int NcTypeToVtkType(int ncType);
389 
390  vtkDataArray* CreateDataArray(int ncType);
391  vtkIdType ComputeNumberOfTuples(NcVar *ncVar);
392 
393  template <typename ValueType>
394  bool LoadDataArray(NcVar *ncVar, vtkDataArray *array, bool resize = true);
395 
396  template <typename ValueType>
397  int LoadPointVarDataImpl(NcVar *ncVar, vtkDataArray *array);
398 
399  template <typename ValueType>
400  int LoadCellVarDataImpl(NcVar *ncVar, vtkDataArray *array);
401 };
402 
403 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
GeometryType Geometry
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
abstract base class for most VTK objects
Definition: vtkObject.h:59
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
static vtkUnstructuredGridAlgorithm * New()
double * PointZ
a vtkAbstractArray subclass for strings
bool IncludeTopography
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
int * OrigConnections
int vtkIdType
Definition: vtkType.h:345
vtkDataArraySelection * PointDataArraySelection
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:96
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
virtual vtkMTimeType GetMTime()
Return this object&#39;s modified time.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
Superclass for algorithms that produce only unstructured grid as output.
std::string VerticalDimension
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkCallbackCommand * SelectionObserver
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
vtkDataArraySelection * CellDataArraySelection
bool ShowMultilayerView