VTK  9.7.1
vtkNetCDFUGRIDReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkNetCDFUGRIDReader_h
5 #define vtkNetCDFUGRIDReader_h
6 
7 #include "vtkDataArraySelection.h" // For vtkSmartPointer downcast
8 #include "vtkIONetCDFModule.h" // For export macro
9 #include "vtkSmartPointer.h" // For vtkSmartPointer
11 
12 #include <cstdlib> // For std::size_t
13 #include <vector> // For std::vector
14 
15 VTK_ABI_NAMESPACE_BEGIN
16 
30 class VTKIONETCDF_EXPORT vtkNetCDFUGRIDReader : public vtkUnstructuredGridAlgorithm
31 {
32 public:
33  static vtkNetCDFUGRIDReader* New();
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
38 
41  vtkSetFilePathMacro(FileName);
42  vtkGetFilePathMacro(FileName);
44 
46 
50  vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
51  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
53 
55 
58  int GetNumberOfPointArrays();
59  int GetNumberOfCellArrays();
61 
63 
66  const char* GetPointArrayName(int index);
67  const char* GetCellArrayName(int index);
69 
71 
74  int GetPointArrayStatus(const char* name);
75  int GetCellArrayStatus(const char* name);
76  void SetPointArrayStatus(const char* name, int status);
77  void SetCellArrayStatus(const char* name, int status);
79 
81 
90  vtkGetMacro(ReplaceFillValueWithNan, bool);
91  vtkSetMacro(ReplaceFillValueWithNan, bool);
92  vtkBooleanMacro(ReplaceFillValueWithNan, bool);
94 
95 protected:
97  ~vtkNetCDFUGRIDReader() override;
98 
102  vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) override;
103 
104  bool Open();
105  bool ParseHeader();
106  bool FillArraySelection(const std::vector<int>& ids, vtkDataArraySelection* selection);
107  bool FillPoints(vtkUnstructuredGrid* output);
108  bool FillCells(vtkUnstructuredGrid* output);
109  bool FillArrays(vtkUnstructuredGrid* output, std::size_t timeStep);
110  void Close();
111 
112  bool CheckError(int error);
113  std::string GetAttributeString(int var, std::string name);
114  std::string GetVariableName(int var);
115  std::string GetAttributeName(int var, int att);
116  std::string GetDimensionName(int dim);
117  vtkSmartPointer<vtkDataArray> GetArrayData(int var, std::size_t time, std::size_t size);
118 
119 private:
120  char* FileName = nullptr;
121 
122  int NcId = -1;
123  int MeshVarId = -1;
124  int FaceVarId = -1;
125  int FaceFillValue = -1;
126  int FaceStartIndex = 0;
127  int NodeXVarId = -1;
128  int NodeYVarId = -1;
129  int NodeType = -1;
130  std::size_t NodeCount = 0;
131  std::size_t FaceCount = 0;
132  std::size_t NodesPerFace = 0;
133  std::size_t FaceStride = 0;
134  std::size_t NodesPerFaceStride = 0;
135  bool ReplaceFillValueWithNan = false;
136  std::vector<int> NodeArrayVarIds; // data variables linked to nodes (points)
137  std::vector<int> FaceArrayVarIds; // data variables linked to face (cells)
138  std::vector<double> TimeSteps;
139 
140  vtkSmartPointer<vtkDataArraySelection> PointDataArraySelection;
141  vtkSmartPointer<vtkDataArraySelection> CellDataArraySelection;
142 
144  void operator=(const vtkNetCDFUGRIDReader&) = delete;
145 };
146 
147 VTK_ABI_NAMESPACE_END
148 
149 #endif
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
Store vtkAlgorithm input/output information.
static vtkUnstructuredGridAlgorithm * New()
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
Store on/off settings for data arrays, etc.
dataset represents arbitrary combinations of all possible cell types
Superclass for algorithms that produce only unstructured grid as output.
Read unstructured NetCDF UGRID files.
VTKIOHDF_EXPORT bool Open(const char *fileName, hid_t &fileID)
Open a VTK HDF file and checks if it is valid.
Store zero or more vtkInformation instances.
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.