Commit b94acdde authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add ability to read XML files from disk into Xdmf structures in memory.

parent 5e8d6200
...@@ -47,6 +47,7 @@ set(XdmfSources ...@@ -47,6 +47,7 @@ set(XdmfSources
XdmfItem XdmfItem
XdmfItemProperty XdmfItemProperty
XdmfObject XdmfObject
XdmfReader
XdmfTopology XdmfTopology
XdmfTopologyType XdmfTopologyType
XdmfVisitor XdmfVisitor
......
...@@ -14,11 +14,12 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -14,11 +14,12 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#include <XdmfGeometry.hpp> #include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp> #include <XdmfGeometryType.hpp>
#include <XdmfGrid.hpp> #include <XdmfGrid.hpp>
#include <XdmfHDF5Controller.hpp> #include <XdmfHDF5Controller.hpp>
#include <XdmfHDF5Writer.hpp> #include <XdmfHDF5Writer.hpp>
#include <XdmfItem.hpp> #include <XdmfItem.hpp>
#include <XdmfItemProperty.hpp> #include <XdmfItemProperty.hpp>
#include <XdmfObject.hpp> #include <XdmfObject.hpp>
#include <XdmfReader.hpp>
#include <XdmfTopology.hpp> #include <XdmfTopology.hpp>
#include <XdmfTopologyType.hpp> #include <XdmfTopologyType.hpp>
#include <XdmfVisitor.hpp> #include <XdmfVisitor.hpp>
...@@ -58,6 +59,7 @@ namespace boost { ...@@ -58,6 +59,7 @@ namespace boost {
%template(XdmfHDF5WriterPtr) boost::shared_ptr<XdmfHDF5Writer>; %template(XdmfHDF5WriterPtr) boost::shared_ptr<XdmfHDF5Writer>;
%template(XdmfItemPtr) boost::shared_ptr<XdmfItem>; %template(XdmfItemPtr) boost::shared_ptr<XdmfItem>;
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>; %template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfReaderPtr) boost::shared_ptr<XdmfReader>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>; %template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>; %template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>;
%template(XdmfWriterPtr) boost::shared_ptr<XdmfWriter>; %template(XdmfWriterPtr) boost::shared_ptr<XdmfWriter>;
...@@ -91,6 +93,7 @@ SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor); ...@@ -91,6 +93,7 @@ SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, Loki::BaseVisitor); SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfReader, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfDataItem); SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfObject);
...@@ -103,15 +106,15 @@ SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject); ...@@ -103,15 +106,15 @@ SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject);
%include XdmfObject.hpp %include XdmfObject.hpp
%include XdmfItem.hpp %include XdmfItem.hpp
%include XdmfDataItem.hpp
%include XdmfItemProperty.hpp %include XdmfItemProperty.hpp
%include XdmfVisitor.hpp %include XdmfVisitor.hpp
%include XdmfHDF5Controller.hpp %include XdmfHDF5Controller.hpp
%include XdmfHDF5Writer.hpp %include XdmfHDF5Writer.hpp
%include XdmfReader.hpp
%include XdmfWriter.hpp %include XdmfWriter.hpp
%include XdmfDataItem.hpp
%include XdmfAttribute.hpp %include XdmfAttribute.hpp
%include XdmfAttributeCenter.hpp %include XdmfAttributeCenter.hpp
%include XdmfAttributeType.hpp %include XdmfAttributeType.hpp
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
* Author: kleiter * Author: kleiter
*/ */
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
#include <sstream>
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
#include "XdmfHDF5Controller.hpp" #include "XdmfHDF5Controller.hpp"
#include "XdmfVisitor.hpp" #include "XdmfVisitor.hpp"
#include <sstream>
class XdmfArray::Clear : public boost::static_visitor <void> { class XdmfArray::Clear : public boost::static_visitor <void> {
public: public:
...@@ -363,6 +365,8 @@ XdmfArray::~XdmfArray() ...@@ -363,6 +365,8 @@ XdmfArray::~XdmfArray()
std::cout << "Deleted Array " << this << std::endl; std::cout << "Deleted Array " << this << std::endl;
} }
std::string XdmfArray::ItemTag = "DataItem";
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) 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) if(mHaveArrayPointer)
...@@ -410,7 +414,14 @@ boost::shared_ptr<const XdmfHDF5Controller> XdmfArray::getHDF5Controller() const ...@@ -410,7 +414,14 @@ boost::shared_ptr<const XdmfHDF5Controller> XdmfArray::getHDF5Controller() const
std::map<std::string, std::string> XdmfArray::getItemProperties() const std::map<std::string, std::string> XdmfArray::getItemProperties() const
{ {
std::map<std::string, std::string> arrayProperties; std::map<std::string, std::string> arrayProperties;
arrayProperties["Format"] = "HDF"; if(mHDF5Controller)
{
arrayProperties["Format"] = "HDF";
}
else
{
arrayProperties["Format"] = "XML";
}
arrayProperties["DataType"] = this->getType(); arrayProperties["DataType"] = this->getType();
std::stringstream precision; std::stringstream precision;
precision << this->getPrecision(); precision << this->getPrecision();
...@@ -423,7 +434,7 @@ std::map<std::string, std::string> XdmfArray::getItemProperties() const ...@@ -423,7 +434,7 @@ std::map<std::string, std::string> XdmfArray::getItemProperties() const
std::string XdmfArray::getItemTag() const std::string XdmfArray::getItemTag() const
{ {
return "DataItem"; return ItemTag;
} }
unsigned int XdmfArray::getPrecision() const unsigned int XdmfArray::getPrecision() const
...@@ -503,6 +514,50 @@ std::string XdmfArray::getValuesString() const ...@@ -503,6 +514,50 @@ std::string XdmfArray::getValuesString() const
return ""; return "";
} }
void XdmfArray::initialize(const std::string & type, const unsigned int precision)
{
if(type.compare("Char") == 0 && precision == 1)
{
this->initialize<char>();
}
else if(type.compare("Short") == 0 && precision == 2)
{
this->initialize<short>();
}
else if(type.compare("Int") == 0 && precision == 4)
{
this->initialize<int>();
}
else if(type.compare("Long") == 0 && precision == 8)
{
this->initialize<long>();
}
else if(type.compare("Float") == 0 && precision == 4)
{
this->initialize<float>();
}
else if(type.compare("Double") == 0 && precision == 8)
{
this->initialize<double>();
}
else if(type.compare("UChar") == 0 && precision == 8)
{
this->initialize<unsigned char>();
}
else if(type.compare("UShort") == 0 && precision == 8)
{
this->initialize<unsigned short>();
}
else if(type.compare("UInt") == 0 && precision == 8)
{
this->initialize<unsigned int>();
}
else
{
assert(false);
}
}
void XdmfArray::internalizeArrayPointer() void XdmfArray::internalizeArrayPointer()
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
...@@ -511,6 +566,79 @@ void XdmfArray::internalizeArrayPointer() ...@@ -511,6 +566,79 @@ void XdmfArray::internalizeArrayPointer()
} }
} }
void XdmfArray::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
std::string contentVal;
int precisionVal;
int sizeVal;
std::string typeVal;
std::map<std::string, std::string>::const_iterator content = itemProperties.find("Content");
if(content != itemProperties.end())
{
contentVal = content->second;
}
else
{
assert(false);
}
std::map<std::string, std::string>::const_iterator precision = itemProperties.find("Precision");
if(precision != itemProperties.end())
{
precisionVal = atoi(precision->second.c_str());
}
else
{
assert(false);
}
std::map<std::string, std::string>::const_iterator size = itemProperties.find("Dimensions");
if(size != itemProperties.end())
{
sizeVal = atoi(size->second.c_str());
}
else
{
assert(false);
}
std::map<std::string, std::string>::const_iterator type = itemProperties.find("DataType");
if(type != itemProperties.end())
{
typeVal = type->second;
}
else
{
assert(false);
}
std::map<std::string, std::string>::const_iterator format = itemProperties.find("Format");
if(format != itemProperties.end())
{
if(format->second.compare("HDF") == 0)
{
mHDF5Controller = XdmfHDF5Controller::New(contentVal, precisionVal, sizeVal, typeVal);
}
else if(format->second.compare("XML") == 0)
{
this->initialize(typeVal, precisionVal);
this->reserve(sizeVal);
boost::char_separator<char> sep(" ");
boost::tokenizer<boost::char_separator<char> > tokens(contentVal, sep);
BOOST_FOREACH(std::string t, tokens)
{
double val = atof(t.c_str());
this->pushBack(val);
}
}
else
{
assert(false);
}
}
else
{
assert(false);
}
}
void XdmfArray::read() void XdmfArray::read()
{ {
if(mHDF5Controller) if(mHDF5Controller)
......
...@@ -51,6 +51,7 @@ public: ...@@ -51,6 +51,7 @@ public:
XdmfNewMacro(XdmfArray); XdmfNewMacro(XdmfArray);
LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem) LOKI_DEFINE_VISITABLE(XdmfArray, XdmfItem)
friend class XdmfHDF5Writer; friend class XdmfHDF5Writer;
static std::string ItemTag;
/** /**
* Copy values from an XdmfArray into this array. * Copy values from an XdmfArray into this array.
...@@ -178,13 +179,19 @@ public: ...@@ -178,13 +179,19 @@ public:
template <typename T> template <typename T>
boost::shared_ptr<std::vector<T> > initialize(); boost::shared_ptr<std::vector<T> > initialize();
/**
* Copy a value to the back of this array
*/
template <typename T>
void pushBack(T & value);
/** /**
* Read data from disk into memory. * Read data from disk into memory.
*/ */
void read(); void read();
/** /**
* Release all data held by this XdmfArray. * Release all data from currently held in memory.
*/ */
void release(); void release();
...@@ -200,10 +207,10 @@ public: ...@@ -200,10 +207,10 @@ public:
* to val. If numValues is less than the current size, values at indices larger than numValues are removed. * to val. If numValues is less than the current size, values at indices larger than numValues are removed.
* *
* @param numValues the number of values to resize this array to. * @param numValues the number of values to resize this array to.
* @param val the number to initialize newly created values to, if needed. * @param value the number to initialize newly created values to, if needed.
*/ */
template<typename T> template<typename T>
void resize(const unsigned int numValues, const T & val = 0); void resize(const unsigned int numValues, const T & value = 0);
/** /**
* Attach an hdf5 controller to this XdmfArray. * Attach an hdf5 controller to this XdmfArray.
...@@ -277,6 +284,7 @@ protected: ...@@ -277,6 +284,7 @@ protected:
XdmfArray(); XdmfArray();
virtual ~XdmfArray(); virtual ~XdmfArray();
virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);
private: private:
...@@ -287,7 +295,7 @@ private: ...@@ -287,7 +295,7 @@ private:
class Clear; class Clear;
class CopyArrayValues; class CopyArrayValues;
template<typename T> template <typename T>
class CopyValues; class CopyValues;
class GetCapacity; class GetCapacity;
...@@ -296,20 +304,26 @@ private: ...@@ -296,20 +304,26 @@ private:
class GetSize; class GetSize;
class GetType; class GetType;
template<typename T> template <typename T>
class GetValuesCopy; class GetValuesCopy;
class GetValuesPointer; class GetValuesPointer;
class GetValuesString; class GetValuesString;
class InternalizeArrayPointer; class InternalizeArrayPointer;
class NewArray; class NewArray;
template <typename T>
class PushBack;
class Reserve; class Reserve;
template<typename T> template <typename T>
class Resize; class Resize;
struct NullDeleter; struct NullDeleter;
void initialize(const std::string & type, const unsigned int precision);
/** /**
* After setValues(const T * const array) is called, XdmfArray stores a pointer that is not allowed to be modified through * After setValues(const T * const array) is called, XdmfArray stores a pointer that is not allowed to be modified through
* the XdmfArray API. If the user desires to modify the contents of the pointer, they must do so without calling any * the XdmfArray API. If the user desires to modify the contents of the pointer, they must do so without calling any
......
// Includes // Includes
#include "XdmfArray.hpp" #include "XdmfArray.hpp"
template<typename T> template <typename T>
class XdmfArray::CopyValues : public boost::static_visitor <void> { class XdmfArray::CopyValues : public boost::static_visitor <void> {
public: public:
...@@ -41,7 +41,7 @@ private: ...@@ -41,7 +41,7 @@ private:
const unsigned int mValuesStride; const unsigned int mValuesStride;
}; };
template<typename T> template <typename T>
class XdmfArray::GetValuesCopy : public boost::static_visitor <void> { class XdmfArray::GetValuesCopy : public boost::static_visitor <void> {
public: public:
...@@ -81,7 +81,27 @@ private: ...@@ -81,7 +81,27 @@ private:
const unsigned int mValuesStride; const unsigned int mValuesStride;
}; };
template<typename T> template <typename T>
class XdmfArray::PushBack : public boost::static_visitor <void> {
public:
PushBack(const T & val) :
mVal(val)
{
}
template<typename U>
void operator()(boost::shared_ptr<std::vector<U> > & array) const
{
array->push_back((U)mVal);
}
private:
const T & mVal;
};
template <typename T>
class XdmfArray::Resize : public boost::static_visitor <void> { class XdmfArray::Resize : public boost::static_visitor <void> {
public: public:
...@@ -110,7 +130,7 @@ struct XdmfArray::NullDeleter ...@@ -110,7 +130,7 @@ struct XdmfArray::NullDeleter
} }
}; };
template<typename T> template <typename T>
void XdmfArray::copyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) void XdmfArray::copyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride)
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
...@@ -121,7 +141,7 @@ void XdmfArray::copyValues(const unsigned int startIndex, const T * const values ...@@ -121,7 +141,7 @@ void XdmfArray::copyValues(const unsigned int startIndex, const T * const values
{ {
initialize<T>(); initialize<T>();
} }
boost::apply_visitor( CopyValues<T>(startIndex, valuesPointer, numValues, arrayStride, valuesStride), mArray); boost::apply_visitor(CopyValues<T>(startIndex, valuesPointer, numValues, arrayStride, valuesStride), mArray);
} }
template <typename T> template <typename T>
...@@ -167,11 +187,7 @@ void XdmfArray::getValuesCopy(const unsigned int startIndex, T * valuesPointer, ...@@ -167,11 +187,7 @@ void XdmfArray::getValuesCopy(const unsigned int startIndex, T * valuesPointer,
{ {
boost::apply_visitor(GetValuesCopy<T>(startIndex, valuesPointer, numValues, arrayStride, valuesStride), mArrayPointer); boost::apply_visitor(GetValuesCopy<T>(startIndex, valuesPointer, numValues, arrayStride, valuesStride), mArrayPointer);
} }
else if(mHDF5Controller) assert(false);
{
assert("Need to complete");
}
assert("Throw Exception No Data");
} }
template <typename T> template <typename T>
...@@ -193,8 +209,18 @@ boost::shared_ptr<std::vector<T> > XdmfArray::initialize() ...@@ -193,8 +209,18 @@ boost::shared_ptr<std::vector<T> > XdmfArray::initialize()
return newArray; return newArray;
} }
template <typename T>
void XdmfArray::pushBack(T & value)
{
if(mHaveArrayPointer)
{
internalizeArrayPointer();
}
return boost::apply_visitor(PushBack<T>(value), mArray);
}
template<typename T> template<typename T>
void XdmfArray::resize(const unsigned int numValues, const T & val) void XdmfArray::resize(const unsigned int numValues, const T & value)
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
{ {
...@@ -204,10 +230,10 @@ void XdmfArray::resize(const unsigned int numValues, const T & val) ...@@ -204,10 +230,10 @@ void XdmfArray::resize(const unsigned int numValues, const T & val)
{ {
initialize<T>(); initialize<T>();
} }
return boost::apply_visitor(Resize<T>(numValues, val), mArray); return boost::apply_visitor(Resize<T>(numValues, value), mArray);
} }
template<typename T> template <typename T>
void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numValues, const bool transferOwnership) void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numValues, const bool transferOwnership)
{ {
// Remove contents of internal array. // Remove contents of internal array.
...@@ -229,7 +255,7 @@ void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numVa ...@@ -229,7 +255,7 @@ void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numVa
mArrayPointerNumValues = numValues; mArrayPointerNumValues = numValues;
} }
template<typename T> template <typename T>
void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership) void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership)
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
...@@ -249,7 +275,7 @@ void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership) ...@@ -249,7 +275,7 @@ void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership)
mHaveArray = true; mHaveArray = true;
} }
template<typename T> template <typename T>
void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array) void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array)
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
...@@ -260,7 +286,7 @@ void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array) ...@@ -260,7 +286,7 @@ void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array)
mHaveArray = true; mHaveArray = true;
} }
template<typename T> template <typename T>
bool XdmfArray::swap(std::vector<T> & array) bool XdmfArray::swap(std::vector<T> & array)
{ {
if(mHaveArrayPointer) if(mHaveArrayPointer)
...@@ -283,7 +309,7 @@ bool XdmfArray::swap(std::vector<T> & array) ...@@ -283,7 +309,7 @@ bool XdmfArray::swap(std::vector<T> & array)
} }
} }
template<typename T> template <typename T>
bool XdmfArray::swap(boost::shared_ptr<std::vector<T> > array) bool XdmfArray::swap(boost::shared_ptr<std::vector<T> > array)
{ {
return this->swap(*array.get()); return this->swap(*array.get());
......
...@@ -20,6 +20,8 @@ XdmfAttribute::~XdmfAttribute() ...@@ -20,6 +20,8 @@ XdmfAttribute::~XdmfAttribute()
std::cout << "Deleted Attribute " << this << std::endl; std::cout << "Deleted Attribute " << this << std::endl;
} }
std::string XdmfAttribute::ItemTag = "Attribute";
XdmfAttributeCenter XdmfAttribute::getAttributeCenter() const XdmfAttributeCenter XdmfAttribute::getAttributeCenter() const
{ {
return mAttributeCenter; return mAttributeCenter;
...@@ -41,7 +43,7 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const ...@@ -41,7 +43,7 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const
std::string XdmfAttribute::getItemTag() const std::string XdmfAttribute::getItemTag() const
{ {
return "Attribute"; return ItemTag;
} }
std::string XdmfAttribute::getName() const std::string XdmfAttribute::getName() const
...@@ -49,6 +51,23 @@ std::string XdmfAttribute::getName() const ...@@ -49,6 +51,23 @@ std::string XdmfAttribute::getName() const
return mName; return mName;
} }
void XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
std::map<std::string, std::string>::const_iterator name = itemProperties.find("Name");
if(name != itemProperties.end())
{
mName = name->second;
}
else
{
assert(false);
}
mAttributeCenter = XdmfAttributeCenter::New(itemProperties);
mAttributeType = XdmfAttributeType::New(itemProperties);
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfAttribute::setAttributeCenter(const XdmfAttributeCenter & attributeCenter) void XdmfAttribute::setAttributeCenter(const XdmfAttributeCenter & attributeCenter)
{ {
mAttributeCenter = attributeCenter; mAttributeCenter = attributeCenter;
......
...@@ -18,6 +18,7 @@ public: ...@@ -18,6 +18,7 @@ public:
XdmfNewMacro(XdmfAttribute); XdmfNewMacro(XdmfAttribute);
LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfDataItem) LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfDataItem)
static std::string ItemTag;
/** /**
* Get the XdmfAttributeCenter associated with this attribute. * Get the XdmfAttributeCenter associated with this attribute.
...@@ -69,6 +70,7 @@ protected: ...@@ -69,6 +70,7 @@ protected:
XdmfAttribute(); XdmfAttribute();
virtual ~XdmfAttribute(); virtual ~XdmfAttribute();
virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);
private: private:
......
...@@ -35,13 +35,48 @@ XdmfAttributeCenter XdmfAttributeCenter::Node() ...@@ -35,13 +35,48 @@ XdmfAttributeCenter XdmfAttributeCenter::Node()
XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) : XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
mName(name) mName(name)
{}; {
}
XdmfAttributeCenter::XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter): XdmfAttributeCenter::XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter):
mName(attributeCenter.mName) mName(attributeCenter.mName)
{ {
} }
XdmfAttributeCenter XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperties)
{
std::map<std::string, std::string>::const_iterator center = itemProperties.find("Center");
if(center != itemProperties.end())
{
const std::string centerVal = center->second;
if(centerVal.compare("Grid") == 0)
{
return Grid();
}
else if(centerVal.compare("Cell") == 0)
{
return Cell();
}
else if(centerVal.compare("Face") == 0)
{
return Face();
}
else if(centerVal.compare("Edge")