XdmfVisitor.cpp 1.77 KB
Newer Older
1
2
3
// Kenneth Leiter
// Xdmf Smart Pointer Test

4
5
6
7
#include "XdmfAttribute.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfTopology.hpp"
8
9
#include "XdmfVisitor.hpp"

10
11
12
13
14
#include <iomanip>

XdmfVisitor::XdmfVisitor() :
	mTabIndex(0),
	xmlData()
15
{
16
	std::cout << "Created Visitor " << this << std::endl;
17
18
19
20
}

XdmfVisitor::~XdmfVisitor()
{
21
22
23
24
25
	std::cout << "Deleted Visitor " << this << std::endl;
}

void XdmfVisitor::visit(const XdmfAttribute * const attribute)
{
26
	xmlData << std::setw(mTabIndex) << "" << "<Attribute> Name=\"" << attribute->getName() << "\" AttributeType=\"" << attribute->getAttributeTypeAsString() << "\" Center=\"" << attribute->getAttributeCenterAsString() << "\">\n";
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
	xmlData << std::setw(mTabIndex) << "" << "</Attribute>\n";
}

void XdmfVisitor::visit(const XdmfGeometry * const geometry)
{
	xmlData << std::setw(mTabIndex) << "" << "<Geometry GeometryType=\"" << geometry->getGeometryTypeAsString() << "\">\n";
	xmlData << std::setw(mTabIndex) << "" << "</Geometry>\n";
}

void XdmfVisitor::visit(const XdmfGrid * const grid)
{
	xmlData << std::setw(mTabIndex) << "" << "<Grid Name=\"" << grid->getName() <<"\">\n";
	mTabIndex++;
	visit(grid->getGeometry().get());
	visit(grid->getTopology().get());
42
43
44
45
	for(unsigned int i=0; i<grid->getNumberOfAttribute(); i++)
	{
		visit(grid->getAttribute(i).get());
	}
46
47
	mTabIndex--;
	xmlData << std::setw(mTabIndex) << "" << "</Grid>\n";
48
49
}

50
void XdmfVisitor::visit(const XdmfTopology * const topology)
51
{
52
53
	xmlData << std::setw(mTabIndex) << "" << "<Topology TopologyType=\"" << topology->getTopologyTypeAsString() << "\" NumberOfElements=" << topology->getNumberElements() << "\">\n";
	xmlData << std::setw(mTabIndex) << "" << "</Topology>\n";
54
55
}

56
57
const std::string XdmfVisitor::printSelf() const
{
58
	return "XdmfVisitor:\n" + xmlData.str();
59
}