VTK
|
00001 // -*- c++ -*- 00002 /*========================================================================= 00003 00004 Program: Visualization Toolkit 00005 Module: vtkNetCDFCFReader.h 00006 00007 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00016 00017 /*------------------------------------------------------------------------- 00018 Copyright 2008 Sandia Corporation. 00019 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00020 the U.S. Government retains certain rights in this software. 00021 -------------------------------------------------------------------------*/ 00022 00035 #ifndef __vtkNetCDFCFReader_h 00036 #define __vtkNetCDFCFReader_h 00037 00038 #include "vtkIONetCDFModule.h" // For export macro 00039 #include "vtkNetCDFReader.h" 00040 00041 #include <vtkStdString.h> // Used for ivars. 00042 00043 class vtkImageData; 00044 class vtkPoints; 00045 class vtkRectilinearGrid; 00046 class vtkStructuredGrid; 00047 class vtkUnstructuredGrid; 00048 00049 class VTKIONETCDF_EXPORT vtkNetCDFCFReader : public vtkNetCDFReader 00050 { 00051 public: 00052 vtkTypeMacro(vtkNetCDFCFReader, vtkNetCDFReader); 00053 static vtkNetCDFCFReader *New(); 00054 virtual void PrintSelf(ostream &os, vtkIndent indent); 00055 00057 00061 vtkGetMacro(SphericalCoordinates, int); 00062 vtkSetMacro(SphericalCoordinates, int); 00063 vtkBooleanMacro(SphericalCoordinates, int); 00065 00067 00076 vtkGetMacro(VerticalScale, double); 00077 vtkSetMacro(VerticalScale, double); 00078 vtkGetMacro(VerticalBias, double); 00079 vtkSetMacro(VerticalBias, double); 00081 00083 00089 vtkGetMacro(OutputType, int); 00090 virtual void SetOutputType(int type); 00091 void SetOutputTypeToAutomatic() { this->SetOutputType(-1); } 00092 void SetOutputTypeToImage() { this->SetOutputType(VTK_IMAGE_DATA); } 00093 void SetOutputTypeToRectilinear() {this->SetOutputType(VTK_RECTILINEAR_GRID);} 00094 void SetOutputTypeToStructured() { this->SetOutputType(VTK_STRUCTURED_GRID); } 00095 void SetOutputTypeToUnstructured() { 00096 this->SetOutputType(VTK_UNSTRUCTURED_GRID); 00097 } 00099 00101 static int CanReadFile(const char *filename); 00102 00103 protected: 00104 vtkNetCDFCFReader(); 00105 ~vtkNetCDFCFReader(); 00106 00107 int SphericalCoordinates; 00108 00109 double VerticalScale; 00110 double VerticalBias; 00111 00112 int OutputType; 00113 00114 virtual int RequestDataObject(vtkInformation *request, 00115 vtkInformationVector **inputVector, 00116 vtkInformationVector *outputVector); 00117 00118 virtual int RequestInformation(vtkInformation *request, 00119 vtkInformationVector **inputVector, 00120 vtkInformationVector *outputVector); 00121 00122 virtual int RequestData(vtkInformation *request, 00123 vtkInformationVector **inputVector, 00124 vtkInformationVector *outputVector); 00125 00126 //BTX 00128 00129 virtual int ReadMetaData(int ncFD); 00130 virtual int IsTimeDimension(int ncFD, int dimId); 00131 virtual vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId); 00132 //ETX 00134 00135 //BTX 00136 class vtkDimensionInfo { 00137 public: 00138 vtkDimensionInfo() { }; 00139 vtkDimensionInfo(int ncFD, int id); 00140 const char *GetName() const { return this->Name.c_str(); } 00141 enum UnitsEnum { 00142 UNDEFINED_UNITS, 00143 TIME_UNITS, 00144 LATITUDE_UNITS, 00145 LONGITUDE_UNITS, 00146 VERTICAL_UNITS 00147 }; 00148 UnitsEnum GetUnits() const { return this->Units; } 00149 vtkSmartPointer<vtkDoubleArray> GetCoordinates() {return this->Coordinates;} 00150 vtkSmartPointer<vtkDoubleArray> GetBounds() { return this->Bounds; } 00151 bool GetHasRegularSpacing() const { return this->HasRegularSpacing; } 00152 double GetOrigin() const { return this->Origin; } 00153 double GetSpacing() const { return this->Spacing; } 00154 vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { 00155 return this->SpecialVariables; 00156 } 00157 protected: 00158 vtkStdString Name; 00159 int DimId; 00160 vtkSmartPointer<vtkDoubleArray> Coordinates; 00161 vtkSmartPointer<vtkDoubleArray> Bounds; 00162 UnitsEnum Units; 00163 bool HasRegularSpacing; 00164 double Origin, Spacing; 00165 vtkSmartPointer<vtkStringArray> SpecialVariables; 00166 int LoadMetaData(int ncFD); 00167 }; 00168 class vtkDimensionInfoVector; 00169 friend class vtkDimensionInfoVector; 00170 vtkDimensionInfoVector *DimensionInfo; 00171 vtkDimensionInfo *GetDimensionInfo(int dimension); 00172 00173 class vtkDependentDimensionInfo { 00174 public: 00175 vtkDependentDimensionInfo() : Valid(false) { }; 00176 vtkDependentDimensionInfo(int ncFD, int varId, vtkNetCDFCFReader *parent); 00177 bool GetValid() const { return this->Valid; } 00178 bool GetHasBounds() const { return this->HasBounds; } 00179 bool GetCellsUnstructured() const { return this->CellsUnstructured; } 00180 vtkSmartPointer<vtkIntArray> GetGridDimensions() const { 00181 return this->GridDimensions; 00182 } 00183 vtkSmartPointer<vtkDoubleArray> GetLongitudeCoordinates() const { 00184 return this->LongitudeCoordinates; 00185 } 00186 vtkSmartPointer<vtkDoubleArray> GetLatitudeCoordinates() const { 00187 return this->LatitudeCoordinates; 00188 } 00189 vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { 00190 return this->SpecialVariables; 00191 } 00192 protected: 00193 bool Valid; 00194 bool HasBounds; 00195 bool CellsUnstructured; 00196 vtkSmartPointer<vtkIntArray> GridDimensions; 00197 vtkSmartPointer<vtkDoubleArray> LongitudeCoordinates; 00198 vtkSmartPointer<vtkDoubleArray> LatitudeCoordinates; 00199 vtkSmartPointer<vtkStringArray> SpecialVariables; 00200 int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader *parent); 00201 int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray *coords); 00202 int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray *coords); 00203 int LoadUnstructuredBoundsVariable(int ncFD, int varId, 00204 vtkDoubleArray *coords); 00205 }; 00206 friend class vtkDependentDimensionInfo; 00207 class vtkDependentDimensionInfoVector; 00208 friend class vtkDependentDimensionInfoVector; 00209 vtkDependentDimensionInfoVector *DependentDimensionInfo; 00210 00211 // Finds the dependent dimension information for the given set of dimensions. 00212 // Returns NULL if no information has been recorded. 00213 vtkDependentDimensionInfo *FindDependentDimensionInfo(vtkIntArray *dims); 00214 //ETX 00215 00217 00220 virtual void IdentifySphericalCoordinates(vtkIntArray *dimensions, 00221 int &longitudeDim, 00222 int &latitudeDim, 00223 int &verticalDim); 00225 00226 enum CoordinateTypesEnum { 00227 COORDS_UNIFORM_RECTILINEAR, 00228 COORDS_NONUNIFORM_RECTILINEAR, 00229 COORDS_REGULAR_SPHERICAL, 00230 COORDS_2D_EUCLIDEAN, 00231 COORDS_2D_SPHERICAL, 00232 COORDS_EUCLIDEAN_4SIDED_CELLS, 00233 COORDS_SPHERICAL_4SIDED_CELLS, 00234 COORDS_EUCLIDEAN_PSIDED_CELLS, 00235 COORDS_SPHERICAL_PSIDED_CELLS 00236 }; 00237 00241 CoordinateTypesEnum CoordinateType(vtkIntArray *dimensions); 00242 00244 virtual bool DimensionsAreForPointData(vtkIntArray *dimensions); 00245 00247 00250 void ExtentForDimensionsAndPiece(int pieceNumber, 00251 int numberOfPieces, 00252 int ghostLevels, 00253 int extent[6]); 00255 00257 virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6]); 00258 00260 00261 void AddRectilinearCoordinates(vtkImageData *imageOutput); 00262 void AddRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput); 00263 void Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]); 00264 void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]); 00265 void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput); 00266 void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput); 00267 void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00268 const int extent[6]); 00269 void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00270 const int extent[6]); 00272 00274 00275 void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]); 00276 void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]); 00277 void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput); 00278 void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput); 00279 void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00280 const int extent[6]); 00281 void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00282 const int extent[6]); 00284 00286 00288 void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput, 00289 const int extent[6]); 00291 00293 00294 void AddUnstructuredRectilinearCoordinates( 00295 vtkUnstructuredGrid *unstructuredOutput, 00296 const int extent[6]); 00297 void AddUnstructuredSphericalCoordinates( 00298 vtkUnstructuredGrid *unstructuredOutput, 00299 const int extent[6]); 00301 00302 00303 private: 00304 vtkNetCDFCFReader(const vtkNetCDFCFReader &); // Not implemented 00305 void operator=(const vtkNetCDFCFReader &); // Not implemented 00306 }; 00307 00308 #endif //__vtkNetCDFCFReader_h 00309