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 
35 #ifndef vtkNetCDFCFReader_h
36 #define vtkNetCDFCFReader_h
37 
38 #include "vtkIONetCDFModule.h" // For export macro
39 #include "vtkNetCDFReader.h"
40 
41 #include "vtkStdString.h" // Used for ivars.
42 
43 class vtkImageData;
44 class vtkPoints;
45 class vtkRectilinearGrid;
46 class vtkStructuredGrid;
48 
50 {
51 public:
53  static vtkNetCDFCFReader *New();
54  virtual void PrintSelf(ostream &os, vtkIndent indent);
55 
57 
61  vtkGetMacro(SphericalCoordinates, int);
62  vtkSetMacro(SphericalCoordinates, int);
63  vtkBooleanMacro(SphericalCoordinates, int);
65 
67 
76  vtkGetMacro(VerticalScale, double);
77  vtkSetMacro(VerticalScale, double);
78  vtkGetMacro(VerticalBias, double);
79  vtkSetMacro(VerticalBias, double);
81 
83 
89  vtkGetMacro(OutputType, int);
90  virtual void SetOutputType(int type);
91  void SetOutputTypeToAutomatic() { this->SetOutputType(-1); }
92  void SetOutputTypeToImage() { this->SetOutputType(VTK_IMAGE_DATA); }
93  void SetOutputTypeToRectilinear() {this->SetOutputType(VTK_RECTILINEAR_GRID);}
94  void SetOutputTypeToStructured() { this->SetOutputType(VTK_STRUCTURED_GRID); }
96  this->SetOutputType(VTK_UNSTRUCTURED_GRID);
97  }
99 
101  static int CanReadFile(const char *filename);
102 
103 protected:
106 
108 
110  double VerticalBias;
111 
113 
114  virtual int RequestDataObject(vtkInformation *request,
115  vtkInformationVector **inputVector,
116  vtkInformationVector *outputVector);
117 
118  virtual int RequestInformation(vtkInformation *request,
119  vtkInformationVector **inputVector,
120  vtkInformationVector *outputVector);
121 
122  virtual int RequestData(vtkInformation *request,
123  vtkInformationVector **inputVector,
124  vtkInformationVector *outputVector);
125 
126 //BTX
128 
129  virtual int ReadMetaData(int ncFD);
130  virtual int IsTimeDimension(int ncFD, int dimId);
131  virtual vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId);
132 //ETX
134 
135 //BTX
137  public:
139  vtkDimensionInfo(int ncFD, int id);
140  const char *GetName() const { return this->Name.c_str(); }
141  enum UnitsEnum {
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; }
155  return this->SpecialVariables;
156  }
157  protected:
159  int DimId;
164  double Origin, Spacing;
166  int LoadMetaData(int ncFD);
167  };
168  class vtkDimensionInfoVector;
169  friend class vtkDimensionInfoVector;
170  vtkDimensionInfoVector *DimensionInfo;
171  vtkDimensionInfo *GetDimensionInfo(int dimension);
172 
174  public:
175  vtkDependentDimensionInfo() : Valid(false) { };
176  vtkDependentDimensionInfo(int ncFD, int varId, vtkNetCDFCFReader *parent);
177  bool GetValid() const { return this->Valid; }
178  bool GetHasBounds() const { return this->HasBounds; }
179  bool GetCellsUnstructured() const { return this->CellsUnstructured; }
181  return this->GridDimensions;
182  }
184  return this->LongitudeCoordinates;
185  }
187  return this->LatitudeCoordinates;
188  }
190  return this->SpecialVariables;
191  }
192  protected:
193  bool Valid;
194  bool HasBounds;
200  int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader *parent);
201  int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray *coords);
202  int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray *coords);
203  int LoadUnstructuredBoundsVariable(int ncFD, int varId,
204  vtkDoubleArray *coords);
205  };
207  class vtkDependentDimensionInfoVector;
208  friend class vtkDependentDimensionInfoVector;
209  vtkDependentDimensionInfoVector *DependentDimensionInfo;
210 
211  // Finds the dependent dimension information for the given set of dimensions.
212  // Returns NULL if no information has been recorded.
213  vtkDependentDimensionInfo *FindDependentDimensionInfo(vtkIntArray *dims);
214 //ETX
215 
217 
220  virtual void IdentifySphericalCoordinates(vtkIntArray *dimensions,
221  int &longitudeDim,
222  int &latitudeDim,
223  int &verticalDim);
225 
235  COORDS_SPHERICAL_PSIDED_CELLS
236  };
237 
241  CoordinateTypesEnum CoordinateType(vtkIntArray *dimensions);
242 
244  virtual bool DimensionsAreForPointData(vtkIntArray *dimensions);
245 
247 
250  void ExtentForDimensionsAndPiece(int pieceNumber,
251  int numberOfPieces,
252  int ghostLevels,
253  int extent[6]);
255 
257  virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6]);
258 
260 
261  void AddRectilinearCoordinates(vtkImageData *imageOutput);
262  void AddRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput);
263  void FakeRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput);
264  void Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
265  void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
266  void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
267  void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
268  void FakeStructuredCoordinates(vtkStructuredGrid *structuredOutput);
269  void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
270  const int extent[6]);
271  void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
272  const int extent[6]);
274 
276 
277  void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]);
278  void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]);
279  void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
280  void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
281  void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
282  const int extent[6]);
283  void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
284  const int extent[6]);
286 
288 
290  void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput,
291  const int extent[6]);
293 
295 
296  void AddUnstructuredRectilinearCoordinates(
297  vtkUnstructuredGrid *unstructuredOutput,
298  const int extent[6]);
299  void AddUnstructuredSphericalCoordinates(
300  vtkUnstructuredGrid *unstructuredOutput,
301  const int extent[6]);
303 
304 
305 private:
306  vtkNetCDFCFReader(const vtkNetCDFCFReader &); // Not implemented
307  void operator=(const vtkNetCDFCFReader &); // Not implemented
308 };
309 
310 #endif //vtkNetCDFCFReader_h
311 
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
vtkSmartPointer< vtkDoubleArray > Coordinates
vtkSmartPointer< vtkDoubleArray > GetCoordinates()
a dataset that is topologically regular with variable spacing in the three coordinate directions ...
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
#define VTK_IMAGE_DATA
Definition: vtkType.h:72
vtkSmartPointer< vtkDoubleArray > LatitudeCoordinates
void SetOutputTypeToStructured()
#define VTK_RECTILINEAR_GRID
Definition: vtkType.h:69
virtual void PrintSelf(ostream &os, vtkIndent indent)
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
virtual bool DimensionsAreForPointData(vtkIntArray *vtkNotUsed(dimensions))
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkDimensionInfoVector * DimensionInfo
vtkSmartPointer< vtkStringArray > SpecialVariables
void SetOutputTypeToUnstructured()
virtual int ReadMetaData(int ncFD)
dynamic, self-adjusting array of double
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
static vtkNetCDFReader * New()
virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6])
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkSmartPointer< vtkDoubleArray > GetLatitudeCoordinates() const
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
dataset represents arbitrary combinations of all possible cell types
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
virtual int IsTimeDimension(int ncFD, int dimId)
vtkSmartPointer< vtkStringArray > SpecialVariables
vtkSmartPointer< vtkDoubleArray > GetBounds()
virtual vtkSmartPointer< vtkDoubleArray > GetTimeValues(int ncFD, int dimId)
vtkSmartPointer< vtkDoubleArray > LongitudeCoordinates
vtkDependentDimensionInfoVector * DependentDimensionInfo
topologically regular array of data
void SetOutputTypeToRectilinear()
Store zero or more vtkInformation instances.
#define VTKIONETCDF_EXPORT
vtkSmartPointer< vtkDoubleArray > GetLongitudeCoordinates() const
vtkSmartPointer< vtkDoubleArray > Bounds
vtkSmartPointer< vtkIntArray > GridDimensions
#define VTK_STRUCTURED_GRID
Definition: vtkType.h:68
represent and manipulate 3D points
Definition: vtkPoints.h:38
#define VTK_UNSTRUCTURED_GRID
Definition: vtkType.h:70
vtkSmartPointer< vtkStringArray > GetSpecialVariables() const
vtkSmartPointer< vtkIntArray > GetGridDimensions() const
virtual int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)