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