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

8
#include "XdmfAttribute.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
9 10 11
#include "XdmfGrid.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
12 13
#include "XdmfVisitor.hpp"
#include <sstream>
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
14

15
XdmfGrid::XdmfGrid() :
Ken Leiter (Civ ARL/CISD) kleiter's avatar
ENH:  
Ken Leiter (Civ ARL/CISD) kleiter committed
16 17 18
	mGeometry(XdmfGeometry::New()),
	mTopology(XdmfTopology::New()),
	mName("Grid")
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
19 20 21 22 23 24 25 26 27
{
	std::cout << "Created Grid " << this << std::endl;
}

XdmfGrid::~XdmfGrid()
{
  std::cout << "Deleted Grid " << this << std::endl;
}

28 29 30 31 32 33 34 35 36
boost::shared_ptr<XdmfAttribute> XdmfGrid::getAttribute(unsigned int index)
{
	if(index >= mAttributes.size())
	{
		assert(false);
		// Out of range --- should we throw exceptions?
	}
	return mAttributes[index];
}
37

38 39 40 41 42 43 44 45 46
boost::shared_ptr<const XdmfAttribute> XdmfGrid::getAttribute(unsigned int index) const
{
	if(index >= mAttributes.size())
	{
		assert(false);
		// Out of range --- should we throw exceptions?
	}
	return mAttributes[index];
}
47 48 49 50 51 52 53 54 55 56 57

boost::shared_ptr<XdmfGeometry> XdmfGrid::getGeometry()
{
	return mGeometry;
}

boost::shared_ptr<const XdmfGeometry> XdmfGrid::getGeometry() const
{
	return mGeometry;
}

58 59 60 61 62 63 64
std::map<std::string, std::string> XdmfGrid::getItemProperties() const
{
	std::map<std::string, std::string> gridProperties;
	gridProperties["Name"] = mName;
	return gridProperties;
}

65
std::string XdmfGrid::getName() const
66
{
67
	return mName;
68 69
}

70
unsigned int XdmfGrid::getNumberOfAttributes() const
71
{
72
	return mAttributes.size();
73 74
}

75
boost::shared_ptr<XdmfTopology> XdmfGrid::getTopology()
76
{
77
	return mTopology;
78
}
79

80
boost::shared_ptr<const XdmfTopology> XdmfGrid::getTopology() const
81
{
82
	return mTopology;
83 84
}

85 86 87 88 89
void XdmfGrid::insert(boost::shared_ptr<XdmfAttribute> attribute)
{
	mAttributes.push_back(attribute);
}

90
void XdmfGrid::setGeometry(boost::shared_ptr<XdmfGeometry> geometry)
91
{
92
	mGeometry = geometry;
93 94
}

95
void XdmfGrid::setName(const std::string & name)
96
{
97
	mName= name;
98 99
}

100
void XdmfGrid::setTopology(boost::shared_ptr<XdmfTopology> topology)
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
101
{
102
	mTopology = topology;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
103
}
104

105
void XdmfGrid::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
106
{
107 108
	mGeometry->accept(visitor);
	mTopology->accept(visitor);
109 110
	for(std::vector<boost::shared_ptr<XdmfAttribute> >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter)
	{
111
		(*iter)->accept(visitor);
112 113
	}
}