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 "vtkNetCDFReader.h" 00039 00040 #include <vtkStdString.h> // Used for ivars. 00041 00042 class vtkImageData; 00043 class vtkPoints; 00044 class vtkRectilinearGrid; 00045 class vtkStructuredGrid; 00046 class vtkUnstructuredGrid; 00047 00048 class VTK_IO_EXPORT vtkNetCDFCFReader : public vtkNetCDFReader 00049 { 00050 public: 00051 vtkTypeMacro(vtkNetCDFCFReader, vtkNetCDFReader); 00052 static vtkNetCDFCFReader *New(); 00053 virtual void PrintSelf(ostream &os, vtkIndent indent); 00054 00056 00060 vtkGetMacro(SphericalCoordinates, int); 00061 vtkSetMacro(SphericalCoordinates, int); 00062 vtkBooleanMacro(SphericalCoordinates, int); 00064 00066 00075 vtkGetMacro(VerticalScale, double); 00076 vtkSetMacro(VerticalScale, double); 00077 vtkGetMacro(VerticalBias, double); 00078 vtkSetMacro(VerticalBias, double); 00080 00082 00088 vtkGetMacro(OutputType, int); 00089 virtual void SetOutputType(int type); 00090 void SetOutputTypeToAutomatic() { this->SetOutputType(-1); } 00091 void SetOutputTypeToImage() { this->SetOutputType(VTK_IMAGE_DATA); } 00092 void SetOutputTypeToRectilinear() {this->SetOutputType(VTK_RECTILINEAR_GRID);} 00093 void SetOutputTypeToStructured() { this->SetOutputType(VTK_STRUCTURED_GRID); } 00094 void SetOutputTypeToUnstructured() { 00095 this->SetOutputType(VTK_UNSTRUCTURED_GRID); 00096 } 00098 00100 static int CanReadFile(const char *filename); 00101 00102 protected: 00103 vtkNetCDFCFReader(); 00104 ~vtkNetCDFCFReader(); 00105 00106 int SphericalCoordinates; 00107 00108 double VerticalScale; 00109 double VerticalBias; 00110 00111 int OutputType; 00112 00113 virtual int RequestDataObject(vtkInformation *request, 00114 vtkInformationVector **inputVector, 00115 vtkInformationVector *outputVector); 00116 00117 virtual int RequestInformation(vtkInformation *request, 00118 vtkInformationVector **inputVector, 00119 vtkInformationVector *outputVector); 00120 00121 virtual int RequestData(vtkInformation *request, 00122 vtkInformationVector **inputVector, 00123 vtkInformationVector *outputVector); 00124 00125 //BTX 00127 00128 virtual int ReadMetaData(int ncFD); 00129 virtual int IsTimeDimension(int ncFD, int dimId); 00130 virtual vtkSmartPointer<vtkDoubleArray> GetTimeValues(int ncFD, int dimId); 00131 //ETX 00133 00134 //BTX 00135 class vtkDimensionInfo { 00136 public: 00137 vtkDimensionInfo() { }; 00138 vtkDimensionInfo(int ncFD, int id); 00139 const char *GetName() const { return this->Name.c_str(); } 00140 enum UnitsEnum { 00141 UNDEFINED_UNITS, 00142 TIME_UNITS, 00143 LATITUDE_UNITS, 00144 LONGITUDE_UNITS, 00145 VERTICAL_UNITS 00146 }; 00147 UnitsEnum GetUnits() const { return this->Units; } 00148 vtkSmartPointer<vtkDoubleArray> GetCoordinates() {return this->Coordinates;} 00149 vtkSmartPointer<vtkDoubleArray> GetBounds() { return this->Bounds; } 00150 bool GetHasRegularSpacing() const { return this->HasRegularSpacing; } 00151 double GetOrigin() const { return this->Origin; } 00152 double GetSpacing() const { return this->Spacing; } 00153 vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { 00154 return this->SpecialVariables; 00155 } 00156 protected: 00157 vtkStdString Name; 00158 int DimId; 00159 vtkSmartPointer<vtkDoubleArray> Coordinates; 00160 vtkSmartPointer<vtkDoubleArray> Bounds; 00161 UnitsEnum Units; 00162 bool HasRegularSpacing; 00163 double Origin, Spacing; 00164 vtkSmartPointer<vtkStringArray> SpecialVariables; 00165 int LoadMetaData(int ncFD); 00166 }; 00167 class vtkDimensionInfoVector; 00168 friend class vtkDimensionInfoVector; 00169 vtkDimensionInfoVector *DimensionInfo; 00170 vtkDimensionInfo *GetDimensionInfo(int dimension); 00171 00172 class vtkDependentDimensionInfo { 00173 public: 00174 vtkDependentDimensionInfo() : Valid(false) { }; 00175 vtkDependentDimensionInfo(int ncFD, int varId, vtkNetCDFCFReader *parent); 00176 bool GetValid() const { return this->Valid; } 00177 bool GetHasBounds() const { return this->HasBounds; } 00178 bool GetCellsUnstructured() const { return this->CellsUnstructured; } 00179 vtkSmartPointer<vtkIntArray> GetGridDimensions() const { 00180 return this->GridDimensions; 00181 } 00182 vtkSmartPointer<vtkDoubleArray> GetLongitudeCoordinates() const { 00183 return this->LongitudeCoordinates; 00184 } 00185 vtkSmartPointer<vtkDoubleArray> GetLatitudeCoordinates() const { 00186 return this->LatitudeCoordinates; 00187 } 00188 vtkSmartPointer<vtkStringArray> GetSpecialVariables() const { 00189 return this->SpecialVariables; 00190 } 00191 protected: 00192 bool Valid; 00193 bool HasBounds; 00194 bool CellsUnstructured; 00195 vtkSmartPointer<vtkIntArray> GridDimensions; 00196 vtkSmartPointer<vtkDoubleArray> LongitudeCoordinates; 00197 vtkSmartPointer<vtkDoubleArray> LatitudeCoordinates; 00198 vtkSmartPointer<vtkStringArray> SpecialVariables; 00199 int LoadMetaData(int ncFD, int varId, vtkNetCDFCFReader *parent); 00200 int LoadCoordinateVariable(int ncFD, int varId, vtkDoubleArray *coords); 00201 int LoadBoundsVariable(int ncFD, int varId, vtkDoubleArray *coords); 00202 int LoadUnstructuredBoundsVariable(int ncFD, int varId, 00203 vtkDoubleArray *coords); 00204 }; 00205 friend class vtkDependentDimensionInfo; 00206 class vtkDependentDimensionInfoVector; 00207 friend class vtkDependentDimensionInfoVector; 00208 vtkDependentDimensionInfoVector *DependentDimensionInfo; 00209 00210 // Finds the dependent dimension information for the given set of dimensions. 00211 // Returns NULL if no information has been recorded. 00212 vtkDependentDimensionInfo *FindDependentDimensionInfo(vtkIntArray *dims); 00213 //ETX 00214 00216 00219 virtual void IdentifySphericalCoordinates(vtkIntArray *dimensions, 00220 int &longitudeDim, 00221 int &latitudeDim, 00222 int &verticalDim); 00224 00225 enum CoordinateTypesEnum { 00226 COORDS_UNIFORM_RECTILINEAR, 00227 COORDS_NONUNIFORM_RECTILINEAR, 00228 COORDS_REGULAR_SPHERICAL, 00229 COORDS_2D_EUCLIDEAN, 00230 COORDS_2D_SPHERICAL, 00231 COORDS_EUCLIDEAN_4SIDED_CELLS, 00232 COORDS_SPHERICAL_4SIDED_CELLS, 00233 COORDS_EUCLIDEAN_PSIDED_CELLS, 00234 COORDS_SPHERICAL_PSIDED_CELLS 00235 }; 00236 00240 CoordinateTypesEnum CoordinateType(vtkIntArray *dimensions); 00241 00243 virtual bool DimensionsAreForPointData(vtkIntArray *dimensions); 00244 00246 00249 void ExtentForDimensionsAndPiece(int pieceNumber, 00250 int numberOfPieces, 00251 int ghostLevels, 00252 int extent[6]); 00254 00256 virtual void GetUpdateExtentForOutput(vtkDataSet *output, int extent[6]); 00257 00259 00260 void AddRectilinearCoordinates(vtkImageData *imageOutput); 00261 void AddRectilinearCoordinates(vtkRectilinearGrid *rectilinearOutput); 00262 void Add1DRectilinearCoordinates(vtkPoints *points, const int extent[6]); 00263 void Add2DRectilinearCoordinates(vtkPoints *points, const int extent[6]); 00264 void Add1DRectilinearCoordinates(vtkStructuredGrid *structuredOutput); 00265 void Add2DRectilinearCoordinates(vtkStructuredGrid *structuredOutput); 00266 void Add1DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00267 const int extent[6]); 00268 void Add2DRectilinearCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00269 const int extent[6]); 00271 00273 00274 void Add1DSphericalCoordinates(vtkPoints *points, const int extent[6]); 00275 void Add2DSphericalCoordinates(vtkPoints *points, const int extent[6]); 00276 void Add1DSphericalCoordinates(vtkStructuredGrid *structuredOutput); 00277 void Add2DSphericalCoordinates(vtkStructuredGrid *structuredOutput); 00278 void Add1DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00279 const int extent[6]); 00280 void Add2DSphericalCoordinates(vtkUnstructuredGrid *unstructuredOutput, 00281 const int extent[6]); 00283 00285 00287 void AddStructuredCells(vtkUnstructuredGrid *unstructuredOutput, 00288 const int extent[6]); 00290 00292 00293 void AddUnstructuredRectilinearCoordinates( 00294 vtkUnstructuredGrid *unstructuredOutput, 00295 const int extent[6]); 00296 void AddUnstructuredSphericalCoordinates( 00297 vtkUnstructuredGrid *unstructuredOutput, 00298 const int extent[6]); 00300 00301 00302 private: 00303 vtkNetCDFCFReader(const vtkNetCDFCFReader &); // Not implemented 00304 void operator=(const vtkNetCDFCFReader &); // Not implemented 00305 }; 00306 00307 #endif //__vtkNetCDFCFReader_h 00308