Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
512 s042372 1
/* ----------------------------------------------------------------------- *
572 jab 2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
512 s042372 5
 * ----------------------------------------------------------------------- */
511 s042372 6
 
572 jab 7
 
8
 
511 s042372 9
#ifndef __HMESH_ITEMID_H__
10
#define __HMESH_ITEMID_H__
11
 
546 jab 12
#include <iostream>
13
 
511 s042372 14
namespace HMesh
15
{
526 jab 16
	template<typename ITEM, typename ITEMID>
17
	class AttributeVector;
18
 
546 jab 19
	struct VertexTag {};
20
    struct FaceTag {};
21
    struct HalfEdgeTag {};
22
 
515 s042372 23
    template<typename T>
512 s042372 24
    class ItemID
25
    {
26
    public:
515 s042372 27
        ItemID();
511 s042372 28
 
512 s042372 29
        bool operator ==(const ItemID& other) const;
30
        bool operator !=(const ItemID& other) const;
31
        bool operator <(const ItemID& other) const;
547 jab 32
 
33
		template<typename X>
34
		friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
546 jab 35
 
515 s042372 36
    private:
518 s042372 37
        typedef unsigned int IndexType;  
38
        static const IndexType INVALID_INDEX =  0xffffffff;
39
 
515 s042372 40
        ItemID(IndexType index);
511 s042372 41
 
515 s042372 42
        friend class ConnectivityKernel;
43
        template<typename ITEM, typename ITEMID>
44
        friend class AttributeVector;
511 s042372 45
 
512 s042372 46
        IndexType index;
47
    };
511 s042372 48
 
49
 
515 s042372 50
    typedef ItemID<VertexTag> VertexID;
51
    typedef ItemID<FaceTag> FaceID;
52
    typedef ItemID<HalfEdgeTag> HalfEdgeID;
511 s042372 53
 
515 s042372 54
    static const VertexID InvalidVertexID;
55
    static const FaceID InvalidFaceID;
56
    static const HalfEdgeID InvalidHalfEdgeID;
511 s042372 57
 
515 s042372 58
    template<typename T>
59
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}
511 s042372 60
 
515 s042372 61
    template<typename T>
62
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}
63
 
64
    template<typename T>
65
    inline bool ItemID<T>::operator ==(const ItemID& other) const
512 s042372 66
    { return index == other.index; }
511 s042372 67
 
515 s042372 68
    template<typename T>
69
    inline bool ItemID<T>::operator !=(const ItemID& other) const
512 s042372 70
    { return index != other.index; }
511 s042372 71
 
515 s042372 72
    template<typename T>
73
    inline bool ItemID<T>::operator <(const ItemID& other) const
512 s042372 74
    { return index < other.index; }
511 s042372 75
 
547 jab 76
	template<typename T>
77
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
546 jab 78
	{
79
		return (os << iid.index);
80
	}
81
 
511 s042372 82
}
83
 
84
#endif