Subversion Repositories gelsvn

Rev

Rev 546 | Rev 572 | 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;
547 jab 35
 
36
		template<typename X>
37
		friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
546 jab 38
 
515 s042372 39
    private:
518 s042372 40
        typedef unsigned int IndexType;  
41
        static const IndexType INVALID_INDEX =  0xffffffff;
42
 
515 s042372 43
        ItemID(IndexType index);
511 s042372 44
 
515 s042372 45
        friend class ConnectivityKernel;
46
        template<typename ITEM, typename ITEMID>
47
        friend class AttributeVector;
511 s042372 48
 
512 s042372 49
        IndexType index;
50
    };
511 s042372 51
 
52
 
515 s042372 53
    typedef ItemID<VertexTag> VertexID;
54
    typedef ItemID<FaceTag> FaceID;
55
    typedef ItemID<HalfEdgeTag> HalfEdgeID;
511 s042372 56
 
515 s042372 57
    static const VertexID InvalidVertexID;
58
    static const FaceID InvalidFaceID;
59
    static const HalfEdgeID InvalidHalfEdgeID;
511 s042372 60
 
515 s042372 61
    template<typename T>
62
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}
511 s042372 63
 
515 s042372 64
    template<typename T>
65
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}
66
 
67
    template<typename T>
68
    inline bool ItemID<T>::operator ==(const ItemID& other) const
512 s042372 69
    { return index == other.index; }
511 s042372 70
 
515 s042372 71
    template<typename T>
72
    inline bool ItemID<T>::operator !=(const ItemID& other) const
512 s042372 73
    { return index != other.index; }
511 s042372 74
 
515 s042372 75
    template<typename T>
76
    inline bool ItemID<T>::operator <(const ItemID& other) const
512 s042372 77
    { return index < other.index; }
511 s042372 78
 
547 jab 79
	template<typename T>
80
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
546 jab 81
	{
82
		return (os << iid.index);
83
	}
84
 
511 s042372 85
}
86
 
87
#endif