Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkAVSucdReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkAVSucdReader.h,v $
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 =========================================================================*/
00049 #ifndef __vtkAVSucdReader_h
00050 #define __vtkAVSucdReader_h
00051 
00052 #include "vtkUnstructuredGridSource.h"
00053 
00054 class vtkIntArray;
00055 class vtkFloatArray;
00056 class vtkIdTypeArray;
00057 class vtkDataArraySelection;
00058 
00059 class VTK_IO_EXPORT vtkAVSucdReader : public vtkUnstructuredGridSource
00060 {
00061 public:
00062   static vtkAVSucdReader *New();
00063   vtkTypeRevisionMacro(vtkAVSucdReader,vtkUnstructuredGridSource);
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00067 
00068   vtkSetStringMacro(FileName);
00069   vtkGetStringMacro(FileName);
00071 
00073 
00075   vtkSetMacro(BinaryFile, int);
00076   vtkGetMacro(BinaryFile, int);
00077   vtkBooleanMacro(BinaryFile, int);
00079 
00081 
00082   vtkGetMacro(NumberOfCells,int);
00084 
00086 
00087   vtkGetMacro(NumberOfNodes,int);
00089 
00091 
00092   vtkGetMacro(NumberOfNodeFields,int);
00094 
00096 
00097   vtkGetMacro(NumberOfCellFields,int);
00099 
00101 
00103   vtkGetMacro(NumberOfFields,int);
00105 
00107 
00108   vtkGetMacro(NumberOfNodeComponents,int);
00109   vtkGetMacro(NumberOfCellComponents,int);
00111 
00113 
00114   void SetByteOrderToBigEndian();
00115   void SetByteOrderToLittleEndian();
00116   const char *GetByteOrderAsString();
00118 
00119   vtkSetMacro(ByteOrder, int);
00120   vtkGetMacro(ByteOrder, int);
00121 
00123 
00126   int GetNumberOfPointArrays();
00127   int GetNumberOfCellArrays();
00128   const char* GetPointArrayName(int index);
00129   const char* GetCellArrayName(int index);
00130   int GetPointArrayStatus(const char* name);
00131   int GetCellArrayStatus(const char* name);
00132   void SetPointArrayStatus(const char* name, int status);  
00133   void SetCellArrayStatus(const char* name, int status);
00135 
00136   void DisableAllCellArrays();
00137   void EnableAllCellArrays();
00138   void DisableAllPointArrays();
00139   void EnableAllPointArrays();
00140 
00141   // get min and max value for the index-th value of a cell component
00142   // index varies from 0 to (veclen - 1)
00143   void GetCellDataRange(int cellComp, int index, float *min, float *max);
00144 
00145   // get min and max value for the index-th value of a node component
00146   // index varies from 0 to (veclen - 1)
00147   void GetNodeDataRange(int nodeComp, int index, float *min, float *max);
00148 
00149 protected:
00150   vtkAVSucdReader();
00151   ~vtkAVSucdReader();
00152   void ExecuteInformation();
00153   void Execute();
00154 
00155   char *FileName;
00156   int BinaryFile;
00157 
00158   int NumberOfNodes;
00159   int NumberOfCells;
00160   int NumberOfNodeFields;
00161   int NumberOfNodeComponents;
00162   int NumberOfCellComponents;
00163   int NumberOfCellFields;
00164   int NumberOfFields;
00165   int NlistNodes;
00166 
00167   ifstream *FileStream;
00168 
00169   vtkDataArraySelection* PointDataArraySelection;
00170   vtkDataArraySelection* CellDataArraySelection;
00171 
00172   int DecrementNodeIds;
00173   int ByteOrder;
00174   int GetLabel(char *string, int number, char *label);
00175   //BTX
00176   enum
00177   {
00178     FILE_BIG_ENDIAN=0,
00179     FILE_LITTLE_ENDIAN=1
00180   };
00181   enum UCDCell_type
00182   {
00183     PT    = 0,
00184     LINE  = 1,
00185     TRI   = 2,
00186     QUAD  = 3,
00187     TET   = 4,
00188     PYR   = 5,
00189     PRISM = 6,
00190     HEX   = 7
00191   };
00192 
00193   struct DataInfo {
00194     long foffset; // offset in binary file
00195     int  veclen;   // number of components in the node or cell variable
00196     float min;    // pre-calculated data min stored in UCD file
00197     float max;    // pre-calculated data max stored in UCD file
00198   };
00199   //ETX
00200 
00201   DataInfo *NodeDataInfo;
00202   DataInfo *CellDataInfo;
00203 
00204 private:
00205   void ReadFile();
00206   void ReadGeometry();
00207   void ReadNodeData();
00208   void ReadCellData();
00209 
00210   int ReadFloatBlock(int n, float *block);
00211   int ReadIntBlock(int n, int *block);
00212   void ReadXYZCoords(vtkFloatArray *coords);
00213   void ReadBinaryCellTopology(vtkIntArray *material, int *types, 
00214                               vtkIdTypeArray *listcells);
00215   void ReadASCIICellTopology(vtkIntArray *material, vtkUnstructuredGrid *output);
00216 
00217   vtkAVSucdReader(const vtkAVSucdReader&);  // Not implemented.
00218   void operator=(const vtkAVSucdReader&);  // Not implemented.
00219 };
00220 
00221 #endif