XdmfGeometryType.cpp 3.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * XdmfGeometryType.cpp
 *
 *  Created on: Jan 29, 2010
 *      Author: kleiter
 */

#include "XdmfGeometryType.hpp"

// Supported XdmfGeometryTypes
11
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::NoGeometryType()
12
{
13 14
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("None", 0));
	return p;
15
}
16

17
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::XYZ()
18
{
19 20
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("XYZ", 3));
	return p;
21
}
22

23
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::XY()
24
{
25 26
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("XY", 2));
	return p;
27
}
28

29
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::X_Y_Z()
30
{
31 32
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("X_Y_Z", 3));
	return p;
33
}
34

35
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::X_Y()
36
{
37 38
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("X_Y", 2));
	return p;
39
}
40

41
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::VXVYVZ()
42
{
43 44
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("VXVYVZ", 3));
	return p;
45
}
46

47
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::Origin_DXDYDZ()
48
{
49 50
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("ORIGIN_DXDYDZ", 3));
	return p;
51
}
52

53
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::VXVY()
54
{
55 56
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("VXVY", 2));
	return p;
57
}
58

59
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::Origin_DXDY()
60
{
61 62
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("ORIGIN_DXDY", 2));
	return p;
63 64 65 66 67
}

XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimensions) :
	mName(name),
	mDimensions(dimensions)
68 69 70
{
}

71 72 73 74
XdmfGeometryType::~XdmfGeometryType()
{
}

75
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
76 77 78 79 80
{
	std::map<std::string, std::string>::const_iterator type = itemProperties.find("GeometryType");
	if(type != itemProperties.end())
	{
		const std::string typeVal = type->second;
81
		if(typeVal.compare("None") == 0)
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
		{
			return NoGeometryType();
		}
		else if(typeVal.compare("XYZ") == 0)
		{
			return XYZ();
		}
		else if(typeVal.compare("XY") == 0)
		{
			return XY();
		}
		else if(typeVal.compare("X_Y_Z") == 0)
		{
			return X_Y_Z();
		}
		else if(typeVal.compare("X_Y") == 0)
		{
			return X_Y();
		}
		else if(typeVal.compare("VXVYVZ") == 0)
		{
			return VXVYVZ();
		}
		else if(typeVal.compare("ORIGIN_DXDYDZ") == 0)
		{
			return Origin_DXDYDZ();
		}
		else if(typeVal.compare("VXVY") == 0)
		{
			return VXVY();
		}
		else if(typeVal.compare("ORIGIN_DXDY") == 0)
		{
			return Origin_DXDY();
		}
		else
		{
			assert(false);
		}
	}
	assert(false);
}
124 125 126 127 128 129 130 131 132 133 134

bool XdmfGeometryType::operator==(const XdmfGeometryType& geometryType) const
{
	return mDimensions == geometryType.mDimensions && mName.compare(geometryType.mName) == 0;
}

bool XdmfGeometryType::operator!=(const XdmfGeometryType& geometryType) const
{
	return !this->operator==(geometryType);
}

135
unsigned int XdmfGeometryType::getDimensions() const
136 137 138 139
{
	return mDimensions;
}

140 141
void XdmfGeometryType::getProperties(std::map<std::string, std::string> & collectedProperties) const
{
142
	collectedProperties["GeometryType"] = mName;
143
}