Subversion Repositories gelsvn

Rev

Rev 511 | Rev 515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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