Subversion Repositories gelsvn

Rev

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

Rev 512 Rev 515
Line 15... Line 15...
15
#include <cstdint>
15
#include <cstdint>
16
 
16
 
17
namespace HMesh
17
namespace HMesh
18
{
18
{
19
    typedef uint32_t IndexType;  
19
    typedef uint32_t IndexType;  
20
    const IndexType NULL_INDEX =  UINT32_MAX;
20
    const IndexType INVALID_INDEX =  UINT32_MAX;
21
 
21
 
-
 
22
    template<typename T>
22
    class ItemID
23
    class ItemID
23
    {
24
    {
24
    public:
25
    public:
25
        ItemID(IndexType _index = NULL_INDEX);
26
        ItemID();
26
 
27
 
27
        bool operator ==(const ItemID& other) const;
28
        bool operator ==(const ItemID& other) const;
28
        bool operator !=(const ItemID& other) const;
29
        bool operator !=(const ItemID& other) const;
29
        bool operator >=(const ItemID& other) const;
-
 
30
        bool operator <=(const ItemID& other) const;
-
 
31
        bool operator <(const ItemID& other) const;
30
        bool operator <(const ItemID& other) const;
32
        bool operator >(const ItemID& other) const;
-
 
33
 
-
 
34
        ItemID& operator ++();
-
 
35
        ItemID& operator ++(int);
-
 
36
        ItemID& operator --();
-
 
37
        ItemID& operator --(int);
-
 
38
 
-
 
39
        bool valid() const;
-
 
40
        IndexType idx() const;
-
 
41
        void invalidate();
-
 
42
 
31
 
43
    private:
32
    private:
44
        IndexType index;
33
        ItemID(IndexType index);
45
    };
-
 
46
 
34
 
47
    class VertexID : public ItemID
35
        friend class ConnectivityKernel;
48
    {
-
 
49
    public:
-
 
50
        VertexID(IndexType _index = NULL_INDEX) : ItemID(_index){}
36
        template<typename ITEM, typename ITEMID>
51
    };
37
        friend class AttributeVector;
52
 
38
 
53
    class FaceID : public ItemID
39
        IndexType index;
54
    {
-
 
55
    public:
-
 
56
        FaceID(IndexType _index = NULL_INDEX) : ItemID(_index){}
-
 
57
    };
40
    };
58
 
41
 
-
 
42
    struct VertexTag {};
-
 
43
    struct FaceTag {};
59
    class HalfEdgeID : public ItemID
44
    struct HalfEdgeTag {};
60
    {
45
 
-
 
46
    typedef ItemID<VertexTag> VertexID;
61
    public:
47
    typedef ItemID<FaceTag> FaceID;
62
        HalfEdgeID(IndexType _index = NULL_INDEX) : ItemID(_index){}
48
    typedef ItemID<HalfEdgeTag> HalfEdgeID;
63
    };
49
 
-
 
50
    static const VertexID InvalidVertexID;
-
 
51
    static const FaceID InvalidFaceID;
-
 
52
    static const HalfEdgeID InvalidHalfEdgeID;
64
 
53
 
-
 
54
    template<typename T>
65
    inline ItemID::ItemID(IndexType _index) : index(_index){}
55
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}
66
 
56
 
-
 
57
    template<typename T>
-
 
58
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}
-
 
59
 
-
 
60
    template<typename T>
67
    inline bool ItemID::operator ==(const ItemID& other) const
61
    inline bool ItemID<T>::operator ==(const ItemID& other) const
68
    { return index == other.index; }
62
    { return index == other.index; }
69
 
63
 
-
 
64
    template<typename T>
70
    inline bool ItemID::operator !=(const ItemID& other) const
65
    inline bool ItemID<T>::operator !=(const ItemID& other) const
71
    { return index != other.index; }
66
    { return index != other.index; }
72
 
67
 
73
    inline bool ItemID::operator >=(const ItemID& other) const
-
 
74
    { return index >= other.index; }
-
 
75
 
-
 
76
    inline bool ItemID::operator <=(const ItemID& other) const
-
 
77
    { return index <= other.index; }
68
    template<typename T>
78
 
-
 
79
    inline bool ItemID::operator <(const ItemID& other) const
69
    inline bool ItemID<T>::operator <(const ItemID& other) const
80
    { return index < other.index; }
70
    { return index < other.index; }
81
 
71
 
82
    inline bool ItemID::operator >(const ItemID& other) const
-
 
83
    { return index > other.index; }
-
 
84
 
-
 
85
    inline ItemID& ItemID::operator ++()
-
 
86
    { 
-
 
87
        ++index;
-
 
88
        return *this;
-
 
89
    }
-
 
90
 
-
 
91
    inline ItemID& ItemID::operator ++(int)
-
 
92
    {
-
 
93
        ++(*this);
-
 
94
        return *this;
-
 
95
    }
-
 
96
 
-
 
97
    inline ItemID& ItemID::operator --()
-
 
98
    { 
-
 
99
        --index; 
-
 
100
        return *this;
-
 
101
    }
-
 
102
 
-
 
103
    inline ItemID& ItemID::operator --(int)
-
 
104
    {
-
 
105
        --(*this);
-
 
106
        return *this;
-
 
107
    }
-
 
108
 
-
 
109
    inline bool ItemID::valid() const
-
 
110
    { return index != NULL_INDEX; }
-
 
111
 
-
 
112
    inline void ItemID::invalidate()
-
 
113
    { index = NULL_INDEX; }
-
 
114
 
-
 
115
    inline IndexType ItemID::idx() const
-
 
116
    { return index; }
-
 
117
 
72
 
118
}
73
}
119
 
74
 
120
#endif
75
#endif
121
 
76