00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00038 #ifndef __vtkAVSucdReader_h
00039 #define __vtkAVSucdReader_h
00040 
00041 #include "vtkUnstructuredGridAlgorithm.h"
00042 
00043 class vtkIntArray;
00044 class vtkFloatArray;
00045 class vtkIdTypeArray;
00046 class vtkDataArraySelection;
00047 
00048 class VTK_IO_EXPORT vtkAVSucdReader : public vtkUnstructuredGridAlgorithm
00049 {
00050 public:
00051   static vtkAVSucdReader *New();
00052   vtkTypeMacro(vtkAVSucdReader,vtkUnstructuredGridAlgorithm);
00053   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00056 
00057   vtkSetStringMacro(FileName);
00058   vtkGetStringMacro(FileName);
00060 
00062 
00064   vtkSetMacro(BinaryFile, int);
00065   vtkGetMacro(BinaryFile, int);
00066   vtkBooleanMacro(BinaryFile, int);
00068 
00070 
00071   vtkGetMacro(NumberOfCells,int);
00073 
00075 
00076   vtkGetMacro(NumberOfNodes,int);
00078 
00080 
00081   vtkGetMacro(NumberOfNodeFields,int);
00083 
00085 
00086   vtkGetMacro(NumberOfCellFields,int);
00088 
00090 
00092   vtkGetMacro(NumberOfFields,int);
00094 
00096 
00097   vtkGetMacro(NumberOfNodeComponents,int);
00098   vtkGetMacro(NumberOfCellComponents,int);
00100 
00102 
00103   void SetByteOrderToBigEndian();
00104   void SetByteOrderToLittleEndian();
00105   const char *GetByteOrderAsString();
00107 
00108   vtkSetMacro(ByteOrder, int);
00109   vtkGetMacro(ByteOrder, int);
00110 
00112 
00115   int GetNumberOfPointArrays();
00116   int GetNumberOfCellArrays();
00117   const char* GetPointArrayName(int index);
00118   const char* GetCellArrayName(int index);
00119   int GetPointArrayStatus(const char* name);
00120   int GetCellArrayStatus(const char* name);
00121   void SetPointArrayStatus(const char* name, int status);  
00122   void SetCellArrayStatus(const char* name, int status);
00124 
00125   void DisableAllCellArrays();
00126   void EnableAllCellArrays();
00127   void DisableAllPointArrays();
00128   void EnableAllPointArrays();
00129 
00130   
00131   
00132   void GetCellDataRange(int cellComp, int index, float *min, float *max);
00133 
00134   
00135   
00136   void GetNodeDataRange(int nodeComp, int index, float *min, float *max);
00137 
00138 protected:
00139   vtkAVSucdReader();
00140   ~vtkAVSucdReader();
00141   int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00142   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00143 
00144   char *FileName;
00145   int BinaryFile;
00146 
00147   int NumberOfNodes;
00148   int NumberOfCells;
00149   int NumberOfNodeFields;
00150   int NumberOfNodeComponents;
00151   int NumberOfCellComponents;
00152   int NumberOfCellFields;
00153   int NumberOfFields;
00154   int NlistNodes;
00155 
00156   ifstream *FileStream;
00157 
00158   vtkDataArraySelection* PointDataArraySelection;
00159   vtkDataArraySelection* CellDataArraySelection;
00160 
00161   int DecrementNodeIds;
00162   int ByteOrder;
00163   int GetLabel(char *string, int number, char *label);
00164   
00165   enum
00166   {
00167     FILE_BIG_ENDIAN=0,
00168     FILE_LITTLE_ENDIAN=1
00169   };
00170   enum UCDCell_type
00171   {
00172     PT    = 0,
00173     LINE  = 1,
00174     TRI   = 2,
00175     QUAD  = 3,
00176     TET   = 4,
00177     PYR   = 5,
00178     PRISM = 6,
00179     HEX   = 7
00180   };
00181 
00182   struct DataInfo {
00183     long foffset; 
00184     int  veclen;  
00185     float min[3]; 
00186     float max[3]; 
00187   };
00188   
00189 
00190   DataInfo *NodeDataInfo;
00191   DataInfo *CellDataInfo;
00192 
00193 private:
00194   void ReadFile(vtkUnstructuredGrid *output);
00195   void ReadGeometry(vtkUnstructuredGrid *output);
00196   void ReadNodeData(vtkUnstructuredGrid *output);
00197   void ReadCellData(vtkUnstructuredGrid *output);
00198 
00199   int ReadFloatBlock(int n, float *block);
00200   int ReadIntBlock(int n, int *block);
00201   void ReadXYZCoords(vtkFloatArray *coords);
00202   void ReadBinaryCellTopology(vtkIntArray *material, int *types, 
00203                               vtkIdTypeArray *listcells);
00204   void ReadASCIICellTopology(vtkIntArray *material, vtkUnstructuredGrid *output);
00205 
00206   vtkAVSucdReader(const vtkAVSucdReader&);  
00207   void operator=(const vtkAVSucdReader&);  
00208 };
00209 
00210 #endif