XdmfDomain.cpp 1.82 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8
/*
 * XdmfGrid.cpp
 *
 *  Created on: Jan 25, 2010
 *      Author: kleiter
 */

#include "XdmfDomain.hpp"
9
#include "XdmfGrid.hpp"
Kenneth Leiter's avatar
Kenneth Leiter committed
10 11 12 13 14 15 16 17 18 19 20

XdmfDomain::XdmfDomain()
{
	std::cout << "Created Domain " << this << std::endl;
}

XdmfDomain::~XdmfDomain()
{
  std::cout << "Deleted Domain " << this << std::endl;
}

21
const std::string XdmfDomain::ItemTag = "Domain";
22

23
void XdmfDomain::insert(const boost::shared_ptr<XdmfGrid> grid)
Kenneth Leiter's avatar
Kenneth Leiter committed
24 25 26 27
{
	mGrids.push_back(grid);
}

28
boost::shared_ptr<XdmfGrid> XdmfDomain::getGrid(const unsigned int index)
Kenneth Leiter's avatar
Kenneth Leiter committed
29
{
30
	return boost::const_pointer_cast<XdmfGrid>(static_cast<const XdmfDomain &>(*this).getGrid(index));
Kenneth Leiter's avatar
Kenneth Leiter committed
31 32
}

33
boost::shared_ptr<const XdmfGrid> XdmfDomain::getGrid(const unsigned int index) const
Kenneth Leiter's avatar
Kenneth Leiter committed
34 35 36 37 38 39 40 41 42
{
	if(index >= mGrids.size())
	{
		assert(false);
		// Out of range --- should we throw exceptions?
	}
	return mGrids[index];
}

43 44 45 46 47 48
std::map<std::string, std::string> XdmfDomain::getItemProperties() const
{
	std::map<std::string, std::string> domainProperties;
	return domainProperties;
}

49 50
std::string XdmfDomain::getItemTag() const
{
51
	return ItemTag;
52 53
}

Kenneth Leiter's avatar
Kenneth Leiter committed
54 55 56 57 58
unsigned int XdmfDomain::getNumberOfGrids() const
{
	return mGrids.size();
}

59 60 61 62 63 64 65 66
void XdmfDomain::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
{
	for(std::vector<boost::shared_ptr<XdmfItem> >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter)
	{
		this->insert(boost::shared_dynamic_cast<XdmfGrid>(*iter));
	}
}

67 68 69 70 71 72 73 74 75
void XdmfDomain::removeGrid(const unsigned int index)
{
	if(index >= mGrids.size())
	{
		assert(false);
	}
	mGrids.erase(mGrids.begin() + index);
}

76
void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
77 78 79
{
	for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
	{
80
		(*iter)->accept(visitor);
81 82
	}
}