#include <hdf5orthoreader.h>
Public Member Functions | |
HDF5OrthoReader (bool debuginfo=false) | |
OrthoMesh & | getMesh (string strMeshName) |
void | readScalars (VecDouble &vec, std::string dataSetName) |
hid_t | getFile () |
~HDF5OrthoReader () | |
OrthoMesh * | loadOrthoMesh (std::string strMeshName) |
void | iterateTree (hid_t id, HDF5Operator &op) |
void | list () |
Protected Member Functions | |
HDF5OrthoInfo | readOrthoMeshInfo (hid_t triaGroup) |
Private Types | |
typedef __gnu_cxx::hash_map < string, OrthoMesh *, StringHashFun, struct eqstr > | MeshHeap |
Private Attributes | |
MeshHeap | _meshCash |
HDF5OrthoRead
Definition at line 19 of file hdf5orthoreader.h.
typedef __gnu_cxx::hash_map<string,OrthoMesh*,StringHashFun,struct eqstr> HDF5OrthoReader::MeshHeap [private] |
Definition at line 22 of file hdf5orthoreader.h.
HDF5OrthoReader::HDF5OrthoReader | ( | bool | debuginfo = false |
) |
Definition at line 4 of file hdf5orthoreader.cpp.
00005 { 00006 m_file =-1; 00007 if (!debuginfo) 00008 { 00009 H5Eset_auto(H5E_DEFAULT,NULL,stderr); 00010 H5Eset_auto(H5E_DEFAULT,NULL,stdout); 00011 } 00012 00013 }
HDF5OrthoReader::~HDF5OrthoReader | ( | ) | [inline] |
Definition at line 32 of file hdf5orthoreader.h.
hid_t HDF5OrthoReader::getFile | ( | ) |
Definition at line 45 of file hdf5orthoreader.cpp.
OrthoMesh & HDF5OrthoReader::getMesh | ( | string | strMeshName | ) |
Definition at line 17 of file hdf5orthoreader.cpp.
void HDF5OrthoReader::iterateTree | ( | hid_t | id, | |
HDF5Operator & | op | |||
) |
Definition at line 72 of file hdf5orthoreader.cpp.
00073 { 00074 00075 switch(H5Iget_type(id)) 00076 { 00077 case H5I_GROUP: 00078 { 00079 char strElem[STR_SIZE]; 00080 hsize_t nElems; 00081 00082 op.processGroup(id); 00083 00084 //Iterate among all attributes 00085 unsigned nAtts = H5Aget_num_attrs(id); 00086 for (unsigned i=0;i<nAtts;i++) 00087 { 00088 hid_t attId = H5Aopen_idx(id,i); 00089 iterateTree(attId,op); 00090 H5Aclose(attId); 00091 } 00092 H5Gget_num_objs(id,&nElems); 00093 for(unsigned i=0;i<nElems;i++) 00094 { 00095 H5Gget_objname_by_idx(id,i,strElem,STR_SIZE); 00096 hsize_t type =H5Gget_objtype_by_idx(id,i); 00097 switch(type) 00098 { 00099 case H5G_LINK: 00100 { 00101 printf("Ignoring link %s\n",strElem); 00102 break; 00103 } 00104 case H5G_GROUP: 00105 { 00106 hid_t idChild=H5Gopen(id,strElem,H5P_DEFAULT); 00107 iterateTree(idChild,op); 00108 closeId(idChild); 00109 break; 00110 } 00111 case H5G_DATASET: 00112 { 00113 hid_t idChild=H5Dopen(id,strElem,H5P_DEFAULT); 00114 iterateTree(idChild,op); 00115 closeId(idChild); 00116 break; 00117 } 00118 case H5G_TYPE: 00119 { 00120 printf("Ignoring type %s\n",strElem); 00121 break; 00122 } 00123 } 00124 } 00125 break; 00126 } 00127 case H5I_DATASET: 00128 { 00129 op.processDataSet(id); 00130 //Iterate among all attributes 00131 unsigned nAtts = H5Aget_num_attrs(id); 00132 for (unsigned i=0;i<nAtts;i++) 00133 { 00134 hid_t attId = H5Aopen_idx(id,i); 00135 iterateTree(attId,op); 00136 H5Aclose(attId); 00137 } 00138 break; 00139 } 00140 case H5I_ATTR: 00141 { 00142 op.processAtt(id); 00143 break; 00144 } 00145 default: 00146 { 00147 throw new Exception("HDF5OrthoReader::iterateTree() Expect HDF5 object to be a dataset, a group or attribute"); 00148 } 00149 } 00150 }
void HDF5OrthoReader::list | ( | ) |
Definition at line 52 of file hdf5orthoreader.cpp.
00053 { 00054 hid_t triaG = openGroup("Triangulations"); 00055 hid_t test = H5Gopen1(triaG,"./tria0"); 00056 char name2[1000]; 00057 H5Iget_name(test,name2,1000); 00058 printf("Test %s\n",name2); 00059 hsize_t numObjs; 00060 H5Gget_num_objs(triaG,&numObjs); 00061 for (unsigned i =0;i<numObjs;i++) 00062 { 00063 char name[1000]; 00064 H5Gget_objname_by_idx(triaG,i,name,1000); 00065 printf("%s\n",name); 00066 } 00067 00068 }
OrthoMesh * HDF5OrthoReader::loadOrthoMesh | ( | std::string | strMeshName | ) |
Definition at line 31 of file hdf5orthoreader.cpp.
00032 { 00033 char path[500]; 00034 sprintf(path,"Triangulations/%s",strMeshName.c_str()); 00035 hid_t Gtria = H5Gopen1(getFile(),path); 00036 if (Gtria < 0) 00037 throw new Exception("HDF5OrthoReader::loadOrthoMesh Could not find mesh \"%s\"",path); 00038 HDF5OrthoInfo info; 00039 info.readOrthoMeshInfo(Gtria); 00040 OrthoMesh* pMesh = new OrthoMesh(info.P0,info.P1,info.nElems[0],info.nElems[1],info.nElems[2],info.wells); 00041 return pMesh; 00042 }
HDF5OrthoInfo HDF5OrthoReader::readOrthoMeshInfo | ( | hid_t | triaGroup | ) | [protected] |
void HDF5OrthoReader::readScalars | ( | VecDouble & | vec, | |
std::string | dataSetName | |||
) |
Definition at line 183 of file hdf5orthoreader.cpp.
00184 { 00185 hid_t dataset=H5Dopen(getFile(),dataSetName.c_str(),H5P_DEFAULT); 00186 if (dataset < 0) 00187 throw new Exception("Could not read dataset \"%s\"",dataSetName.c_str()); 00188 00189 hid_t dataspace=H5Dget_space(dataset); 00190 unsigned rank=H5Sget_simple_extent_ndims(dataspace); 00191 hsize_t dims[rank],maxdims[rank]; 00192 H5Sget_simple_extent_dims(dataspace,dims,maxdims); 00193 unsigned nElems=dims[0]; 00194 for (unsigned i=1;i<rank;i++) 00195 { 00196 nElems*=dims[i]; 00197 } 00198 if (vec.size() != nElems) 00199 vec.reinit(nElems); 00200 //READ THE DATA 00201 H5Dread(dataset,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,vec.begin()); 00202 H5Sclose(dataspace); 00203 H5Dclose(dataset); 00204 00205 }
MeshHeap HDF5OrthoReader::_meshCash [private] |
Definition at line 23 of file hdf5orthoreader.h.