Subversion Repositories gelsvn

Rev

Rev 526 | Rev 547 | 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
 
546 jab 15
#include <iostream>
16
 
511 s042372 17
namespace HMesh
18
{
526 jab 19
	template<typename ITEM, typename ITEMID>
20
	class AttributeVector;
21
 
546 jab 22
	struct VertexTag {};
23
    struct FaceTag {};
24
    struct HalfEdgeTag {};
25
 
515 s042372 26
    template<typename T>
512 s042372 27
    class ItemID
28
    {
29
    public:
515 s042372 30
        ItemID();
511 s042372 31
 
512 s042372 32
        bool operator ==(const ItemID& other) const;
33
        bool operator !=(const ItemID& other) const;
34
        bool operator <(const ItemID& other) const;
546 jab 35
 
36
		friend std::ostream& operator<<(std::ostream& os, const ItemID<FaceTag>&);
37
 
515 s042372 38
    private:
518 s042372 39
        typedef unsigned int IndexType;  
40
        static const IndexType INVALID_INDEX =  0xffffffff;
41
 
515 s042372 42
        ItemID(IndexType index);
511 s042372 43
 
515 s042372 44
        friend class ConnectivityKernel;
45
        template<typename ITEM, typename ITEMID>
46
        friend class AttributeVector;
511 s042372 47
 
512 s042372 48
        IndexType index;
49
    };
511 s042372 50
 
51
 
515 s042372 52
    typedef ItemID<VertexTag> VertexID;
53
    typedef ItemID<FaceTag> FaceID;
54
    typedef ItemID<HalfEdgeTag> HalfEdgeID;
511 s042372 55
 
515 s042372 56
    static const VertexID InvalidVertexID;
57
    static const FaceID InvalidFaceID;
58
    static const HalfEdgeID InvalidHalfEdgeID;
511 s042372 59
 
515 s042372 60
    template<typename T>
61
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}
511 s042372 62
 
515 s042372 63
    template<typename T>
64
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}
65
 
66
    template<typename T>
67
    inline bool ItemID<T>::operator ==(const ItemID& other) const
512 s042372 68
    { return index == other.index; }
511 s042372 69
 
515 s042372 70
    template<typename T>
71
    inline bool ItemID<T>::operator !=(const ItemID& other) const
512 s042372 72
    { return index != other.index; }
511 s042372 73
 
515 s042372 74
    template<typename T>
75
    inline bool ItemID<T>::operator <(const ItemID& other) const
512 s042372 76
    { return index < other.index; }
511 s042372 77
 
546 jab 78
	inline std::ostream& operator<<(std::ostream& os, const FaceID& iid)
79
	{
80
		return (os << iid.index);
81
	}
82
 
511 s042372 83
}
84
 
85
#endif