Subversion Repositories gelsvn

Rev

Rev 511 | Rev 515 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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