Subversion Repositories gelsvn

Rev

Rev 572 | Rev 585 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/* ----------------------------------------------------------------------- *
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
 * Copyright (C) the authors and DTU Informatics
 * For license and list of authors, see ../../doc/intro.pdf
 * ----------------------------------------------------------------------- */

/**
 * @file ItemID.h
 * @brief Base class for the integer IDs used to refer to mesh entities.
 */


#ifndef __HMESH_ITEMID_H__
#define __HMESH_ITEMID_H__

#include <iostream>

namespace HMesh
{
        template<typename ITEM, typename ITEMID>
        class AttributeVector;
        
        struct VertexTag {};
    struct FaceTag {};
    struct HalfEdgeTag {};
        
    template<typename T>
    class ItemID
    {
    public:
        ItemID();

        bool operator ==(const ItemID& other) const;
        bool operator !=(const ItemID& other) const;
        bool operator <(const ItemID& other) const;

                template<typename X>
                friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
                
    private:
        typedef unsigned int IndexType;  
        static const IndexType INVALID_INDEX =  0xffffffff;

        ItemID(IndexType index);

        friend class ConnectivityKernel;
        template<typename ITEM, typename ITEMID>
        friend class AttributeVector;

        IndexType index;
    };


    typedef ItemID<VertexTag> VertexID;
    typedef ItemID<FaceTag> FaceID;
    typedef ItemID<HalfEdgeTag> HalfEdgeID;

    static const VertexID InvalidVertexID;
    static const FaceID InvalidFaceID;
    static const HalfEdgeID InvalidHalfEdgeID;

    template<typename T>
    inline ItemID<T>::ItemID() : index(INVALID_INDEX){}

    template<typename T>
    inline ItemID<T>::ItemID(IndexType _index) : index(_index){}

    template<typename T>
    inline bool ItemID<T>::operator ==(const ItemID& other) const
    { return index == other.index; }

    template<typename T>
    inline bool ItemID<T>::operator !=(const ItemID& other) const
    { return index != other.index; }

    template<typename T>
    inline bool ItemID<T>::operator <(const ItemID& other) const
    { return index < other.index; }

        template<typename T>
        inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
        {
                return (os << iid.index);
        }
        
}

#endif

Generated by GNU Enscript 1.6.6.