Commit e93ca0fd authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Create a generic XdmfVisitor class and move writing operations to...

ENH: Create a generic XdmfVisitor class and move writing operations to XdmfWriter.  Incorporate Loki library to perform asymmetric visitor operation (allows customizable behavior for eventual Xdmf / NetDMF library split).  Modify Loki
Visitor to work happily with boost::shared_ptr and modify swig wrapping to properly handle boost::shared_ptr inheritance.
parent 48eedaab
......@@ -18,7 +18,7 @@ endif(HDF5_FOUND)
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
include_directories(${LIBXML2_INCLUDE_DIR})
endif(LIBXML2_FOUND)
option(XDMF_WRAP_PYTHON OFF)
......@@ -38,7 +38,7 @@ set(XdmfSources
XdmfAttributeCenter
XdmfAttributeType
XdmfDataItem
XdmfDomain
XdmfDomain
XdmfGeometry
XdmfGeometryType
XdmfGrid
......@@ -47,6 +47,7 @@ set(XdmfSources
XdmfTopology
XdmfTopologyType
XdmfVisitor
XdmfWriter
)
add_library(Xdmf ${XdmfSources})
......
......@@ -3,19 +3,50 @@ XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/
%include std_string.i
%include std_vector.i
%module Xdmf
%{
#include <XdmfArray.hpp>
#include <XdmfAttribute.hpp>
#include <XdmfAttributeCenter.hpp>
#include <XdmfAttributeType.hpp>
#include <XdmfDataItem.hpp>
#include <XdmfDomain.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGrid.hpp>
#include <XdmfItem.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
#include <XdmfTopologyType.hpp>
#include <XdmfVisitor.hpp>
#include <XdmfWriter.hpp>
%}
namespace boost {
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
}
// Macro for defining shared pointer inheritances:
%define SWIG_SHARED_PTR_DERIVED(CLASS, BASECLASS...)
%types(boost::shared_ptr< CLASS > = boost::shared_ptr< BASECLASS > ) %{
boost::shared_ptr< BASECLASS > p = *(boost::shared_ptr< CLASS >*)$from;
boost::shared_ptr< BASECLASS > * pPtr = &p;
return pPtr;
%}
%enddef
%include std_string.i
%include std_vector.i
%include loki/Visitor.h
// Shared Pointer Templates
%template(XdmfAttributePtr) boost::shared_ptr<XdmfAttribute>;
%template(XdmfArrayPtr) boost::shared_ptr<XdmfArray>;
%template(XdmfBaseVisitorPtr) boost::shared_ptr<Loki::BaseVisitor>;
%template(XdmfDataItemPtr) boost::shared_ptr<XdmfDataItem>;
%template(XdmfDomainPtr) boost::shared_ptr<XdmfDomain>;
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
......@@ -24,29 +55,47 @@ namespace boost {
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>;
%module Xdmf
%{
#include <XdmfArray.hpp>
#include <XdmfAttribute.hpp>
#include <XdmfAttributeCenter.hpp>
#include <XdmfAttributeType.hpp>
#include <XdmfDataItem.hpp>
#include <XdmfDomain.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGrid.hpp>
#include <XdmfItem.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
#include <XdmfTopologyType.hpp>
#include <XdmfVisitor.hpp>
%}
%template(XdmfWriterPtr) boost::shared_ptr<XdmfWriter>;
// Abstract Base Classes
%template() Loki::BaseVisitable<void>;
%template() Loki::Visitor<XdmfArray>;
%template() Loki::Visitor<XdmfAttribute>;
%template() Loki::Visitor<XdmfDomain>;
%template() Loki::Visitor<XdmfGeometry>;
%template() Loki::Visitor<XdmfGrid>;
%template() Loki::Visitor<XdmfItem>;
%template() Loki::Visitor<XdmfTopology>;
SWIG_SHARED_PTR_DERIVED(XdmfArray, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfArray, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfVisitor, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfVisitor, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject);
%include XdmfObject.hpp
%include XdmfItem.hpp
%include XdmfVisitor.hpp
%include XdmfWriter.hpp
%include XdmfDataItem.hpp
......@@ -63,79 +112,79 @@ namespace boost {
// Provide accessors from python lists to XdmfArrays
%extend XdmfArray {
void copyValueAsChar(int index, char value) {
$self->copyValues(index, &value);
}
void copyValueAsShort(int index, short value) {
$self->copyValues(index, &value);
}
void copyValueAsInt(int index, int value) {
$self->copyValues(index, &value);
}
void copyValueAsLong(int index, long value) {
$self->copyValues(index, &value);
}
void copyValueAsFloat(int index, float value) {
$self->copyValues(index, &value);
}
void copyValueAsDouble(int index, double value) {
$self->copyValues(index, &value);
}
void copyValueAsUChar(int index, unsigned char value) {
$self->copyValues(index, &value);
}
void copyValueAsUShort(int index, unsigned short value) {
$self->copyValues(index, &value);
}
void copyValueAsUInt(int index, unsigned int value) {
$self->copyValues(index, &value);
}
void copyValueAsChar(int index, char value) {
$self->copyValues(index, &value);
}
void copyValueAsShort(int index, short value) {
$self->copyValues(index, &value);
}
void copyValueAsInt(int index, int value) {
$self->copyValues(index, &value);
}
void copyValueAsLong(int index, long value) {
$self->copyValues(index, &value);
}
void copyValueAsFloat(int index, float value) {
$self->copyValues(index, &value);
}
void copyValueAsDouble(int index, double value) {
$self->copyValues(index, &value);
}
void copyValueAsUChar(int index, unsigned char value) {
$self->copyValues(index, &value);
}
void copyValueAsUShort(int index, unsigned short value) {
$self->copyValues(index, &value);
}
void copyValueAsUInt(int index, unsigned int value) {
$self->copyValues(index, &value);
}
};
%extend boost::shared_ptr<XdmfArray> {
%pythoncode {
def copyValuesAsChar(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsChar(i+startIndex, values[i])
def copyValuesAsShort(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsShort(i+startIndex, values[i])
def copyValuesAsInt(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsInt(i+startIndex, values[i])
def copyValuesAsLong(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsLong(i+startIndex, values[i])
def copyValuesAsFloat(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsFloat(i+startIndex, values[i])
def copyValuesAsDouble(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsDouble(i+startIndex, values[i])
def copyValuesAsUChar(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUChar(i+startIndex, values[i])
def copyValuesAsUShort(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUShort(i+startIndex, values[i])
def copyValuesAsUInt(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUInt(i+startIndex, values[i])
};
};
%pythoncode {
def copyValuesAsChar(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsChar(i+startIndex, values[i])
def copyValuesAsShort(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsShort(i+startIndex, values[i])
def copyValuesAsInt(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsInt(i+startIndex, values[i])
def copyValuesAsLong(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsLong(i+startIndex, values[i])
def copyValuesAsFloat(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsFloat(i+startIndex, values[i])
def copyValuesAsDouble(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsDouble(i+startIndex, values[i])
def copyValuesAsUChar(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUChar(i+startIndex, values[i])
def copyValuesAsUShort(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUShort(i+startIndex, values[i])
def copyValuesAsUInt(self, startIndex, values):
for i in range(0, len(values)):
self.copyValueAsUInt(i+startIndex, values[i])
};
};
\ No newline at end of file
......@@ -421,11 +421,6 @@ XdmfArray::~XdmfArray()
std::cout << "Deleted Array " << this << std::endl;
}
void XdmfArray::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
void XdmfArray::copyValues(const unsigned int startIndex, const boost::shared_ptr<const XdmfArray> values, const unsigned int valuesStartIndex, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride)
{
if(mHaveArrayPointer)
......
......@@ -47,11 +47,7 @@ class XdmfArray : public XdmfItem {
public:
XdmfNewMacro(XdmfArray);
/**
*
*/
virtual void accept(boost::shared_ptr<XdmfVisitor>) const;
LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem)
/**
* Copy values from an XdmfArray into this array.
......@@ -246,6 +242,9 @@ protected:
private:
XdmfArray(const XdmfArray & array); // Not implemented.
void operator=(const XdmfArray & array); // Not implemented.
// Variant Visitor Operations
class Clear;
class CopyArrayValues;
......@@ -298,16 +297,16 @@ private:
boost::shared_ptr<std::vector<unsigned short> >,
boost::shared_ptr<std::vector<unsigned int> > > ArrayVariant;
typedef boost::variant<
boost::shared_array<const char>,
boost::shared_array<const short>,
boost::shared_array<const int>,
boost::shared_array<const long>,
boost::shared_array<const float>,
boost::shared_array<const double>,
boost::shared_array<const unsigned char>,
boost::shared_array<const unsigned short>,
boost::shared_array<const unsigned int> > ArrayPointerVariant;
typedef boost::variant<
boost::shared_array<const char>,
boost::shared_array<const short>,
boost::shared_array<const int>,
boost::shared_array<const long>,
boost::shared_array<const float>,
boost::shared_array<const double>,
boost::shared_array<const unsigned char>,
boost::shared_array<const unsigned short>,
boost::shared_array<const unsigned int> > ArrayPointerVariant;
ArrayVariant mArray;
ArrayPointerVariant mArrayPointer;
......
......@@ -21,11 +21,6 @@ XdmfAttribute::~XdmfAttribute()
std::cout << "Deleted Attribute " << this << std::endl;
}
void XdmfAttribute::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
XdmfAttributeCenter XdmfAttribute::getAttributeCenter() const
{
return mAttributeCenter;
......
......@@ -17,8 +17,7 @@ class XdmfAttribute : public XdmfDataItem {
public:
XdmfNewMacro(XdmfAttribute);
void accept(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfDataItem)
/**
* Get the XdmfAttributeCenter associated with this attribute.
......
......@@ -34,7 +34,7 @@ void XdmfDataItem::setArray(boost::shared_ptr<XdmfArray> array)
mArray = array;
}
void XdmfDataItem::traverse(boost::shared_ptr<XdmfVisitor> visitor) const
void XdmfDataItem::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
{
mArray->accept(visitor);
}
......@@ -17,6 +17,8 @@ class XdmfDataItem : public XdmfItem {
public:
LOKI_DEFINE_VISITABLE(XdmfDataItem, XdmfItem)
/**
* Get the XdmfArray attached to this XdmfDataItem.
*
......@@ -38,7 +40,7 @@ public:
*/
void setArray(boost::shared_ptr<XdmfArray> array);
virtual void traverse(boost::shared_ptr<XdmfVisitor> visitor) const;
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
protected:
......
......@@ -19,11 +19,6 @@ XdmfDomain::~XdmfDomain()
std::cout << "Deleted Domain " << this << std::endl;
}
void XdmfDomain::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
void XdmfDomain::insert(boost::shared_ptr<XdmfGrid> grid)
{
mGrids.push_back(grid);
......@@ -54,7 +49,7 @@ unsigned int XdmfDomain::getNumberOfGrids() const
return mGrids.size();
}
void XdmfDomain::traverse(boost::shared_ptr<XdmfVisitor> visitor) const
void XdmfDomain::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
{
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{
......
......@@ -19,8 +19,7 @@ class XdmfDomain : public XdmfItem {
public:
XdmfNewMacro(XdmfDomain);
virtual void accept(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE(XdmfDomain, XdmfItem)
/**
* Get a XdmfGrid attached to the domain.
......@@ -52,7 +51,7 @@ public:
*/
unsigned int getNumberOfGrids() const;
virtual void traverse(boost::shared_ptr<XdmfVisitor> visitor) const;
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
protected:
......
......@@ -20,11 +20,6 @@ XdmfGeometry::~XdmfGeometry()
std::cout << "Deleted Geometry " << this << std::endl;
}
void XdmfGeometry::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
XdmfGeometryType XdmfGeometry::getGeometryType() const
{
return mGeometryType;
......
......@@ -17,8 +17,7 @@ class XdmfGeometry : public XdmfDataItem {
public:
XdmfNewMacro(XdmfGeometry);
virtual void accept(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE(XdmfGeometry, XdmfDataItem)
/**
* Get the XdmfGeometryType associated with this geometry.
......
......@@ -25,11 +25,6 @@ XdmfGrid::~XdmfGrid()
std::cout << "Deleted Grid " << this << std::endl;
}
void XdmfGrid::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
boost::shared_ptr<XdmfAttribute> XdmfGrid::getAttribute(unsigned int index)
{
if(index >= mAttributes.size())
......@@ -100,7 +95,7 @@ void XdmfGrid::setTopology(boost::shared_ptr<XdmfTopology> topology)
mTopology = topology;
}
void XdmfGrid::traverse(boost::shared_ptr<XdmfVisitor> visitor) const
void XdmfGrid::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
{
mGeometry->accept(visitor);
mTopology->accept(visitor);
......
......@@ -22,8 +22,7 @@ class XdmfGrid : public XdmfItem {
public:
XdmfNewMacro(XdmfGrid);
virtual void accept(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem)
/**
* Get an XdmfAttribute attached to this grid.
......@@ -111,7 +110,7 @@ public:
*/
void setName(const std::string & name);
virtual void traverse(boost::shared_ptr<XdmfVisitor> visitor) const;
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
protected:
......
......@@ -9,7 +9,7 @@ XdmfItem::~XdmfItem()
{
}
void XdmfItem::traverse(boost::shared_ptr<XdmfVisitor> visitor) const
void XdmfItem::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
{
return;
}
......@@ -13,6 +13,7 @@
class XdmfVisitor;
// Includes
#include <loki/Visitor.h>
#include "XdmfObject.hpp"
/**
......@@ -21,12 +22,13 @@ class XdmfVisitor;
* XdmfItem is an abstract base class. It represents any item that can be visited and traversed by an XdmfVisitor
* and have its contents added to an Xdmf file.
*/
class XdmfItem : public XdmfObject {
class XdmfItem : public XdmfObject,
public Loki::BaseVisitable<void> {
public:
virtual void accept(boost::shared_ptr<XdmfVisitor> visitor) const = 0;
virtual void traverse(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE_BASE()
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
protected:
......@@ -35,9 +37,8 @@ protected:
private:
XdmfItem(const XdmfItem&); // Not implemented.
void operator=(const XdmfItem&); // Not implemented.
XdmfItem(const XdmfItem & item); // Not implemented.
void operator=(const XdmfItem & item); // Not implemented.
};
#endif /* XDMFITEM_HPP_ */
......@@ -2,8 +2,8 @@
#define XDMFOBJECT_HPP_
// Includes
#include "boost/shared_ptr.hpp"
#include <iostream>
#include <boost/shared_ptr.hpp>
#define XdmfNewMacro(type) \
template <typename T> friend void boost::checked_delete(T * x); \
......
......@@ -21,13 +21,12 @@ XdmfTopology::~XdmfTopology()
std::cout << "Deleted Topology " << this << std::endl;
}
void XdmfTopology::accept(boost::shared_ptr<XdmfVisitor> visitor) const
{
visitor->visit(this, visitor);
}
unsigned int XdmfTopology::getNumberElements() const
{
if(this->getTopologyType().getNodesPerElement() == 0)
{
return 0;
}
return this->getArray()->getSize() / this->getTopologyType().getNodesPerElement();
}
......
......@@ -17,8 +17,7 @@ class XdmfTopology : public XdmfDataItem {
public:
XdmfNewMacro(XdmfTopology);
virtual void accept(boost::shared_ptr<XdmfVisitor> visitor) const;
LOKI_DEFINE_VISITABLE(XdmfTopology, XdmfDataItem)
/**
* Get the number of elements this Topology contains.
......
// Kenneth Leiter
// Xdmf Smart Pointer Test
#include "XdmfArray.hpp"
#include "XdmfAttribute.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfTopology.hpp"
#include "XdmfItem.hpp"
#include "XdmfVisitor.hpp"
#include <iomanip>
XdmfVisitor::XdmfVisitor() :
mLightDataLimit(100),
mHeavyFileName("output.h5"),
hdf5Handle(H5Fcreate("output.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)),
xmlDocument(xmlNewDoc((xmlChar*)"1.0")),
xmlCurrentNode(xmlNewNode(NULL, (xmlChar*)"Xdmf"))
XdmfVisitor::XdmfVisitor()
{
xmlDocSetRootElement(xmlDocument, xmlCurrentNode);
std::cout << "Created Visitor " << this << std::endl;
}
XdmfVisitor::~XdmfVisitor()
{
xmlSaveFormatFile("output.xmf", xmlDocument, 1);
xmlFreeDoc(xmlDocument);
xmlCleanupParser();
herr_t status = H5Fclose(hdf5Handle);
std::cout << "Deleted Visitor " << this << std::endl;
}
void XdmfVisitor::visit(const XdmfAttribute * const attribute, boost::shared_ptr<XdmfVisitor> visitor)
{
xmlNodePtr parentNode = xmlCurrentNode;
xmlCurrentNode = xmlNewChild(xmlCurrentNode, NULL, (xmlChar*)"Attribute", NULL);
xmlNewProp(xmlCurrentNode, (xmlChar*)"Name", (xmlChar*)attribute->getName().c_str());
xmlNewProp(xmlCurrentNode, (xmlChar*)"AttributeType", (xmlChar*)attribute->getAttributeType().getName().c_str());
xmlNewProp(xmlCurrentNode, (xmlChar*)"Center", (xmlChar*)attribute->getAttributeCenter().getName().c_str());
dataHierarchy.push_back(attribute->getName());
attribute->traverse(visitor);
dataHierarchy.pop_back();
xmlCurrentNode = parentNode;
}
void XdmfVisitor::visit(const XdmfArray * const array, boost::shared_ptr<XdmfVisitor> visitor)
{
xmlNodePtr parentNode = xmlCurrentNode;
xmlCurrentNode = xmlNewChild(xmlCurrentNode, NULL, (xmlChar*)"DataItem", NULL);
std::string format = "XML";
if(array->getSize() > mLightDataLimit)
{
format = "HDF";
}
xmlNewProp(xmlCurrentNode, (xmlChar*)"Format", (xmlChar*)format.c_str());
xmlNewProp(xmlCurrentNode, (xmlChar*)"DataType", (xmlChar*)array->getType().c_str());
std::stringstream precisionString;
precisionString << array->getPrecision();
xmlNewProp(xmlCurrentNode, (xmlChar*)"Precision", (xmlChar*)precisionString.str().c_str());
std::stringstream dimensionString;
dimensionString << array->getSize();
xmlNewProp(xmlCurrentNode, (xmlChar*)"Dimensions", (xmlChar*)dimensionString.str().c_str());
std::stringstream xmlTextValues;
if(array->getSize() > mLightDataLimit)
{
herr_t status;
hsize_t size = array->getSize();
hid_t dataspace = H5Screate_simple(1, &size, NULL);
hid_t handle = hdf5Handle;
std::string groupName = getHDF5GroupName();
// Need to make sure this group exists before we add to it.
if(dataHierarchy.size() > 1)
{
/* Save old error handler */
H5E_auto_t old_func;
void* old_client_data;
H5Eget_auto(0, &old_func, &old_client_data);
/* Turn off error handling */
H5Eset_auto2(0, NULL, NULL);
/* Probe. May fail, but that's okay */
handle = H5Gopen(hdf5Handle, groupName.c_str(), H5P_DEFAULT);
/* Restore previous error handler */
H5Eset_auto2(0, old_func, old_client_data);
if(handle < 0)
{
handle = H5Gcreate(hdf5Handle, groupName.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
}
}
hid_t dataset = H5Dcreate(handle, dataHierarchy.back().c_str(), array->getHDF5Type(), dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
xmlTextValues << mHeavyFileName << ":" << groupName << "/" << dataHierarchy.back();
status = H5Dwrite(dataset, array->getHDF5Type(), H5S_ALL, H5S_ALL, H5P_DEFAULT, array->getValuesPointer());
status = H5Dclose(dataset);
status = H5Sclose(dataspace);
}
else
{
xmlTextValues << array->getValuesString();
}
xmlAddChild(xmlCurrentNode, xmlNewText((xmlChar*)xmlTextValues.str().c_str()));
xmlCurrentNode = parentNode;
}
void XdmfVisitor::visit(const XdmfDomain * const domain, boost::shared_ptr<XdmfVisitor