VTK
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); }
98  this->SetOutputType(VTK_UNSTRUCTURED_GRID);
99  }
101 
105  static int CanReadFile(const char *filename);
106 
107 protected:
109  ~vtkNetCDFCFReader() override;
110 
112 
114  double VerticalBias;
115 
117 
118  int RequestDataObject(vtkInformation *request,
119  vtkInformationVector **inputVector,
120  vtkInformationVector *outputVector) override;
121 
122  int RequestInformation(vtkInformation *request,
123  vtkInformationVector **inputVector,
124  vtkInformationVector *outputVector) override;
125 
126  int RequestData(vtkInformation *request,
127  vtkInformationVector **inputVector,
128  vtkInformationVector *outputVector) override;
129 
131 
134  int ReadMetaData(int ncFD) override;
135  int IsTimeDimension(int ncFD, int dimId) override;
136  vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId) override;
138 
140  public:
142  vtkDimensionInfo(int ncFD, int id);
143  const char *GetName() const { return this->Name.c_str(); }
144  enum UnitsEnum {
149  VERTICAL_UNITS
150  };
151  UnitsEnum GetUnits() const { return this->Units; }
152  vtkSmartPointer<vtkDoubleArray> GetCoordinates() {return this->Coordinates;}
153  vtkSmartPointer<vtkDoubleArray> GetBounds() { return this->Bounds; }
154  bool GetHasRegularSpacing() const { return this->HasRegularSpacing; }
155  double GetOrigin() const { return this->Origin; }
156  double GetSpacing() const { return this->Spacing; }
158  return this->SpecialVariables;
159  }
160  protected:
162  int DimId;
167  double Origin, Spacing;
169  int LoadMetaData(int ncFD);
170  };
171  class vtkDimensionInfoVector;
172  friend class vtkDimensionInfoVector;
173  vtkDimensionInfoVector *DimensionInfo;
174  vtkDimensionInfo *GetDimensionInfo(int dimension);
175 
177  public:
178  vtkDependentDimensionInfo() : Valid(false) { };
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; }
184  return this->GridDimensions;
185  }
187  return this->LongitudeCoordinates;
188  }
190  return this->LatitudeCoordinates;
191  }
193  return this->SpecialVariables;
194  }
195  protected:
196  bool Valid;
197  bool HasBounds;
203  int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader *parent);
204  int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray *coords);
205  int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray *coords);
206  int LoadUnstructuredBoundsVariable(int ncFD, int varId,
207  vtkDoubleArray *coords);
208  };
210  class vtkDependentDimensionInfoVector;
211  friend class vtkDependentDimensionInfoVector;
212  vtkDependentDimensionInfoVector *DependentDimensionInfo;
213 
214  // Finds the dependent dimension information for the given set of dimensions.
215  // Returns nullptr if no information has been recorded.
216  vtkDependentDimensionInfo *FindDependentDimensionInfo(vtkIntArray *dims);
217 
223  virtual void IdentifySphericalCoordinates(vtkIntArray *dimensions,
224  int &longitudeDim,
225  int &latitudeDim,
226  int &verticalDim);
227 
237  COORDS_SPHERICAL_PSIDED_CELLS
238  };
239 
245  CoordinateTypesEnum CoordinateType(vtkIntArray *dimensions);
246 
250  bool DimensionsAreForPointData(vtkIntArray *dimensions) override;
251 
257  void ExtentForDimensionsAndPiece(int pieceNumber,
258  int numberOfPieces,
259  int ghostLevels,
260  int extent[6]);
261 
265  void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6]) override;
266 
268 
271  void AddRectilinearCoordinates(vtkImageData *imageOutput);
272  void AddRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput);
273  void FakeRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput);
274  void Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
275  void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
276  void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
277  void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
278  void FakeStructuredCoordinates(vtkStructuredGrid *structuredOutput);
279  void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
280  const int extent[6]);
281  void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
282  const int extent[6]);
284 
286 
289  void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]);
290  void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]);
291  void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
292  void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
293  void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
294  const int extent[6]);
295  void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
296  const int extent[6]);
298 
302  void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput,
303  const int extent[6]);
304 
306 
309  void AddUnstructuredRectilinearCoordinates(
310  vtkUnstructuredGrid *unstructuredOutput,
311  const int extent[6]);
312  void AddUnstructuredSphericalCoordinates(
313  vtkUnstructuredGrid *unstructuredOutput,
314  const int extent[6]);
316 
317 
318 private:
319  vtkNetCDFCFReader(const vtkNetCDFCFReader &) = delete;
320  void operator=(const vtkNetCDFCFReader &) = delete;
321 };
322 
323 #endif //vtkNetCDFCFReader_h
324 
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkNetCDFCFReader::vtkDependentDimensionInfo::vtkDependentDimensionInfo
vtkDependentDimensionInfo()
Definition: vtkNetCDFCFReader.h:178
vtkStdString.h
vtkNetCDFCFReader::CoordinateTypesEnum
CoordinateTypesEnum
Definition: vtkNetCDFCFReader.h:228
vtkNetCDFCFReader::vtkDependentDimensionInfo::Valid
bool Valid
Definition: vtkNetCDFCFReader.h:196
vtkNetCDFCFReader::vtkDependentDimensionInfo::HasBounds
bool HasBounds
Definition: vtkNetCDFCFReader.h:197
vtkNetCDFCFReader::DimensionInfo
vtkDimensionInfoVector * DimensionInfo
Definition: vtkNetCDFCFReader.h:173
vtkNetCDFCFReader::vtkDimensionInfo::GetOrigin
double GetOrigin() const
Definition: vtkNetCDFCFReader.h:155
vtkNetCDFCFReader::SetOutputTypeToUnstructured
void SetOutputTypeToUnstructured()
Definition: vtkNetCDFCFReader.h:97
vtkNetCDFCFReader::VerticalScale
double VerticalScale
Definition: vtkNetCDFCFReader.h:113
vtkX3D::type
Definition: vtkX3D.h:516
vtkNetCDFCFReader::vtkDimensionInfo::Bounds
vtkSmartPointer< vtkDoubleArray > Bounds
Definition: vtkNetCDFCFReader.h:164
vtkNetCDFCFReader::SetOutputTypeToStructured
void SetOutputTypeToStructured()
Definition: vtkNetCDFCFReader.h:96
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetLongitudeCoordinates
vtkSmartPointer< vtkDoubleArray > GetLongitudeCoordinates() const
Definition: vtkNetCDFCFReader.h:186
vtkRectilinearGrid
a dataset that is topologically regular with variable spacing in the three coordinate directions
Definition: vtkRectilinearGrid.h:50
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkNetCDFReader
Definition: vtkNetCDFReader.h:51
vtkNetCDFCFReader::vtkDimensionInfo::DimId
int DimId
Definition: vtkNetCDFCFReader.h:162
VTK_IMAGE_DATA
#define VTK_IMAGE_DATA
Definition: vtkType.h:97
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:202
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:165
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
Definition: vtkNetCDFCFReader.h:145
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:201
vtkNetCDFCFReader::SetOutputTypeToImage
void SetOutputTypeToImage()
Definition: vtkNetCDFCFReader.h:94
vtkNetCDFCFReader::vtkDependentDimensionInfo::CellsUnstructured
bool CellsUnstructured
Definition: vtkNetCDFCFReader.h:198
vtkNetCDFCFReader::vtkDimensionInfo::vtkDimensionInfo
vtkDimensionInfo()
Definition: vtkNetCDFCFReader.h:141
vtkX3D::points
Definition: vtkX3D.h:446
vtkNetCDFCFReader::vtkDimensionInfo::GetBounds
vtkSmartPointer< vtkDoubleArray > GetBounds()
Definition: vtkNetCDFCFReader.h:153
vtkNetCDFCFReader::OutputType
int OutputType
Definition: vtkNetCDFCFReader.h:116
vtkNetCDFCFReader::SetOutputTypeToAutomatic
void SetOutputTypeToAutomatic()
Definition: vtkNetCDFCFReader.h:93
vtkNetCDFCFReader::vtkDimensionInfo::SpecialVariables
vtkSmartPointer< vtkStringArray > SpecialVariables
Definition: vtkNetCDFCFReader.h:168
vtkNetCDFCFReader::vtkDimensionInfo::Spacing
double Spacing
Definition: vtkNetCDFCFReader.h:167
vtkNetCDFCFReader::COORDS_EUCLIDEAN_PSIDED_CELLS
Definition: vtkNetCDFCFReader.h:236
vtkNetCDFCFReader::vtkDependentDimensionInfo::LongitudeCoordinates
vtkSmartPointer< vtkDoubleArray > LongitudeCoordinates
Definition: vtkNetCDFCFReader.h:200
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
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:152
vtkNetCDFCFReader::SphericalCoordinates
vtkTypeBool SphericalCoordinates
Definition: vtkNetCDFCFReader.h:111
vtkNetCDFCFReader::vtkDimensionInfo::GetSpecialVariables
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
Definition: vtkNetCDFCFReader.h:157
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
Definition: vtkNetCDFCFReader.h:146
vtkNetCDFCFReader::VerticalBias
double VerticalBias
Definition: vtkNetCDFCFReader.h:114
vtkNetCDFCFReader::vtkDimensionInfo::GetUnits
UnitsEnum GetUnits() const
Definition: vtkNetCDFCFReader.h:151
vtkNetCDFCFReader::vtkDimensionInfo::GetName
const char * GetName() const
Definition: vtkNetCDFCFReader.h:143
vtkNetCDFCFReader::vtkDimensionInfo::GetHasRegularSpacing
bool GetHasRegularSpacing() const
Definition: vtkNetCDFCFReader.h:154
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetHasBounds
bool GetHasBounds() const
Definition: vtkNetCDFCFReader.h:181
vtkNetCDFCFReader::vtkDimensionInfo::Coordinates
vtkSmartPointer< vtkDoubleArray > Coordinates
Definition: vtkNetCDFCFReader.h:163
vtkNetCDFCFReader::vtkDimensionInfo::Name
vtkStdString Name
Definition: vtkNetCDFCFReader.h:161
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:212
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetLatitudeCoordinates
vtkSmartPointer< vtkDoubleArray > GetLatitudeCoordinates() const
Definition: vtkNetCDFCFReader.h:189
vtkNetCDFCFReader::vtkDimensionInfo::LATITUDE_UNITS
Definition: vtkNetCDFCFReader.h:147
vtkNetCDFCFReader::SetOutputTypeToRectilinear
void SetOutputTypeToRectilinear()
Definition: vtkNetCDFCFReader.h:95
vtkNetCDFCFReader::vtkDependentDimensionInfo::GridDimensions
vtkSmartPointer< vtkIntArray > GridDimensions
Definition: vtkNetCDFCFReader.h:199
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:156
vtkNetCDFCFReader::vtkDimensionInfo
Definition: vtkNetCDFCFReader.h:139
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:238
vtkNetCDFCFReader::vtkDependentDimensionInfo
Definition: vtkNetCDFCFReader.h:176
vtkNetCDFCFReader::COORDS_NONUNIFORM_RECTILINEAR
Definition: vtkNetCDFCFReader.h:230
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkNetCDFCFReader::COORDS_2D_SPHERICAL
Definition: vtkNetCDFCFReader.h:233
vtkX3D::extent
Definition: vtkX3D.h:345
vtkUnstructuredGrid
dataset represents arbitrary combinations of all possible cell types
Definition: vtkUnstructuredGrid.h:81
vtkNetCDFCFReader::vtkDimensionInfo::UnitsEnum
UnitsEnum
Definition: vtkNetCDFCFReader.h:144
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
Definition: vtkNetCDFCFReader.h:232
vtkNetCDFCFReader::COORDS_UNIFORM_RECTILINEAR
Definition: vtkNetCDFCFReader.h:229
VTK_UNSTRUCTURED_GRID
#define VTK_UNSTRUCTURED_GRID
Definition: vtkType.h:95
vtkNetCDFCFReader::COORDS_REGULAR_SPHERICAL
Definition: vtkNetCDFCFReader.h:231
vtkNetCDFCFReader::vtkDependentDimensionInfo::GetSpecialVariables
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
Definition: vtkNetCDFCFReader.h:192
vtkNetCDFCFReader::COORDS_SPHERICAL_4SIDED_CELLS
Definition: vtkNetCDFCFReader.h:235
vtkNetCDFCFReader::vtkDimensionInfo::LONGITUDE_UNITS
Definition: vtkNetCDFCFReader.h:148
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
VTK_RECTILINEAR_GRID
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:94
vtkNetCDFCFReader::COORDS_EUCLIDEAN_4SIDED_CELLS
Definition: vtkNetCDFCFReader.h:234
VTK_STRUCTURED_GRID
#define VTK_STRUCTURED_GRID
Definition: vtkType.h:93
vtkNetCDFCFReader::vtkDimensionInfo::HasRegularSpacing
bool HasRegularSpacing
Definition: vtkNetCDFCFReader.h:166