XdmfGeometryType.cpp 3.23 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::VXVY()
48
{
49 50
	static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("VXVY", 2));
	return p;
51
}
52

53
XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimensions) :
54 55
	mDimensions(dimensions),
	mName(name)
56 57 58
{
}

59 60 61 62
XdmfGeometryType::~XdmfGeometryType()
{
}

63
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
64
{
65 66 67 68 69 70
	std::map<std::string, std::string>::const_iterator type = itemProperties.find("Type");
	if(type == itemProperties.end())
	{
		type = itemProperties.find("GeometryType");
	}

71 72 73
	if(type != itemProperties.end())
	{
		const std::string typeVal = type->second;
74
		if(typeVal.compare("None") == 0)
75 76 77 78 79 80 81 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
		{
			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("VXVY") == 0)
		{
			return VXVY();
		}
		else
		{
			assert(false);
		}
	}
	assert(false);
}
109 110 111 112 113 114 115 116 117 118 119

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);
}

120 121 122 123 124 125 126 127 128 129 130
bool XdmfGeometryType::IsEqual(boost::shared_ptr<XdmfGeometryType> geometryType)
{
        if(geometryType == NULL) return false;
        if(this == geometryType.get()
           &&   mDimensions == geometryType->mDimensions
	   &&	mName == geometryType->mName
        ) return true;
        return false;
}


131
unsigned int XdmfGeometryType::getDimensions() const
132 133 134 135
{
	return mDimensions;
}

136 137 138 139 140
std::string XdmfGeometryType::getName() const
{
	return mName;
}

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