File: vtkNetCDFCAMReader.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (171 lines) | stat: -rw-r--r-- 5,714 bytes parent folder | download | duplicates (7)
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
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkNetCDFCAMReader
 * @brief   Read unstructured NetCDF CAM files.
 *
 * Reads in a NetCDF CAM (Community Atmospheric Model) file and
 * produces and unstructured grid.  The grid is actually unstructured
 * in the X and Y directions and rectilinear in the Z direction. If we
 * read one layer we produce quad cells otherwise we produce hex
 * cells.  The reader requires 2 NetCDF files: the main file has all
 * attributes, the connectivity file has point positions and cell
 * connectivity information.
 */

#ifndef vtkNetCDFCAMReader_h
#define vtkNetCDFCAMReader_h

#include "vtkIONetCDFModule.h" // For export macro
#include "vtkUnstructuredGridAlgorithm.h"

VTK_ABI_NAMESPACE_BEGIN
class vtkCallbackCommand;
class vtkDataArraySelection;

class VTKIONETCDF_EXPORT vtkNetCDFCAMReader : public vtkUnstructuredGridAlgorithm
{
public:
  static vtkNetCDFCAMReader* New();
  vtkTypeMacro(vtkNetCDFCAMReader, vtkUnstructuredGridAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /**
   * Returns 1 if this file can be read and 0 if the file cannot be read.
   * Because NetCDF CAM files come in pairs and we only check one of the
   * files, the result is not definitive.  Invalid files may still return 1
   * although a valid file will never return 0.
   */
  static int CanReadFile(VTK_FILEPATH const char* fileName);

  void SetFileName(VTK_FILEPATH const char* fileName);
  vtkGetFilePathMacro(FileName);

  void SetConnectivityFileName(VTK_FILEPATH const char* fileName);
  vtkGetFilePathMacro(ConnectivityFileName);

  ///@{
  /**
   * Set whether to read a single layer, midpoint layers or interface layers.
   * VERTICAL_DIMENSION_SINGLE_LAYER (0) indicates that only a single
   * layer will be read in. The NetCDF variables loaded will be the
   * ones with dimensions (time, ncol).
   * VERTICAL_DIMENSION_MIDPOINT_LAYERS (1) indicates that variables defined
   * on midpoint layers will be read in. These are variables with dimensions
   * (time, lev, ncol).
   * VERTICAL_DIMENSION_INTERFACE_LAYERS (2) indicates that variables
   * defined on interface layers will be read in. These are variables with
   * dimensions (time, ilev, ncol).
   */
  enum VerticalDimension
  {
    VERTICAL_DIMENSION_SINGLE_LAYER,
    VERTICAL_DIMENSION_MIDPOINT_LAYERS,
    VERTICAL_DIMENSION_INTERFACE_LAYERS,
    VERTICAL_DIMENSION_COUNT
  };
  vtkSetClampMacro(VerticalDimension, int, 0, 2);
  vtkGetMacro(VerticalDimension, int);
  ///@}

  ///@{
  /**
   * If SingleXXXLayer is 1, we'll load only the layer specified by
   * XXXLayerIndex.  Otherwise, we load all layers. We do that for
   * midpoint layer variables ( which have dimension 'lev') or for
   * interface layer variables (which have dimension 'ilev').
   */
  vtkBooleanMacro(SingleMidpointLayer, vtkTypeBool);
  vtkSetMacro(SingleMidpointLayer, vtkTypeBool);
  vtkGetMacro(SingleMidpointLayer, vtkTypeBool);
  vtkSetMacro(MidpointLayerIndex, int);
  vtkGetMacro(MidpointLayerIndex, int);
  vtkGetVector2Macro(MidpointLayersRange, int);

  vtkBooleanMacro(SingleInterfaceLayer, vtkTypeBool);
  vtkSetMacro(SingleInterfaceLayer, vtkTypeBool);
  vtkGetMacro(SingleInterfaceLayer, vtkTypeBool);
  vtkSetMacro(InterfaceLayerIndex, int);
  vtkGetMacro(InterfaceLayerIndex, int);
  vtkGetVector2Macro(InterfaceLayersRange, int);
  ///@}

  ///@{
  /**
   * The following methods allow selective reading of variables.
   * By default, ALL data variables on the nodes are read.
   */
  int GetNumberOfPointArrays();
  const char* GetPointArrayName(int index);
  int GetPointArrayStatus(const char* name);
  void SetPointArrayStatus(const char* name, int status);
  void DisableAllPointArrays();
  void EnableAllPointArrays();
  ///@}

protected:
  vtkNetCDFCAMReader();
  ~vtkNetCDFCAMReader() override;

  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  /**
   * Returns true for success.  Based on the piece, number of pieces,
   * number of levels of cells, and the number of cells per level, gives
   * a partitioned space of levels and cells.
   */
  bool GetPartitioning(size_t piece, size_t numPieces, size_t numCellLevels,
    size_t numCellsPerLevel, size_t& beginCellLevel, size_t& endCellLevel, size_t& beginCell,
    size_t& endCell);

  void BuildVarArray();
  static void SelectionCallback(
    vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);

private:
  vtkNetCDFCAMReader(const vtkNetCDFCAMReader&) = delete;
  void operator=(const vtkNetCDFCAMReader&) = delete;

  ///@{
  /**
   * The file name of the file that contains all of the point
   * data (coordinates and fields).
   */
  char* FileName;
  char* CurrentFileName;
  vtkSetStringMacro(CurrentFileName);
  ///@}

  ///@{
  /**
   * The file name that contains the cell connectivity information.
   */
  char* ConnectivityFileName;
  char* CurrentConnectivityFileName;
  vtkSetStringMacro(CurrentConnectivityFileName);
  ///@}

  int VerticalDimension;
  double* TimeSteps;
  size_t NumberOfTimeSteps;
  vtkDataArraySelection* PointDataArraySelection;
  vtkCallbackCommand* SelectionObserver;

  vtkTypeBool SingleMidpointLayer;
  int MidpointLayerIndex;
  int MidpointLayersRange[2];

  vtkTypeBool SingleInterfaceLayer;
  int InterfaceLayerIndex;
  int InterfaceLayersRange[2];

  class Internal;
  Internal* Internals;
};

VTK_ABI_NAMESPACE_END
#endif