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 
49 class VTKIONETCDF_EXPORT vtkNetCDFCFReader : public vtkNetCDFReader
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 Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
264  void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]);
265  void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
266  void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput);
267  void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
268  const int extent[6]);
269  void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput,
270  const int extent[6]);
272 
274 
275  void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]);
276  void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]);
277  void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
278  void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput);
279  void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
280  const int extent[6]);
281  void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput,
282  const int extent[6]);
284 
286 
288  void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput,
289  const int extent[6]);
291 
293 
294  void AddUnstructuredRectilinearCoordinates(
295  vtkUnstructuredGrid *unstructuredOutput,
296  const int extent[6]);
297  void AddUnstructuredSphericalCoordinates(
298  vtkUnstructuredGrid *unstructuredOutput,
299  const int extent[6]);
301 
302 
303 private:
304  vtkNetCDFCFReader(const vtkNetCDFCFReader &); // Not implemented
305  void operator=(const vtkNetCDFCFReader &); // Not implemented
306 };
307 
308 #endif //__vtkNetCDFCFReader_h
309