XdmfDomain.cpp 1.81 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 22
std::string XdmfDomain::ItemTag = "Domain";

Kenneth Leiter's avatar
Kenneth Leiter committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
void XdmfDomain::insert(boost::shared_ptr<XdmfGrid> grid)
{
	mGrids.push_back(grid);
}

boost::shared_ptr<XdmfGrid> XdmfDomain::getGrid(unsigned int index)
{
	if(index >= mGrids.size())
	{
		assert(false);
		// Out of range --- should we throw exceptions?
	}
	return mGrids[index];
}

boost::shared_ptr<const XdmfGrid> XdmfDomain::getGrid(unsigned int index) const
{
	if(index >= mGrids.size())
	{
		assert(false);
		// Out of range --- should we throw exceptions?
	}
	return mGrids[index];
}

48 49 50 51 52 53
std::map<std::string, std::string> XdmfDomain::getItemProperties() const
{
	std::map<std::string, std::string> domainProperties;
	return domainProperties;
}

54 55
std::string XdmfDomain::getItemTag() const
{
56
	return ItemTag;
57 58
}

Kenneth Leiter's avatar
Kenneth Leiter committed
59 60 61 62 63
unsigned int XdmfDomain::getNumberOfGrids() const
{
	return mGrids.size();
}

64 65 66 67 68 69 70 71
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));
	}
}

72 73 74 75 76 77 78 79 80
void XdmfDomain::removeGrid(const unsigned int index)
{
	if(index >= mGrids.size())
	{
		assert(false);
	}
	mGrids.erase(mGrids.begin() + index);
}

81
void XdmfDomain::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
82 83 84
{
	for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
	{
85
		(*iter)->accept(visitor);
86 87
	}
}