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 "vtkNetCDFReader.h"
39 
40 #include <vtkStdString.h> // Used for ivars.
41 
42 class vtkImageData;
43 class vtkPoints;
44 class vtkRectilinearGrid;
45 class vtkStructuredGrid;
47 
49 {
50 public:
52  static vtkNetCDFCFReader *New();
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54 
56 
60  vtkGetMacro(SphericalCoordinates, int);
61  vtkSetMacro(SphericalCoordinates, int);
62  vtkBooleanMacro(SphericalCoordinates, int);
64 
66 
75  vtkGetMacro(VerticalScale, double);
76  vtkSetMacro(VerticalScale, double);
77  vtkGetMacro(VerticalBias, double);
78  vtkSetMacro(VerticalBias, double);
80 
82 
88  vtkGetMacro(OutputType, int);
89  virtual void SetOutputType(int type);
90  void SetOutputTypeToAutomatic() { this->SetOutputType(-1); }
91  void SetOutputTypeToImage() { this->SetOutputType(VTK_IMAGE_DATA); }
92  void SetOutputTypeToRectilinear() {this->SetOutputType(VTK_RECTILINEAR_GRID);}
93  void SetOutputTypeToStructured() { this->SetOutputType(VTK_STRUCTURED_GRID); }
95  this->SetOutputType(VTK_UNSTRUCTURED_GRID);
96  }
98 
100  static int CanReadFile(const char *filename);
101 
102 protected:
105 
107 
109  double VerticalBias;
110 
112 
113  virtual int RequestDataObject(vtkInformation *request,
114  vtkInformationVector **inputVector,
115  vtkInformationVector *outputVector);
116 
117  virtual int RequestInformation(vtkInformation *request,
118  vtkInformationVector **inputVector,
119  vtkInformationVector *outputVector);
120 
121  virtual int RequestData(vtkInformation *request,
122  vtkInformationVector **inputVector,
123  vtkInformationVector *outputVector);
124 
125 //BTX
127 
128  virtual int ReadMetaData(int ncFD);
129  virtual int IsTimeDimension(int ncFD, int dimId);
130  virtual vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId);
131 //ETX
133 
134 //BTX
136  public:
138  vtkDimensionInfo(int ncFD, int id);
139  const char *GetName() const { return this->Name.c_str(); }
140  enum UnitsEnum {
145  VERTICAL_UNITS
146  };
147  UnitsEnum GetUnits() const { return this->Units; }
148  vtkSmartPointer<vtkDoubleArray> GetCoordinates() {return this->Coordinates;}
149  vtkSmartPointer<vtkDoubleArray> GetBounds() { return this->Bounds; }
150  bool GetHasRegularSpacing() const { return this->HasRegularSpacing; }
151  double GetOrigin() const { return this->Origin; }
152  double GetSpacing() const { return this->Spacing; }
154  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  public:
174  vtkDependentDimensionInfo() : Valid(false) { };
175  vtkDependentDimensionInfo(int ncFD, int varId, vtkNetCDFCFReader *parent);
176  bool GetValid() const { return this->Valid; }
177  bool GetHasBounds() const { return this->HasBounds; }
178  bool GetCellsUnstructured() const { return this->CellsUnstructured; }
180  return this->GridDimensions;
181  }
183  return this->LongitudeCoordinates;
184  }
186  return this->LatitudeCoordinates;
187  }
189  return this->SpecialVariables;
190  }
191  protected:
192  bool Valid;
193  bool HasBounds;
199  int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader *parent);
200  int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray *coords);
201  int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray *coords);
202  int LoadUnstructuredBoundsVariable(int ncFD, int varId,
203  vtkDoubleArray *coords);
204  };
206  class vtkDependentDimensionInfoVector;
207  friend class vtkDependentDimensionInfoVector;
208  vtkDependentDimensionInfoVector *DependentDimensionInfo;
209 
210  // Finds the dependent dimension information for the given set of dimensions.
211  // Returns NULL if no information has been recorded.
212  vtkDependentDimensionInfo *FindDependentDimensionInfo(vtkIntArray *dims);
213 //ETX
214 
216 
219  virtual void IdentifySphericalCoordinates(vtkIntArray *dimensions,
220  int &longitudeDim,
221  int &latitudeDim,
222  int &verticalDim);
224 
234  COORDS_SPHERICAL_PSIDED_CELLS
235  };
236 
240  CoordinateTypesEnum CoordinateType(vtkIntArray *dimensions);
241 
243  virtual bool DimensionsAreForPointData(vtkIntArray *dimensions);
244 
246 
249  void ExtentForDimensionsAndPiece(int pieceNumber,
250  int numberOfPieces,
251  int ghostLevels,
252  int extent[6]);
254 
256  virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6]);
257 
259 
260  void AddRectilinearCoordinates(vtkImageData *imageOutput);
261  void AddRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput);
262  void Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
263  void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
264  void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
265  void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
266  void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
267  const int extent[6]);
268  void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
269  const int extent[6]);
271 
273 
274  void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]);
275  void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]);
276  void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
277  void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
278  void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
279  const int extent[6]);
280  void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
281  const int extent[6]);
283 
285 
287  void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput,
288  const int extent[6]);
290 
292 
293  void AddUnstructuredRectilinearCoordinates(
294  vtkUnstructuredGrid *unstructuredOutput,
295  const int extent[6]);
296  void AddUnstructuredSphericalCoordinates(
297  vtkUnstructuredGrid *unstructuredOutput,
298  const int extent[6]);
300 
301 
302 private:
303  vtkNetCDFCFReader(const vtkNetCDFCFReader &); // Not implemented
304  void operator=(const vtkNetCDFCFReader &); // Not implemented
305 };
306 
307 #endif //__vtkNetCDFCFReader_h
308