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:
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 **,
254  int RequestInformation(vtkInformation *, 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);
333  void ShiftLonData();
334  int AddMirrorPoint(int index, double dividerX, double offset);
335  void FixPoints();
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 
371 
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
vtkMPASReader::DoBugFix
bool DoBugFix
Definition: vtkMPASReader.h:296
vtkMPASReader::MaximumPoints
int MaximumPoints
Definition: vtkMPASReader.h:321
vtkMPASReader::New
static vtkMPASReader * New()
vtkMPASReader::LookupPointDataArray
vtkDataArray * LookupPointDataArray(int varIdx)
vtkMPASReader::ModNumPoints
int ModNumPoints
Definition: vtkMPASReader.h:313
vtkMPASReader::EliminateXWrap
int EliminateXWrap()
vtkMPASReader::IsAtmosphere
bool IsAtmosphere
Definition: vtkMPASReader.h:291
vtkMPASReader::CenterRad
double CenterRad
Definition: vtkMPASReader.h:297
vtkMPASReader::CurrentExtraPoint
int CurrentExtraPoint
Definition: vtkMPASReader.h:308
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkMPASReader::MaximumNVertLevels
int MaximumNVertLevels
Definition: vtkMPASReader.h:302
vtkMPASReader::OutputCells
void OutputCells()
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:42
vtkMPASReader::ModConnections
int * ModConnections
Definition: vtkMPASReader.h:316
vtkMPASReader::GetNumberOfPointVars
virtual int GetNumberOfPointVars()
vtkMPASReader::PointY
double * PointY
Definition: vtkMPASReader.h:311
vtkMPASReader::AllocProjectedGeometry
int AllocProjectedGeometry()
vtkMPASReader::OutputPoints
void OutputPoints()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkMPASReader::NumberOfPoints
int NumberOfPoints
Definition: vtkMPASReader.h:304
vtkMPASReader::NumberOfCells
int NumberOfCells
Definition: vtkMPASReader.h:303
vtkMPASReader::OnASphere
bool OnASphere
Definition: vtkMPASReader.h:290
vtkMPASReader::GetNumberOfCellVars
virtual int GetNumberOfCellVars()
Get the number of data variables at the cell centers and points.
vtkMPASReader::SetDefaults
void SetDefaults()
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkMPASReader::CurrentExtraCell
int CurrentExtraCell
Definition: vtkMPASReader.h:309
vtkMPASReader::LoadPointVarData
vtkDataArray * LoadPointVarData(int variable)
vtkMPASReader::ReadAndOutputGrid
int ReadAndOutputGrid()
vtkMPASReader::MaximumLevelPoint
int * MaximumLevelPoint
Definition: vtkMPASReader.h:319
vtkMPASReader::LookupCellDataArray
vtkDataArray * LookupCellDataArray(int varIdx)
vtkMPASReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkMPASReader::AddMirrorPoint
int AddMirrorPoint(int index, double dividerX, double offset)
vtkMPASReader::UseDimensionedArrayNames
bool UseDimensionedArrayNames
Definition: vtkMPASReader.h:299
vtkMPASReader::Spherical
@ Spherical
Definition: vtkMPASReader.h:282
vtkDataArraySelection
Store on/off settings for data arrays for a vtkSource.
Definition: vtkDataArraySelection.h:35
vtkMPASReader::CellOffset
int CellOffset
Definition: vtkMPASReader.h:305
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkMPASReader::IncludeTopography
bool IncludeTopography
Definition: vtkMPASReader.h:295
vtkMPASReader::OrigConnections
int * OrigConnections
Definition: vtkMPASReader.h:315
vtkX3D::level
@ level
Definition: vtkX3D.h:395
vtkMPASReader::GetNcAtts
int GetNcAtts()
vtkMPASReader
Read an MPAS netCDF file.
Definition: vtkMPASReader.h:98
vtkMPASReader::LoadTimeFieldData
void LoadTimeFieldData(vtkUnstructuredGrid *dataset)
Update the "Time" vtkStringArray in dataset's FieldData to contain the xtime string for the current t...
vtkMPASReader::LoadCellVarData
vtkDataArray * LoadCellVarData(int variable)
vtkX3D::offset
@ offset
Definition: vtkX3D.h:438
vtkMPASReader::PointOffset
int PointOffset
Definition: vtkMPASReader.h:306
vtkMPASReader::PointX
double * PointX
Definition: vtkMPASReader.h:310
vtkMPASReader::PointZ
double * PointZ
Definition: vtkMPASReader.h:312
vtkMPASReader::InitializeDimension
long InitializeDimension(const NcDim *dim)
For an arbitrary (i.e.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMPASReader::AllocPlanarGeometry
int AllocPlanarGeometry()
vtkMPASReader::ValidateDimensions
bool ValidateDimensions(NcVar *var, bool silent, int ndims,...)
Returns true if the dimensions in var match the expected args, or prints a warning and returns false ...
vtkMPASReader::AllocSphericalGeometry
int AllocSphericalGeometry()
vtkMPASReader::PointsPerCell
int PointsPerCell
Definition: vtkMPASReader.h:307
vtkMPASReader::CellMap
int * CellMap
Definition: vtkMPASReader.h:317
vtkMPASReader::MaximumCells
int MaximumCells
Definition: vtkMPASReader.h:320
vtkGetStringMacro
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkMPASReader::GetNcDims
int GetNcDims()
vtkMPASReader::ModNumCells
int ModNumCells
Definition: vtkMPASReader.h:314
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkMPASReader::ShiftLonData
void ShiftLonData()
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:87
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkMPASReader::GetCountForDimension
size_t GetCountForDimension(const NcDim *dim)
Return the number of values to read for the specified dimension.
vtkMPASReader::GeometryType
GeometryType
Definition: vtkMPASReader.h:281
vtkMPASReader::GetCursorForDimension
long GetCursorForDimension(const NcDim *dim)
Return the cursor position for the specified dimension.
vtkMPASReader::GetOutput
vtkUnstructuredGrid * GetOutput(int index)
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:51
vtkMPASReader::GetCellType
unsigned char GetCellType()
vtkUnstructuredGridAlgorithm.h
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:43
vtkMPASReader::GetOutput
vtkUnstructuredGrid * GetOutput()
Get the reader's output.
vtkUnstructuredGridAlgorithm
Superclass for algorithms that produce only unstructured grid as output.
Definition: vtkUnstructuredGridAlgorithm.h:41
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:42
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:83
vtkMPASReader::CheckParams
int CheckParams()
vtkMPASReader::ShowMultilayerView
bool ShowMultilayerView
Definition: vtkMPASReader.h:293
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkMPASReader::GetNcVars
int GetNcVars(const char *cellDimName, const char *pointDimName)
vtkMPASReader::BuildVarArrays
int BuildVarArrays()
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkMPASReader::Projected
@ Projected
Definition: vtkMPASReader.h:283
vtkMPASReader::FixPoints
void FixPoints()
vtkMPASReader::ProjectLatLon
bool ProjectLatLon
Definition: vtkMPASReader.h:289
vtkMPASReader::IsZeroCentered
bool IsZeroCentered
Definition: vtkMPASReader.h:292
vtkMPASReader::Geometry
GeometryType Geometry
Definition: vtkMPASReader.h:287
vtkMPASReader::PointMap
int * PointMap
Definition: vtkMPASReader.h:318