VTK
dox/IO/NetCDF/vtkMPASReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMPASReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010   This software is distributed WITHOUT ANY WARRANTY; without even
00011   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012   PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*=========================================================================
00016 
00017 Copyright (c) 2002-2005 Los Alamos National Laboratory
00018 
00019 This software and ancillary information known as vtk_ext (and herein
00020 called "SOFTWARE") is made available under the terms described below.
00021 The SOFTWARE has been approved for release with associated LA_CC
00022 Number 99-44, granted by Los Alamos National Laboratory in July 1999.
00023 
00024 Unless otherwise indicated, this SOFTWARE has been authored by an
00025 employee or employees of the University of California, operator of the
00026 Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
00027 the United States Department of Energy.
00028 
00029 The United States Government has rights to use, reproduce, and
00030 distribute this SOFTWARE.  The public may copy, distribute, prepare
00031 derivative works and publicly display this SOFTWARE without charge,
00032 provided that this Notice and any statement of authorship are
00033 reproduced on all copies.
00034 
00035 Neither the U. S. Government, the University of California, nor the
00036 Advanced Computing Laboratory makes any warranty, either express or
00037 implied, nor assumes any liability or responsibility for the use of
00038 this SOFTWARE.
00039 
00040 If SOFTWARE is modified to produce derivative works, such modified
00041 SOFTWARE should be clearly marked, so as not to confuse it with the
00042 version available from Los Alamos National Laboratory.
00043 
00044 =========================================================================*/
00080 #ifndef __vtkMPASReader_h
00081 #define __vtkMPASReader_h
00082 
00083 #define MAX_VARS 100
00084 #define MAX_VAR_NAME 100
00085 
00086 #include "vtkIONetCDFModule.h" // For export macro
00087 #include "vtkUnstructuredGridAlgorithm.h"
00088 
00089 class vtkCallbackCommand;
00090 class vtkDataArraySelection;
00091 class vtkDoubleArray;
00092 class vtkStdString;
00093 class vtkStringArray;
00094 
00095 class VTKIONETCDF_EXPORT vtkMPASReader : public vtkUnstructuredGridAlgorithm
00096 {
00097  public:
00098   static vtkMPASReader *New();
00099   vtkTypeMacro(vtkMPASReader,vtkUnstructuredGridAlgorithm);
00100   void PrintSelf(ostream& os, vtkIndent indent);
00101 
00103 
00104   vtkSetStringMacro(FileName);
00105   vtkGetStringMacro(FileName);
00107 
00109 
00110   vtkGetMacro(MaximumCells, int);
00112 
00114 
00115   vtkGetMacro(MaximumPoints, int);
00117 
00119 
00120   vtkGetMacro(NumberOfCellVars, int);
00121   vtkGetMacro(NumberOfPointVars, int);
00123 
00125 
00126   vtkUnstructuredGrid *GetOutput();
00127   vtkUnstructuredGrid *GetOutput(int index);
00129 
00131 
00134   int GetNumberOfPointArrays();
00135   const char* GetPointArrayName(int index);
00136   int GetPointArrayStatus(const char* name);
00137   void SetPointArrayStatus(const char* name, int status);
00138   void DisableAllPointArrays();
00139   void EnableAllPointArrays();
00141 
00142   int GetNumberOfCellArrays();
00143   const char* GetCellArrayName(int index);
00144   int GetCellArrayStatus(const char* name);
00145   void SetCellArrayStatus(const char* name, int status);
00146   void DisableAllCellArrays();
00147   void EnableAllCellArrays();
00148 
00149   void SetVerticalLevel(int level);
00150   vtkGetVector2Macro(VerticalLevelRange, int);
00151 
00152   void SetLayerThickness(int val);
00153   vtkGetVector2Macro(LayerThicknessRange, int);
00154 
00155   void SetCenterLon(int val);
00156   vtkGetVector2Macro(CenterLonRange, int);
00157 
00158   void SetProjectLatLon(bool val);
00159   vtkGetMacro(ProjectLatLon, bool);
00160 
00161   void SetIsAtmosphere(bool val);
00162   vtkGetMacro(IsAtmosphere, bool);
00163 
00164   void SetIsZeroCentered(bool val);
00165   vtkGetMacro(IsZeroCentered, bool);
00166 
00167   void SetShowMultilayerView(bool val);
00168   vtkGetMacro(ShowMultilayerView, bool);
00169 
00171   static int CanReadFile(const char *filename);
00172 
00173  protected:
00174   vtkMPASReader();
00175   ~vtkMPASReader();
00176   void DestroyData();
00177 
00178   char *FileName;         // First field part file giving path
00179   /*
00180     int Rank;               // Number of this processor
00181     int TotalRank;          // Number of processors
00182   */
00183 
00184   //  int NumberOfPieces;         // Number of files in dataset
00185   // vtkIdType NumberOfTuples;        // Number of tuples in sub extent
00186 
00187   vtkStdString* VariableName;     // Names of each variable
00188   int* VariableType;          // Scalar, vector or tensor
00189 
00190   int NumberOfTimeSteps;      // Temporal domain
00191   double* TimeSteps;          // Times available for request
00192   double DTime;
00193 
00194 
00195   // Observer to modify this object when array selections are modified
00196   vtkCallbackCommand* SelectionObserver;
00197 
00198   int RequestData(vtkInformation *, vtkInformationVector **,
00199                   vtkInformationVector *);
00200   int RequestInformation(vtkInformation *, vtkInformationVector **,
00201                          vtkInformationVector *);
00202 
00203 
00204   static void SelectionCallback(vtkObject* caller, unsigned long eid,
00205                                 void* clientdata, void* calldata);
00206 
00207   bool InfoRequested;
00208   bool DataRequested;
00209 
00210   // params
00211 
00212   // Selected field of interest
00213   vtkDataArraySelection* PointDataArraySelection;
00214   vtkDataArraySelection* CellDataArraySelection;
00215 
00216   vtkDoubleArray** CellVarDataArray;    // Actual data arrays
00217   vtkDoubleArray** PointVarDataArray;   // Actual data arrays
00218 
00219   int VerticalLevelSelected;
00220   int VerticalLevelRange[2];
00221 
00222   int LayerThickness;
00223   int LayerThicknessRange[2];
00224 
00225   int CenterLon;
00226   int CenterLonRange[2];
00227 
00228   bool ProjectLatLon;
00229   bool IsAtmosphere;
00230   bool IsZeroCentered;
00231   bool ShowMultilayerView;
00232 
00233   bool IncludeTopography;
00234   bool DoBugFix;
00235   double CenterRad;
00236 
00237 
00238   // geometry
00239   int MaximumNVertLevels;
00240   int NumberOfCells;
00241   int NumberOfPoints;
00242   int CellOffset;
00243   int PointOffset;
00244   int PointsPerCell;
00245   int CurrentExtraPoint;  // current extra point
00246   int CurrentExtraCell;   // current extra  cell
00247   double* PointX;      // x coord of point
00248   double* PointY;      // y coord of point
00249   double* PointZ;      // z coord of point
00250   int ModNumPoints;
00251   int ModNumCells;
00252   int* CellMask;
00253   int* OrigConnections;   // original connections
00254   int* ModConnections;    // modified connections
00255   int* CellMap;           // maps from added cell to original cell #
00256   int* PointMap;          // maps from added point to original point #
00257   int* MaximumLevelPoint;      //
00258   int MaximumCells;           // max cells
00259   int MaximumPoints;          // max points
00260   int VerticalIndex;      // for singleLayer, which vertical level
00261 
00262   // vars
00263   int NumberOfCellVars;
00264   int NumberOfPointVars;
00265   double* PointVarData;
00266 
00267   void SetDefaults();
00268   int GetNcDims();
00269   int CheckParams();
00270   int GetNcVars(const char* cellDimName, const char* pointDimName);
00271   int ReadAndOutputGrid(bool init);
00272   int ReadAndOutputVariableData();
00273   int BuildVarArrays();
00274   int AllocSphereGeometry();
00275   int AllocLatLonGeometry();
00276   void ShiftLonData();
00277   int AddMirrorPoint(int index, double dividerX);
00278   void FixPoints();
00279   int EliminateXWrap();
00280   void OutputPoints(bool init);
00281   void OutputCells(bool init);
00282   unsigned char GetCellType();
00283   void LoadGeometryData(int var, double dTime);
00284   int LoadPointVarData(int variable, double dTime);
00285   int LoadCellVarData(int variable, double dTime);
00286   int RegenerateGeometry();
00287 
00288  private:
00289   vtkMPASReader(const vtkMPASReader&);    // Not implemented.
00290   void operator=(const vtkMPASReader&); // Not implemented.
00291   class Internal;
00292   Internal *Internals;
00293 
00294 };
00295 
00296 #endif