XdmfGeometry.cpp 1.62 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1
/*
2
 * XdmfGeometry.cpp
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
3 4 5 6 7 8
 *
 *  Created on: Jan 29, 2010
 *      Author: kleiter
 */

#include "XdmfGeometry.hpp"
9
#include "XdmfGeometryType.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
10

11 12 13 14 15 16
boost::shared_ptr<XdmfGeometry> XdmfGeometry::New()
{
	boost::shared_ptr<XdmfGeometry> p(new XdmfGeometry());
	return p;
}

17
XdmfGeometry::XdmfGeometry() :
18 19
	mNumberPoints(0),
	mType(XdmfGeometryType::NoGeometryType())
20
{
21
}
22

23 24
XdmfGeometry::~XdmfGeometry()
{
25 26
}

27
const std::string XdmfGeometry::ItemTag = "Geometry";
28

29 30 31
std::map<std::string, std::string> XdmfGeometry::getItemProperties() const
{
	std::map<std::string, std::string> geometryProperties;
32
	mType->getProperties(geometryProperties);
33 34 35
	return geometryProperties;
}

36 37
std::string XdmfGeometry::getItemTag() const
{
38 39 40
	return ItemTag;
}

41 42
unsigned int XdmfGeometry::getNumberPoints() const
{
43
	if(mType->getDimensions() == 0)
44 45 46
	{
		return 0;
	}
47
	return this->getSize() / mType->getDimensions();
48 49
}

50 51
boost::shared_ptr<const XdmfGeometryType> XdmfGeometry::getType() const
{
52
	return mType;
53 54
}

55
void XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader)
56
{
57 58
	XdmfItem::populateItem(itemProperties, childItems, reader);
	mType = XdmfGeometryType::New(itemProperties);
59 60 61 62 63 64 65 66
	for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
	{
		if(boost::shared_ptr<XdmfArray> array = boost::shared_dynamic_cast<XdmfArray>(*iter))
		{
			this->swap(array);
		}
		// TODO: If multiple dataitems.
	}
67 68
}

69
void XdmfGeometry::setType(const boost::shared_ptr<const XdmfGeometryType> type)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
70
{
71
	mType = type;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
72
}