XdmfGrid.cpp 2.26 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
std::string XdmfGrid::getName() const
59
{
60
	return mName;
61 62 63
}


64
unsigned int XdmfGrid::getNumberOfAttributes() const
65
{
66
	return mAttributes.size();
67 68
}

69
boost::shared_ptr<XdmfTopology> XdmfGrid::getTopology()
70
{
71
	return mTopology;
72
}
73

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

79

80 81 82 83 84
void XdmfGrid::insert(boost::shared_ptr<XdmfAttribute> attribute)
{
	mAttributes.push_back(attribute);
}

85
std::string XdmfGrid::printSelf() const
86
{
87
	return "XdmfGrid containing a " + mGeometry->printSelf() + " and a " + mTopology->printSelf();
88 89
}

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 106 107 108 109 110 111 112 113 114
void XdmfGrid::traverse(boost::shared_ptr<XdmfVisitor> visitor) const
{
	mGeometry->write(visitor);
	mTopology->write(visitor);
	for(std::vector<boost::shared_ptr<XdmfAttribute> >::const_iterator iter = mAttributes.begin(); iter != mAttributes.end(); ++iter)
	{
		(*iter)->write(visitor);
	}
}

115 116
void XdmfGrid::write(boost::shared_ptr<XdmfVisitor> visitor) const
{
117
	visitor->visit(this, visitor);
118
}