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