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
 
578 jab 7
/**
8
 * @file ItemID.h
9
 * @brief Base class for the integer IDs used to refer to mesh entities.
10
 */
572 jab 11
 
12
 
511 s042372 13
#ifndef __HMESH_ITEMID_H__
14
#define __HMESH_ITEMID_H__
15
 
546 jab 16
#include <iostream>
17
 
511 s042372 18
namespace HMesh
19
{
526 jab 20
	template<typename ITEM, typename ITEMID>
21
	class AttributeVector;
22
 
546 jab 23
	struct VertexTag {};
24
    struct FaceTag {};
25
    struct HalfEdgeTag {};
26
 
515 s042372 27
    template<typename T>
512 s042372 28
    class ItemID
29
    {
30
    public:
515 s042372 31
        ItemID();
511 s042372 32
 
512 s042372 33
        bool operator ==(const ItemID& other) const;
34
        bool operator !=(const ItemID& other) const;
35
        bool operator <(const ItemID& other) const;
547 jab 36
 
37
		template<typename X>
38
		friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
546 jab 39
 
515 s042372 40
    private:
585 jab 41
        typedef size_t IndexType;
42
        static const IndexType INVALID_INDEX =  -1;
518 s042372 43
 
515 s042372 44
        ItemID(IndexType index);
511 s042372 45
 
515 s042372 46
        friend class ConnectivityKernel;
47
        template<typename ITEM, typename ITEMID>
48
        friend class AttributeVector;
511 s042372 49
 
512 s042372 50
        IndexType index;
51
    };
511 s042372 52
 
53
 
515 s042372 54
    typedef ItemID<VertexTag> VertexID;
55
    typedef ItemID<FaceTag> FaceID;
56
    typedef ItemID<HalfEdgeTag> HalfEdgeID;
511 s042372 57
 
515 s042372 58
    static const VertexID InvalidVertexID;
59
    static const FaceID InvalidFaceID;
60
    static const HalfEdgeID InvalidHalfEdgeID;
511 s042372 61
 
515 s042372 62
    template<typename T>
63
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}
511 s042372 64
 
515 s042372 65
    template<typename T>
66
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}
67
 
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
 
515 s042372 76
    template<typename T>
77
    inline bool ItemID<T>::operator <(const ItemID& other) const
512 s042372 78
    { return index < other.index; }
511 s042372 79
 
547 jab 80
	template<typename T>
81
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
546 jab 82
	{
83
		return (os << iid.index);
84
	}
85
 
511 s042372 86
}
87
 
88
#endif