00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(MESH_READER_HPP)
00012 #define MESH_READER_HPP
00013 #include "gtypes.h"
00014 #include "gdd_file.h"
00015 #include "gtbuffer.hpp"
00016 #include "point.hpp"
00017 #include <iostream.h>
00018 #include <fstream.h>
00019 #include <limits.h>
00020
00021 extern char *serror_[] ;
00022 enum ERRNO {
00023 ERRNONE , ERREOF , ERRFILENAME,
00024 ERRHEADER , ERRFILETYPE, ERRCORRUPT,
00025 ERRDIMENSION, ERRNODATA , ERRNOFILE ,
00026 ERRMISC , ERRMALLOC , ERRDATANOTFND,
00027 ERRBADDATA , ERRHAVEDATA
00028 };
00029
00030 class MeshReader
00031 {
00032 public:
00033 MeshReader(GLONG maxbuff=7500000);
00034
00035 ~MeshReader();
00036 GBOOL Open(const char *);
00037 void Close();
00038 void SetProc(GSHORT id);
00039 void bGetNodeIDs(GBOOL bid);
00040 const char *Error();
00041 GSHORT ErrorID();
00042 GSHORT GetNumRetrieved();
00043 GSHORT GetGlobalVerts(Point *&verts, GINT &nverts);
00044 GSHORT GetNumElements();
00045 GLONG GetDynRange();
00046 GSHORT GetTotNumElements();
00047 GSHORT GetNumProcs();
00048 GSHORT GetDim();
00049 GSHORT GetElem(ELEMTYPE &etype, Point3D *&vertex, GSHORT *&bdyn, GLONG *&xN,
00050 GLBuffer *&node_ids, GLBuffer *&bdy_nodes, GBTBuffer *&bct );
00051
00052 private:
00053
00054 GBOOL ReadHeader();
00055 GSHORT GetElemData(GSHORT &elemid, GSHORT &procid, ELEMTYPE &etype, Point3D *&vertex,
00056 GSHORT *&bdyn, GLONG *&xN, GLBuffer *&node_ids, GLBuffer *&bdy_nodes,
00057 GBTBuffer *&bct, const GBOOL bautofill);
00058 GBOOL LocateProcID();
00059 GLONG getdata_t(char *sdata, G_DATATYPE dtype, const char *datadelim, const char *termdelim,
00060 void *data, const GLONG ndata);
00061 GLONG getline(char *sbuff, const GLONG num, const char *delim);
00062 GBOOL getblock(char *sbuff, GLONG num, char *delim0, char *delim1);
00063 GBOOL ignore(const char *str);
00064 GBOOL skipblock(const char *delim0, const char *delim1);
00065 GBOOL skiptoblock(const char *blk_delim, const char *header_delim);
00066
00067
00068 GDD_FILE_TYPE ftype_;
00069 GLONG buffsize_;
00070 GBOOL bnodes_;
00071 GBOOL blocated_;
00072 GBOOL bGetNodeIDs_;
00073 ERRNO ierror_;
00074 GSHORT procid_;
00075 GSHORT nd_;
00076 GSHORT np_;
00077 GSHORT ne_;
00078 GLONG nrng_;
00079 GSHORT ientry_;
00080 GSHORT *elemperproc_;
00081 GSHORT ngverts_;
00082 Point *gverts_;
00083 char *buff_;
00084 char *filename_;
00085 char delimelem_[2][DELIM_MAX+1];
00086 char delimproc_[2][DELIM_MAX+1];
00087 char delimeol_ [DELIM_MAX+1];
00088 char delimlist_ [DELIM_MAX+1];
00089 ifstream *os_;
00090
00091 };
00092
00093 #endif