Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
511 s042372 1
/*
2
* Written by Christian Thode Larsen 2009-2010
3
* Contact: thode2d@gmail.com
4
* Based on original work by J. Andreas Baerentzen
5
* Inspired by OpenMesh (www.openmesh.org)
6
*/
7
 
8
#ifndef __HMESH_ITEMID_H__
9
#define __HMESH_ITEMID_H__
10
 
11
#include <cstdint>
12
 
13
namespace HMesh
14
{
15
	typedef uint32_t IndexType;  
16
	const IndexType NULL_INDEX =  UINT32_MAX;
17
 
18
	class ItemID
19
	{
20
	public:
21
		ItemID(IndexType _index = NULL_INDEX);
22
 
23
		bool operator ==(const ItemID& other) const;
24
		bool operator !=(const ItemID& other) const;
25
		bool operator >=(const ItemID& other) const;
26
		bool operator <=(const ItemID& other) const;
27
		bool operator <(const ItemID& other) const;
28
		bool operator >(const ItemID& other) const;
29
 
30
		ItemID& operator ++();
31
		ItemID& operator ++(int);
32
		ItemID& operator --();
33
		ItemID& operator --(int);
34
 
35
		bool valid() const;
36
		IndexType idx() const;
37
		void invalidate();
38
 
39
	private:
40
		IndexType index;
41
	};
42
 
43
	class VertexID : public ItemID
44
	{
45
	public:
46
		VertexID(IndexType _index = NULL_INDEX) : ItemID(_index){}
47
	};
48
 
49
	class FaceID : public ItemID
50
	{
51
	public:
52
		FaceID(IndexType _index = NULL_INDEX) : ItemID(_index){}
53
	};
54
 
55
	class HalfEdgeID : public ItemID
56
	{
57
	public:
58
		HalfEdgeID(IndexType _index = NULL_INDEX) : ItemID(_index){}
59
	};
60
 
61
	inline ItemID::ItemID(IndexType _index) : index(_index){}
62
 
63
	inline bool ItemID::operator ==(const ItemID& other) const
64
	{ return index == other.index; }
65
 
66
	inline bool ItemID::operator !=(const ItemID& other) const
67
	{ return index != other.index; }
68
 
69
	inline bool ItemID::operator >=(const ItemID& other) const
70
	{ return index >= other.index; }
71
 
72
	inline bool ItemID::operator <=(const ItemID& other) const
73
	{ return index <= other.index; }
74
 
75
	inline bool ItemID::operator <(const ItemID& other) const
76
	{ return index < other.index; }
77
 
78
	inline bool ItemID::operator >(const ItemID& other) const
79
	{ return index > other.index; }
80
 
81
	inline ItemID& ItemID::operator ++()
82
	{ 
83
		++index;
84
		return *this;
85
	}
86
 
87
	inline ItemID& ItemID::operator ++(int)
88
	{
89
		++(*this);
90
		return *this;
91
	}
92
 
93
	inline ItemID& ItemID::operator --()
94
	{ 
95
		--index; 
96
		return *this;
97
	}
98
 
99
	inline ItemID& ItemID::operator --(int)
100
	{
101
		--(*this);
102
		return *this;
103
	}
104
 
105
	inline bool ItemID::valid() const
106
	{ return index != NULL_INDEX; }
107
 
108
	inline void ItemID::invalidate()
109
	{ index = NULL_INDEX; }
110
 
111
	inline IndexType ItemID::idx() const
112
	{ return index; }
113
 
114
}
115
 
116
#endif