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

IO/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 =========================================================================*/
00035 #ifndef __vtkAVSucdReader_h
00036 #define __vtkAVSucdReader_h
00037 
00038 #include "vtkUnstructuredGridSource.h"
00039 
00040 class vtkCellArray;
00041 class vtkIntArray;
00042 class vtkFloatArray;
00043 class vtkIdTypeArray;
00044 class vtkDataArraySelection;
00045 
00046 struct DataInfo {
00047   long foffset; // offset in binary file
00048   int veclen;   // number of components in the node or cell variable
00049 };
00050 
00051 class VTK_IO_EXPORT vtkAVSucdReader : public vtkUnstructuredGridSource
00052 {
00053 public:
00054   static  vtkAVSucdReader *New();
00055   vtkTypeRevisionMacro(vtkAVSucdReader,vtkUnstructuredGridSource);
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 protected:
00129   vtkAVSucdReader();
00130   ~vtkAVSucdReader();
00131   void ExecuteInformation();
00132   void Execute();
00133 
00134   char *FileName;
00135   int BinaryFile;
00136 
00137   int NumberOfNodes;
00138   int NumberOfCells;
00139   int NumberOfNodeFields;
00140   int NumberOfNodeComponents;
00141   int NumberOfCellComponents;
00142   int NumberOfCellFields;
00143   int NumberOfFields;
00144   int nlist_nodes;
00145 
00146   ifstream *fs;
00147 
00148   vtkDataArraySelection* PointDataArraySelection;
00149   vtkDataArraySelection* CellDataArraySelection;
00150 
00151   DataInfo *NodeDataInfo;
00152   DataInfo *CellDataInfo;
00153 
00154   int DecrementNodeIds;
00155   int ByteOrder;
00156   int get_label(char *string, int number, char *label);
00157   //BTX
00158   enum
00159   {
00160     FILE_BIG_ENDIAN=0,
00161     FILE_LITTLE_ENDIAN=1
00162   };
00163   enum UCDCell_type
00164   {
00165     PT    = 0,
00166     LINE  = 1,
00167     TRI   = 2,
00168     QUAD  = 3,
00169     TET   = 4,
00170     PYR   = 5,
00171     PRISM = 6,
00172     HEX   = 7
00173   };
00174   //ETX
00175 
00176  private:
00177   void ReadFile();
00178   void ReadGeometry();
00179   void ReadNodeData();
00180   void ReadCellData();
00181 
00182   int ReadFloatBlock(int n, float *block);
00183   int ReadIntBlock(int n, int *block);
00184   void ReadXYZCoords(vtkFloatArray *coords);
00185   void ReadBinaryCellTopology(vtkIntArray *material, int *types, 
00186                               vtkIdTypeArray *listcells);
00187   void ReadASCIICellTopology(vtkIntArray *material, vtkUnstructuredGrid *output);
00188 
00189   vtkAVSucdReader(const vtkAVSucdReader&);  // Not implemented.
00190   void operator=(const vtkAVSucdReader&);  // Not implemented.
00191 };
00192 
00193 #endif