#include <hdf5writer.h>
Classes | |
struct | FieldInformation |
struct | TriaInformation |
Public Member Functions | |
HDF5Writer () | |
~HDF5Writer () | |
hid_t | getFile () |
void | setVariable (std::string var, std::string value) |
void | setVariable (std::string var, double dValue) |
void | setOutputFile (string strFileName) |
void | close () |
bool | existTriaInformation (string strName) |
void | setAtt (string objPath, string attName, string value) |
void | setAtt (string objPath, string attName, double dValue) |
void | writeInt (string objPath, string attName, int i) |
void | writeGrp (string grpName) |
std::string | getVariableValue (std::string var) |
std::string | getFileName () |
Protected Types | |
enum | TriaType { UNSTRUCTURED_GRID, STRUCTURED_GRID } |
typedef Dictionary::const_iterator | VariableIterator |
Protected Member Functions | |
TriaInformation & | getTriaInformation (string strName) |
void | writeInChunks (hid_t dataset, hsize_t offset[], hsize_t count[], void *buff) |
FieldInformation & | getFieldInfo (std::string fileName) |
void | writeContextVariables (std::string dataSetPath) |
void | validateField (string triaId, string fieldName) |
std::string | getNameOfLastRegisteredTriangulation () |
int | getFieldCount (string fieldName) |
void | incFieldCount (string fieldName) |
VariableIterator | getVariablesIterator () |
VariableIterator | getVariablesEnd () |
void | appendMeshInfo (string triaId, struct TriaInformation info) |
void | putMeshIntoDictionary (string triaId, unsigned verts, unsigned cells) |
Private Types | |
typedef __gnu_cxx::hash_map < string, struct TriaInformation, StringHashFun, struct eqstr > | TriaHeap |
typedef __gnu_cxx::hash_map < string, struct FieldInformation, StringHashFun, struct eqstr > | FieldInfoHeap |
Private Attributes | |
hid_t | m_file |
Dictionary | varsHeap |
TriaHeap | triaHeap |
FieldInfoHeap | fieldInfo |
string | m_strFileName |
string | m_lastTriaName |
Definition at line 22 of file hdf5writer.h.
typedef __gnu_cxx::hash_map<string,struct FieldInformation,StringHashFun,struct eqstr> HDF5Writer::FieldInfoHeap [private] |
Definition at line 78 of file hdf5writer.h.
typedef __gnu_cxx::hash_map<string,struct TriaInformation,StringHashFun,struct eqstr> HDF5Writer::TriaHeap [private] |
Definition at line 77 of file hdf5writer.h.
typedef Dictionary::const_iterator HDF5Writer::VariableIterator [protected] |
Definition at line 91 of file hdf5writer.h.
enum HDF5Writer::TriaType [protected] |
Definition at line 26 of file hdf5writer.h.
00026 {UNSTRUCTURED_GRID,STRUCTURED_GRID};
HDF5Writer::HDF5Writer | ( | ) |
Definition at line 7 of file hdf5writer.cpp.
00008 { 00009 m_file =-1; 00010 H5Eset_auto2(H5E_DEFAULT,(herr_t (*)(hid_t,void*)) &H5Eprint,stdout); 00011 00012 }
HDF5Writer::~HDF5Writer | ( | ) |
Definition at line 30 of file hdf5writer.cpp.
00031 { 00032 close(); 00033 }
void HDF5Writer::appendMeshInfo | ( | string | triaId, | |
struct TriaInformation | info | |||
) | [protected] |
Definition at line 165 of file hdf5writer.cpp.
00166 { 00167 triaHeap[triaId]=info; 00168 m_lastTriaName = triaId; 00169 00170 }
void HDF5Writer::close | ( | ) |
Reimplemented in HDF5OrthoWriter.
Definition at line 23 of file hdf5writer.cpp.
bool HDF5Writer::existTriaInformation | ( | string | strName | ) |
Definition at line 102 of file hdf5writer.cpp.
int HDF5Writer::getFieldCount | ( | string | fieldName | ) | [protected] |
FieldInformation& HDF5Writer::getFieldInfo | ( | std::string | fileName | ) | [inline, protected] |
Definition at line 93 of file hdf5writer.h.
00093 {return fieldInfo[fileName];}
hid_t HDF5Writer::getFile | ( | ) | [inline] |
Definition at line 106 of file hdf5writer.h.
std::string HDF5Writer::getFileName | ( | ) | [inline] |
Definition at line 117 of file hdf5writer.h.
00117 {return m_strFileName;}
std::string HDF5Writer::getNameOfLastRegisteredTriangulation | ( | ) | [inline, protected] |
Definition at line 96 of file hdf5writer.h.
00096 {return m_lastTriaName;}
HDF5Writer::TriaInformation & HDF5Writer::getTriaInformation | ( | string | strName | ) | [protected] |
Get the triangulation information. If the triangulation is not found, an exception is raised.
strName | The name of the triangulation |
Definition at line 96 of file hdf5writer.cpp.
HDF5Writer::VariableIterator HDF5Writer::getVariablesEnd | ( | ) | [protected] |
Definition at line 146 of file hdf5writer.cpp.
00147 { 00148 return this->varsHeap.end(); 00149 }
HDF5Writer::VariableIterator HDF5Writer::getVariablesIterator | ( | ) | [protected] |
This is the method used to get the iterator pointing to the beginning of the variables list. To get the name of the variable that the iterator it is ponting use it->first and to get its value you should use it->second. An example of its use can be seen in the method HDF5HDF5Writer::writeContextVariables .
Definition at line 141 of file hdf5writer.cpp.
00142 { 00143 return this->varsHeap.begin(); 00144 }
std::string HDF5Writer::getVariableValue | ( | std::string | var | ) |
Definition at line 71 of file hdf5writer.cpp.
00072 { 00073 return varsHeap[var]; 00074 }
void HDF5Writer::incFieldCount | ( | string | fieldName | ) | [protected] |
void HDF5Writer::putMeshIntoDictionary | ( | string | triaId, | |
unsigned | verts, | |||
unsigned | cells | |||
) | [protected] |
Write mesh information.
triaId | Name of the mesh | |
verts | Number of vertices of the mesh | |
cells | Number of cells | |
type | Type of triangulation |
Definition at line 200 of file hdf5writer.cpp.
00201 { 00202 appendMeshInfo(triaId,TriaInformation(verts,cells)); 00203 00204 }
void HDF5Writer::setAtt | ( | string | objPath, | |
string | attName, | |||
double | dValue | |||
) |
Definition at line 218 of file hdf5writer.cpp.
00219 { 00220 char value[100]; 00221 sprintf(value,"%g",dValue); 00222 herr_t error = H5LTset_attribute_string(getFile(),objPath.c_str(),attName.c_str(),value); 00223 if (error < 0) 00224 throw new Exception("HDF5OrthoWriter::setAtt error trying to set attribute \"%s/%s\"",objPath.c_str(),attName.c_str()); 00225 }
void HDF5Writer::setAtt | ( | string | objPath, | |
string | attName, | |||
string | value | |||
) |
Definition at line 209 of file hdf5writer.cpp.
void HDF5Writer::setOutputFile | ( | string | strFileName | ) |
Definition at line 14 of file hdf5writer.cpp.
00015 { 00016 m_strFileName=strFileName; 00017 m_file = H5Fcreate(strFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 00018 H5Gclose(H5Gcreate1(m_file,"/DataSets",0)); 00019 H5Gclose(H5Gcreate1(m_file,"/Triangulations",0)); 00020 }
void HDF5Writer::setVariable | ( | std::string | var, | |
double | dValue | |||
) |
Definition at line 77 of file hdf5writer.cpp.
00078 { 00079 char str[100]; 00080 sprintf(str,"%g",dValue); 00081 setVariable(var,str); 00082 }
void HDF5Writer::setVariable | ( | std::string | var, | |
std::string | value | |||
) |
Definition at line 66 of file hdf5writer.cpp.
00067 { 00068 varsHeap[var]=value; 00069 }
void HDF5Writer::validateField | ( | string | triaId, | |
string | fieldName | |||
) | [protected] |
This method validates the name of a field associated with a given triangulation name, It checks if the triangulation referenced by the field exist, check if the fieldName is not already used to define a variable name (see HDF5Writer::setVariable) or a triangulation name
triaId | ||
fieldName |
Definition at line 44 of file hdf5writer.cpp.
00045 { 00046 if ( varsHeap.find(fieldName) != varsHeap.end()) 00047 { 00048 printf("HDF5Writer: Field name %s already defined as a variable\n",fieldName.c_str()); 00049 abort(); 00050 } 00051 if (triaHeap.find(fieldName) != triaHeap.end()) 00052 { 00053 printf("HDF5Writer: Field name %s already defined as a triangulation\n",fieldName.c_str()); 00054 abort(); 00055 } 00056 if (triaHeap.find(triaId) == triaHeap.end()) 00057 { 00058 printf("HDF5Writer: Triangulation \"%s\" referenced by field %s not defined\n",triaId.c_str(),fieldName.c_str()); 00059 abort(); 00060 } 00061 00062 }
void HDF5Writer::writeContextVariables | ( | std::string | dataSetPath | ) | [protected] |
Definition at line 153 of file hdf5writer.cpp.
00154 { 00155 assert(m_file != -1); 00156 //Para todas as variaveis 00157 for (HDF5Writer::VariableIterator it = getVariablesIterator();it != getVariablesEnd();it++) 00158 { 00159 H5LTset_attribute_string(m_file,dataSetPath.c_str(),it->first.c_str(),it->second.c_str()); 00160 } 00161 00162 }
void HDF5Writer::writeGrp | ( | string | grpName | ) |
void HDF5Writer::writeInChunks | ( | hid_t | dataset, | |
hsize_t | offset[], | |||
hsize_t | count[], | |||
void * | buff | |||
) | [protected] |
Definition at line 173 of file hdf5writer.cpp.
00174 { 00175 if (!count[0]) 00176 return; 00177 hid_t dataspace = H5Dget_space(dataset); 00178 H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL,count, NULL); 00179 00180 hid_t datatype = H5Dget_type(dataset); 00181 00182 hsize_t dim[]={count[0],count[1]}; 00183 hid_t memspace = H5Screate_simple(2,dim,NULL); 00184 00185 int error = H5Dwrite(dataset,datatype,memspace,dataspace,H5P_DEFAULT,buff); 00186 assert(error >=0); 00187 00188 H5Sclose(memspace); 00189 H5Sclose(dataspace); 00190 H5Tclose(datatype); 00191 }
void HDF5Writer::writeInt | ( | string | objPath, | |
string | attName, | |||
int | i | |||
) |
FieldInfoHeap HDF5Writer::fieldInfo [private] |
Reference count for each field name.
Definition at line 82 of file hdf5writer.h.
hid_t HDF5Writer::m_file [private] |
File to store the data
Definition at line 75 of file hdf5writer.h.
string HDF5Writer::m_lastTriaName [private] |
This string contains the name of the last triangulation inserted with the method registerTriangulation()
Definition at line 85 of file hdf5writer.h.
string HDF5Writer::m_strFileName [private] |
The filename of the hdf5 file
Definition at line 84 of file hdf5writer.h.
TriaHeap HDF5Writer::triaHeap [private] |
Map of all the triangulations registered
Definition at line 81 of file hdf5writer.h.
Dictionary HDF5Writer::varsHeap [private] |
Map that contains all variable values
Definition at line 80 of file hdf5writer.h.