/usr/include/vtk-7.1/vtkMPASReader.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkMPASReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*=========================================================================
Copyright (c) 2002-2005 Los Alamos National Laboratory
This software and ancillary information known as vtk_ext (and herein
called "SOFTWARE") is made available under the terms described below.
The SOFTWARE has been approved for release with associated LA_CC
Number 99-44, granted by Los Alamos National Laboratory in July 1999.
Unless otherwise indicated, this SOFTWARE has been authored by an
employee or employees of the University of California, operator of the
Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
the United States Department of Energy.
The United States Government has rights to use, reproduce, and
distribute this SOFTWARE. The public may copy, distribute, prepare
derivative works and publicly display this SOFTWARE without charge,
provided that this Notice and any statement of authorship are
reproduced on all copies.
Neither the U. S. Government, the University of California, nor the
Advanced Computing Laboratory makes any warranty, either express or
implied, nor assumes any liability or responsibility for the use of
this SOFTWARE.
If SOFTWARE is modified to produce derivative works, such modified
SOFTWARE should be clearly marked, so as not to confuse it with the
version available from Los Alamos National Laboratory.
=========================================================================*/
/**
* @class vtkMPASReader
* @brief Read an MPAS netCDF file
*
* This program reads an MPAS netCDF data file to allow paraview to
* display a dual-grid sphere or latlon projection. Also allows
* display of primal-grid sphere.
* The variables that have time dim are available to ParaView.
*
* Assume all variables are of interest if they have dims
* (Time, nCells|nVertices, nVertLevels, [nTracers]).
* Does not deal with edge data.
*
* When using this reader, it is important that you remember to do the
*following:
* 1. When changing a selected variable, remember to select it also
* in the drop down box to "color by". It doesn't color by that variable
* automatically.
* 2. When selecting multilayer sphere view, make layer thickness around
* 100,000.
* 3. When selecting multilayer lat/lon view, make layer thickness around 10.
* 4. Always click the -Z orientation after making a switch from lat/lon to
* sphere, from single to multilayer or changing thickness.
* 5. Be conservative on the number of changes you make before hitting Apply,
* since there may be bugs in this reader. Just make one change and then
* hit Apply.
*
*
* Christine Ahrens (cahrens@lanl.gov)
* Version 1.3
*/
#ifndef vtkMPASReader_h
#define vtkMPASReader_h
#include "vtkIONetCDFModule.h" // For export macro
#include "vtkUnstructuredGridAlgorithm.h"
#include <string> // for std::string
class vtkCallbackCommand;
class vtkDataArraySelection;
class vtkDoubleArray;
class vtkStdString;
class vtkStringArray;
class NcVar;
class NcDim;
class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
{
public:
static vtkMPASReader *New();
vtkTypeMacro(vtkMPASReader,vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Specify file name of MPAS data file to read.
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
//@{
/**
* Get the number of data cells
*/
vtkGetMacro(MaximumCells, int);
//@}
//@{
/**
* Get the number of points
*/
vtkGetMacro(MaximumPoints, int);
//@}
//@{
/**
* Get the number of data variables at the cell centers and points
*/
virtual int GetNumberOfCellVars();
virtual int GetNumberOfPointVars();
//@}
//@{
/**
* Get the reader's output
*/
vtkUnstructuredGrid *GetOutput();
vtkUnstructuredGrid *GetOutput(int index);
//@}
//@{
/**
* If true, dimension info is included in the array name. For instance,
* "tracers" will become "tracers(Time, nCells, nVertLevels, nTracers)".
* This is useful for user-visible array selection, but is disabled by default
* for backwards compatibility.
*/
vtkSetMacro(UseDimensionedArrayNames, bool)
vtkGetMacro(UseDimensionedArrayNames, bool)
vtkBooleanMacro(UseDimensionedArrayNames, bool)
//@}
//@{
/**
* The following methods allow selective reading of solutions fields.
* By default, ALL data fields on the nodes are read, but this can
* be modified.
*/
int GetNumberOfPointArrays();
const char* GetPointArrayName(int index);
int GetPointArrayStatus(const char* name);
void SetPointArrayStatus(const char* name, int status);
void DisableAllPointArrays();
void EnableAllPointArrays();
//@}
int GetNumberOfCellArrays();
const char* GetCellArrayName(int index);
int GetCellArrayStatus(const char* name);
void SetCellArrayStatus(const char* name, int status);
void DisableAllCellArrays();
void EnableAllCellArrays();
//@{
/**
* If the point/cell arrays contain dimensions other than Time, nCells, or
* nVertices, they are configured here. Use GetNumberOfDimensions to get the
* number of arbitrary dimensions in the loaded arrays and GetDimensionName to
* retrieve the dimension names. GetDimensionSize returns the number of values
* in the dimensions, and Set/GetDimensionCurrentIndex controls the value
* to fix a given dimension at when extracting slices of data.
*/
int GetNumberOfDimensions();
std::string GetDimensionName(int idx);
vtkStringArray* GetAllDimensions();
int GetDimensionCurrentIndex(const std::string &dim);
void SetDimensionCurrentIndex(const std::string &dim, int idx);
int GetDimensionSize(const std::string &dim);
//@}
//@{
/**
* Get/Set the name to the dimension that identifies the vertical dimension.
* Defaults to "nVertLevels".
*/
vtkSetMacro(VerticalDimension, std::string)
vtkGetMacro(VerticalDimension, std::string)
//@}
//@{
/**
* Convenience functon for setting/querying [GS]etDimensionCurrentIndex
* for the dimension returned by GetVerticalDimension.
*/
void SetVerticalLevel(int level);
int GetVerticalLevel();
//@}
vtkGetVector2Macro(VerticalLevelRange, int)
vtkSetMacro(LayerThickness, int)
vtkGetMacro(LayerThickness, int)
vtkGetVector2Macro(LayerThicknessRange, int)
void SetCenterLon(int val);
vtkGetVector2Macro(CenterLonRange, int)
vtkSetMacro(ProjectLatLon, bool)
vtkGetMacro(ProjectLatLon, bool)
vtkSetMacro(IsAtmosphere, bool)
vtkGetMacro(IsAtmosphere, bool)
vtkSetMacro(IsZeroCentered, bool)
vtkGetMacro(IsZeroCentered, bool)
vtkSetMacro(ShowMultilayerView, bool)
vtkGetMacro(ShowMultilayerView, bool)
/**
* Returns true if the given file can be read.
*/
static int CanReadFile(const char *filename);
vtkMTimeType GetMTime();
protected:
vtkMPASReader();
~vtkMPASReader();
void ReleaseNcData();
void DestroyData();
char *FileName; // First field part file giving path
int NumberOfTimeSteps; // Temporal domain
double DTime; // The current time
// Observer to modify this object when array selections are modified
vtkCallbackCommand* SelectionObserver;
int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
int RequestInformation(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
static void SelectionCallback(vtkObject* caller, unsigned long eid,
void* clientdata, void* calldata);
// Selected field of interest
vtkDataArraySelection* PointDataArraySelection;
vtkDataArraySelection* CellDataArraySelection;
/**
* Update the list of available dimensions. Only does work when
* PointDataArraySelection or CellDataArraySelection is changed.
*/
void UpdateDimensions(bool force = false);
std::string VerticalDimension;
int VerticalLevelRange[2];
int LayerThickness;
int LayerThicknessRange[2];
int CenterLon;
int CenterLonRange[2];
enum GeometryType
{
Spherical,
Projected,
Planar
};
GeometryType Geometry;
bool ProjectLatLon; // User option
bool OnASphere; // Data file attribute
bool IsAtmosphere;
bool IsZeroCentered;
bool ShowMultilayerView;
bool IncludeTopography;
bool DoBugFix;
double CenterRad;
bool UseDimensionedArrayNames;
// geometry
int MaximumNVertLevels;
int NumberOfCells;
int NumberOfPoints;
int CellOffset;
int PointOffset;
int PointsPerCell;
int CurrentExtraPoint; // current extra point
int CurrentExtraCell; // current extra cell
double* PointX; // x coord of point
double* PointY; // y coord of point
double* PointZ; // z coord of point
int ModNumPoints;
int ModNumCells;
int* OrigConnections; // original connections
int* ModConnections; // modified connections
int* CellMap; // maps from added cell to original cell #
int* PointMap; // maps from added point to original point #
int* MaximumLevelPoint; //
int MaximumCells; // max cells
int MaximumPoints; // max points
void SetDefaults();
int GetNcDims();
int GetNcAtts();
int CheckParams();
int GetNcVars(const char* cellDimName, const char* pointDimName);
int ReadAndOutputGrid();
int BuildVarArrays();
int AllocSphericalGeometry();
int AllocProjectedGeometry();
int AllocPlanarGeometry();
void ShiftLonData();
int AddMirrorPoint(int index, double dividerX, double offset);
void FixPoints();
int EliminateXWrap();
void OutputPoints();
void OutputCells();
unsigned char GetCellType();
/**
* Returns true if the dimensions in var match the expected args, or prints a
* warning and returns false if any are incorrect.
* ndims is the number of dimensions, and the variatic args must be
* C-strings identifying the expected dimensions.
* If silent is true, no warnings are printed.
*/
bool ValidateDimensions(NcVar *var, bool silent, int ndims, ...);
/**
* Return the cursor position for the specified dimension.
*/
long GetCursorForDimension(const NcDim *dim);
/**
* Return the number of values to read for the specified dimension.
*/
size_t GetCountForDimension(const NcDim *dim);
/**
* For an arbitrary (i.e. not nCells, nVertices, or Time) dimension, extract
* the dimension's metadata into memory (if needed) and return the last used
* index into the dimension values, or 0 if the dimension is new.
*/
long InitializeDimension(const NcDim *dim);
vtkDataArray* LoadPointVarData(int variable);
vtkDataArray* LoadCellVarData(int variable);
vtkDataArray* LookupPointDataArray(int varIdx);
vtkDataArray* LookupCellDataArray(int varIdx);
/**
* Update the "Time" vtkStringArray in dataset's FieldData to contain the
* xtime string for the current timestep.
* If there is an error getting xtime, the current timestep number is inserted
* instead.
* If a non-string array named Time already exists in the FieldData, dataset
* is not modified in any way.
*/
void LoadTimeFieldData(vtkUnstructuredGrid *dataset);
private:
vtkMPASReader(const vtkMPASReader&) VTK_DELETE_FUNCTION;
void operator=(const vtkMPASReader&) VTK_DELETE_FUNCTION;
class Internal;
Internal *Internals;
static int NcTypeToVtkType(int ncType);
vtkDataArray* CreateDataArray(int ncType);
vtkIdType ComputeNumberOfTuples(NcVar *ncVar);
template <typename ValueType>
bool LoadDataArray(NcVar *ncVar, vtkDataArray *array, bool resize = true);
template <typename ValueType>
int LoadPointVarDataImpl(NcVar *ncVar, vtkDataArray *array);
template <typename ValueType>
int LoadCellVarDataImpl(NcVar *ncVar, vtkDataArray *array);
};
#endif
|