VTK  9.0.1
vtkNetCDFCFReader.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 /*=========================================================================
3 
4  Program: Visualization Toolkit
5  Module: vtkNetCDFCFReader.h
6 
7  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8  All rights reserved.
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 
15 =========================================================================*/
16 
17 /*-------------------------------------------------------------------------
18  Copyright 2008 Sandia Corporation.
19  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
20  the U.S. Government retains certain rights in this software.
21 -------------------------------------------------------------------------*/
22 
33 #ifndef vtkNetCDFCFReader_h
34 #define vtkNetCDFCFReader_h
35 
36 #include "vtkIONetCDFModule.h" // For export macro
37 #include "vtkNetCDFReader.h"
38 
39 #include "vtkStdString.h" // Used for ivars.
40 
41 class vtkImageData;
42 class vtkPoints;
43 class vtkRectilinearGrid;
44 class vtkStructuredGrid;
46 
47 class VTKIONETCDF_EXPORT vtkNetCDFCFReader : public vtkNetCDFReader
48 {
49 public:
51  static vtkNetCDFCFReader* New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
55 
60  vtkGetMacro(SphericalCoordinates, vtkTypeBool);
61  vtkSetMacro(SphericalCoordinates, vtkTypeBool);
62  vtkBooleanMacro(SphericalCoordinates, vtkTypeBool);
64 
66 
77  vtkGetMacro(VerticalScale, double);
78  vtkSetMacro(VerticalScale, double);
79  vtkGetMacro(VerticalBias, double);
80  vtkSetMacro(VerticalBias, double);
82 
84 
91  vtkGetMacro(OutputType, int);
92  virtual void SetOutputType(int type);
93  void SetOutputTypeToAutomatic() { this->SetOutputType(-1); }
94  void SetOutputTypeToImage() { this->SetOutputType(VTK_IMAGE_DATA); }
95  void SetOutputTypeToRectilinear() { this->SetOutputType(VTK_RECTILINEAR_GRID); }
96  void SetOutputTypeToStructured() { this->SetOutputType(VTK_STRUCTURED_GRID); }
97  void SetOutputTypeToUnstructured() { this->SetOutputType(VTK_UNSTRUCTURED_GRID); }
99 
103  static int CanReadFile(const char* filename);
104 
105 protected:
107  ~vtkNetCDFCFReader() override;
108 
110 
112  double VerticalBias;
113 
115 
116  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
117  vtkInformationVector* outputVector) override;
118 
119  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
120  vtkInformationVector* outputVector) override;
121 
122  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
123  vtkInformationVector* outputVector) override;
124 
126 
129  int ReadMetaData(int ncFD) override;
130  int IsTimeDimension(int ncFD, int dimId) override;
131  vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId) override;
133 
135  {
136  public:
138  vtkDimensionInfo(int ncFD, int id);
139  const char* GetName() const { return this->Name.c_str(); }
141  {
146  VERTICAL_UNITS
147  };
148  UnitsEnum GetUnits() const { return this->Units; }
149  vtkSmartPointer<vtkDoubleArray> GetCoordinates() { return this->Coordinates; }
150  vtkSmartPointer<vtkDoubleArray> GetBounds() { return this->Bounds; }
151  bool GetHasRegularSpacing() const { return this->HasRegularSpacing; }
152  double GetOrigin() const { return this->Origin; }
153  double GetSpacing() const { return this->Spacing; }
154  vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { return this->SpecialVariables; }
155 
156  protected:
158  int DimId;
163  double Origin, Spacing;
165  int LoadMetaData(int ncFD);
166  };
167  class vtkDimensionInfoVector;
168  friend class vtkDimensionInfoVector;
169  vtkDimensionInfoVector* DimensionInfo;
170  vtkDimensionInfo* GetDimensionInfo(int dimension);
171 
173  {
174  public:
176  : Valid(false)
177  {
178  }
179  vtkDependentDimensionInfo(int ncFD, int varId, vtkNetCDFCFReader* parent);
180  bool GetValid() const { return this->Valid; }
181  bool GetHasBounds() const { return this->HasBounds; }
182  bool GetCellsUnstructured() const { return this->CellsUnstructured; }
183  vtkSmartPointer<vtkIntArray> GetGridDimensions() const { return this->GridDimensions; }
185  {
186  return this->LongitudeCoordinates;
187  }
189  {
190  return this->LatitudeCoordinates;
191  }
192  vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { return this->SpecialVariables; }
193 
194  protected:
195  bool Valid;
196  bool HasBounds;
202  int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader* parent);
203  int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray* coords);
204  int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray* coords);
205  int LoadUnstructuredBoundsVariable(int ncFD, int varId, vtkDoubleArray* coords);
206  };
208  class vtkDependentDimensionInfoVector;
209  friend class vtkDependentDimensionInfoVector;
210  vtkDependentDimensionInfoVector* DependentDimensionInfo;
211 
212  // Finds the dependent dimension information for the given set of dimensions.
213  // Returns nullptr if no information has been recorded.
214  vtkDependentDimensionInfo* FindDependentDimensionInfo(vtkIntArray* dims);
215 
221  virtual void IdentifySphericalCoordinates(
222  vtkIntArray* dimensions, int& longitudeDim, int& latitudeDim, int& verticalDim);
223 
225  {
234  COORDS_SPHERICAL_PSIDED_CELLS
235  };
236 
242  CoordinateTypesEnum CoordinateType(vtkIntArray* dimensions);
243 
247  bool DimensionsAreForPointData(vtkIntArray* dimensions) override;
248 
254  void ExtentForDimensionsAndPiece(
255  int pieceNumber, int numberOfPieces, int ghostLevels, int extent[6]);
256 
260  void GetUpdateExtentForOutput(vtkDataSet* output, int extent[6]) override;
261 
263 
266  void AddRectilinearCoordinates(vtkImageData* imageOutput);
267  void AddRectilinearCoordinates(vtkRectilinearGrid* rectilinearOutput);
268  void FakeRectilinearCoordinates(vtkRectilinearGrid* rectilinearOutput);
269  void Add1DRectilinearCoordinates(vtkPoints* points, const int extent[6]);
270  void Add2DRectilinearCoordinates(vtkPoints* points, const int extent[6]);
271  void Add1DRectilinearCoordinates(vtkStructuredGrid* structuredOutput);
272  void Add2DRectilinearCoordinates(vtkStructuredGrid* structuredOutput);
273  void FakeStructuredCoordinates(vtkStructuredGrid* structuredOutput);
274  void Add1DRectilinearCoordinates(vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
275  void Add2DRectilinearCoordinates(vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
277 
279 
282  void Add1DSphericalCoordinates(vtkPoints* points, const int extent[6]);
283  void Add2DSphericalCoordinates(vtkPoints* points, const int extent[6]);
284  void Add1DSphericalCoordinates(vtkStructuredGrid* structuredOutput);
285  void Add2DSphericalCoordinates(vtkStructuredGrid* structuredOutput);
286  void Add1DSphericalCoordinates(vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
287  void Add2DSphericalCoordinates(vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
289 
293  void AddStructuredCells(vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
294 
296 
299  void AddUnstructuredRectilinearCoordinates(
300  vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
301  void AddUnstructuredSphericalCoordinates(
302  vtkUnstructuredGrid* unstructuredOutput, const int extent[6]);
304 
305 private:
306  vtkNetCDFCFReader(const vtkNetCDFCFReader&) = delete;
307  void operator=(const vtkNetCDFCFReader&) = delete;
308 };
309 
310 #endif // vtkNetCDFCFReader_h
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkNetCDFCFReader::vtkDependentDimensionInfo::vtkDependentDimensionInfo
vtkDependentDimensionInfo()
Definition: vtkNetCDFCFReader.h:175
vtkStdString.h
vtkNetCDFCFReader::CoordinateTypesEnum
CoordinateTypesEnum
Definition: vtkNetCDFCFReader.h:224
vtkNetCDFCFReader::vtkDependentDimensionInfo::Valid
bool Valid
Definition: vtkNetCDFCFReader.h:195
vtkNetCDFCFReader::vtkDependentDimensionInfo::HasBounds
bool HasBounds
Definition: vtkNetCDFCFReader.h:196
vtkNetCDFCFReader::DimensionInfo
vtkDimensionInfoVector * DimensionInfo
Definition: vtkNetCDFCFReader.h:169
vtkNetCDFCFReader::vtkDimensionInfo::GetOrigin
double GetOrigin() const
Definition: vtkNetCDFCFReader.h:152
vtkNetCDFCFReader::SetOutputTypeToUnstructured
void SetOutputTypeToUnstructured()
Definition: vtkNetCDFCFReader.h:97
vtkNetCDFCFReader::VerticalScale
double VerticalScale
Definition: vtkNetCDFCFReader.h:111
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkNetCDFCFReader::vtkDimensionInfo::Bounds
vtkSmartPointer< vtkDoubleArray > Bounds
Definition: vtkNetCDFCFReader.h:160
vtkNetCDFCFReader::SetOutputTypeToStructured
void SetOutputTypeToStructured()
Definition: vtkNetCDFCFReader.h:96
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetLongitudeCoordinates
vtkSmartPointer< vtkDoubleArray > GetLongitudeCoordinates() const
Definition: vtkNetCDFCFReader.h:184
vtkRectilinearGrid
a dataset that is topologically regular with variable spacing in the three coordinate directions
Definition: vtkRectilinearGrid.h:51
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkNetCDFReader
Definition: vtkNetCDFReader.h:51
vtkNetCDFCFReader::vtkDimensionInfo::DimId
int DimId
Definition: vtkNetCDFCFReader.h:158
VTK_IMAGE_DATA
#define VTK_IMAGE_DATA
Definition: vtkType.h:91
vtkNetCDFReader::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
vtkStructuredGrid
topologically regular array of data
Definition: vtkStructuredGrid.h:57
vtkSmartPointer< vtkDoubleArray >
vtkNetCDFCFReader
Definition: vtkNetCDFCFReader.h:47
vtkNetCDFCFReader::vtkDependentDimensionInfo::SpecialVariables
vtkSmartPointer< vtkStringArray > SpecialVariables
Definition: vtkNetCDFCFReader.h:201
vtkNetCDFReader::RequestDataObject
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkNetCDFCFReader::vtkDimensionInfo::Units
UnitsEnum Units
Definition: vtkNetCDFCFReader.h:161
vtkNetCDFReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNetCDFCFReader::vtkDimensionInfo::UNDEFINED_UNITS
@ UNDEFINED_UNITS
Definition: vtkNetCDFCFReader.h:142
vtkNetCDFReader::New
static vtkNetCDFReader * New()
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetCellsUnstructured
bool GetCellsUnstructured() const
Definition: vtkNetCDFCFReader.h:182
vtkNetCDFReader::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
vtkNetCDFCFReader::vtkDependentDimensionInfo::LatitudeCoordinates
vtkSmartPointer< vtkDoubleArray > LatitudeCoordinates
Definition: vtkNetCDFCFReader.h:200
vtkNetCDFCFReader::SetOutputTypeToImage
void SetOutputTypeToImage()
Definition: vtkNetCDFCFReader.h:94
vtkNetCDFCFReader::vtkDependentDimensionInfo::CellsUnstructured
bool CellsUnstructured
Definition: vtkNetCDFCFReader.h:197
vtkNetCDFCFReader::vtkDimensionInfo::vtkDimensionInfo
vtkDimensionInfo()
Definition: vtkNetCDFCFReader.h:137
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkNetCDFCFReader::vtkDimensionInfo::GetBounds
vtkSmartPointer< vtkDoubleArray > GetBounds()
Definition: vtkNetCDFCFReader.h:150
vtkNetCDFCFReader::OutputType
int OutputType
Definition: vtkNetCDFCFReader.h:114
vtkNetCDFCFReader::SetOutputTypeToAutomatic
void SetOutputTypeToAutomatic()
Definition: vtkNetCDFCFReader.h:93
vtkNetCDFCFReader::vtkDimensionInfo::SpecialVariables
vtkSmartPointer< vtkStringArray > SpecialVariables
Definition: vtkNetCDFCFReader.h:164
vtkNetCDFCFReader::vtkDimensionInfo::Spacing
double Spacing
Definition: vtkNetCDFCFReader.h:163
vtkNetCDFCFReader::COORDS_EUCLIDEAN_PSIDED_CELLS
@ COORDS_EUCLIDEAN_PSIDED_CELLS
Definition: vtkNetCDFCFReader.h:233
vtkNetCDFCFReader::vtkDependentDimensionInfo::LongitudeCoordinates
vtkSmartPointer< vtkDoubleArray > LongitudeCoordinates
Definition: vtkNetCDFCFReader.h:199
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkNetCDFCFReader::vtkDimensionInfo::GetCoordinates
vtkSmartPointer< vtkDoubleArray > GetCoordinates()
Definition: vtkNetCDFCFReader.h:149
vtkNetCDFCFReader::SphericalCoordinates
vtkTypeBool SphericalCoordinates
Definition: vtkNetCDFCFReader.h:109
vtkNetCDFCFReader::vtkDimensionInfo::GetSpecialVariables
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
Definition: vtkNetCDFCFReader.h:154
vtkNetCDFReader::GetTimeValues
virtual vtkSmartPointer< vtkDoubleArray > GetTimeValues(int ncFD, int dimId)
Given a dimension already determined to be a time dimension (via a call to IsTimeDimension) returns a...
vtkNetCDFCFReader::vtkDimensionInfo::TIME_UNITS
@ TIME_UNITS
Definition: vtkNetCDFCFReader.h:143
vtkNetCDFCFReader::VerticalBias
double VerticalBias
Definition: vtkNetCDFCFReader.h:112
vtkNetCDFCFReader::vtkDimensionInfo::GetUnits
UnitsEnum GetUnits() const
Definition: vtkNetCDFCFReader.h:148
vtkNetCDFCFReader::vtkDimensionInfo::GetName
const char * GetName() const
Definition: vtkNetCDFCFReader.h:139
vtkNetCDFCFReader::vtkDimensionInfo::GetHasRegularSpacing
bool GetHasRegularSpacing() const
Definition: vtkNetCDFCFReader.h:151
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetHasBounds
bool GetHasBounds() const
Definition: vtkNetCDFCFReader.h:181
vtkNetCDFCFReader::vtkDimensionInfo::Coordinates
vtkSmartPointer< vtkDoubleArray > Coordinates
Definition: vtkNetCDFCFReader.h:159
vtkNetCDFCFReader::vtkDimensionInfo::Name
vtkStdString Name
Definition: vtkNetCDFCFReader.h:157
vtkNetCDFReader::IsTimeDimension
virtual int IsTimeDimension(int ncFD, int dimId)
Determines whether the given variable is a time dimension.
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkNetCDFCFReader::DependentDimensionInfo
vtkDependentDimensionInfoVector * DependentDimensionInfo
Definition: vtkNetCDFCFReader.h:210
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetLatitudeCoordinates
vtkSmartPointer< vtkDoubleArray > GetLatitudeCoordinates() const
Definition: vtkNetCDFCFReader.h:188
vtkNetCDFCFReader::vtkDimensionInfo::LATITUDE_UNITS
@ LATITUDE_UNITS
Definition: vtkNetCDFCFReader.h:144
vtkNetCDFCFReader::SetOutputTypeToRectilinear
void SetOutputTypeToRectilinear()
Definition: vtkNetCDFCFReader.h:95
vtkNetCDFCFReader::vtkDependentDimensionInfo::GridDimensions
vtkSmartPointer< vtkIntArray > GridDimensions
Definition: vtkNetCDFCFReader.h:198
vtkNetCDFReader::GetUpdateExtentForOutput
virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6])
Retrieves the update extent for the output object.
vtkNetCDFCFReader::vtkDimensionInfo::GetSpacing
double GetSpacing() const
Definition: vtkNetCDFCFReader.h:153
vtkNetCDFCFReader::vtkDimensionInfo
Definition: vtkNetCDFCFReader.h:134
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetValid
bool GetValid() const
Definition: vtkNetCDFCFReader.h:180
vtkNetCDFReader.h
vtkNetCDFReader::ReadMetaData
virtual int ReadMetaData(int ncFD)
Reads meta data and populates ivars.
vtkNetCDFReader::DimensionsAreForPointData
virtual bool DimensionsAreForPointData(vtkIntArray *vtkNotUsed(dimensions))
Called internally to determine whether a variable with the given set of dimensions should be loaded a...
Definition: vtkNetCDFReader.h:243
vtkNetCDFCFReader::vtkDependentDimensionInfo
Definition: vtkNetCDFCFReader.h:172
vtkNetCDFCFReader::COORDS_NONUNIFORM_RECTILINEAR
@ COORDS_NONUNIFORM_RECTILINEAR
Definition: vtkNetCDFCFReader.h:227
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkNetCDFCFReader::COORDS_2D_SPHERICAL
@ COORDS_2D_SPHERICAL
Definition: vtkNetCDFCFReader.h:230
vtkX3D::extent
@ extent
Definition: vtkX3D.h:351
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:92
vtkNetCDFCFReader::vtkDimensionInfo::UnitsEnum
UnitsEnum
Definition: vtkNetCDFCFReader.h:140
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetGridDimensions
vtkSmartPointer< vtkIntArray > GetGridDimensions() const
Definition: vtkNetCDFCFReader.h:183
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
vtkNetCDFCFReader::COORDS_2D_EUCLIDEAN
@ COORDS_2D_EUCLIDEAN
Definition: vtkNetCDFCFReader.h:229
vtkNetCDFCFReader::COORDS_UNIFORM_RECTILINEAR
@ COORDS_UNIFORM_RECTILINEAR
Definition: vtkNetCDFCFReader.h:226
VTK_UNSTRUCTURED_GRID
#define VTK_UNSTRUCTURED_GRID
Definition: vtkType.h:89
vtkNetCDFCFReader::COORDS_REGULAR_SPHERICAL
@ COORDS_REGULAR_SPHERICAL
Definition: vtkNetCDFCFReader.h:228
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetSpecialVariables
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
Definition: vtkNetCDFCFReader.h:192
vtkNetCDFCFReader::COORDS_SPHERICAL_4SIDED_CELLS
@ COORDS_SPHERICAL_4SIDED_CELLS
Definition: vtkNetCDFCFReader.h:232
vtkNetCDFCFReader::vtkDimensionInfo::LONGITUDE_UNITS
@ LONGITUDE_UNITS
Definition: vtkNetCDFCFReader.h:145
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
VTK_RECTILINEAR_GRID
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:88
vtkNetCDFCFReader::COORDS_EUCLIDEAN_4SIDED_CELLS
@ COORDS_EUCLIDEAN_4SIDED_CELLS
Definition: vtkNetCDFCFReader.h:231
VTK_STRUCTURED_GRID
#define VTK_STRUCTURED_GRID
Definition: vtkType.h:87
vtkNetCDFCFReader::vtkDimensionInfo::HasRegularSpacing
bool HasRegularSpacing
Definition: vtkNetCDFCFReader.h:162