GEL
2
GEL is a library for Geometry and Linear Algebra
|
00001 /* ----------------------------------------------------------------------- * 00002 * This file is part of GEL, www.imm.dtu.dk/GEL 00003 * Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics 00004 * 00005 * Principal authors: 00006 * Christian Thode Larsen (thode2d@gmail.com) 00007 * J. Andreas Baerentzen (jab@imm.dtu.dk) 00008 * 00009 * See LICENSE.txt for licensing information 00010 * ----------------------------------------------------------------------- */ 00011 00012 #ifndef __HMESH_ITEMID_H__ 00013 #define __HMESH_ITEMID_H__ 00014 00015 #include <iostream> 00016 00017 namespace HMesh 00018 { 00019 template<typename ITEM, typename ITEMID> 00020 class AttributeVector; 00021 00022 struct VertexTag {}; 00023 struct FaceTag {}; 00024 struct HalfEdgeTag {}; 00025 00026 template<typename T> 00027 class ItemID 00028 { 00029 public: 00030 ItemID(); 00031 00032 bool operator ==(const ItemID& other) const; 00033 bool operator !=(const ItemID& other) const; 00034 bool operator <(const ItemID& other) const; 00035 00036 template<typename X> 00037 friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&); 00038 00039 private: 00040 typedef unsigned int IndexType; 00041 static const IndexType INVALID_INDEX = 0xffffffff; 00042 00043 ItemID(IndexType index); 00044 00045 friend class ConnectivityKernel; 00046 template<typename ITEM, typename ITEMID> 00047 friend class AttributeVector; 00048 00049 IndexType index; 00050 }; 00051 00052 00053 typedef ItemID<VertexTag> VertexID; 00054 typedef ItemID<FaceTag> FaceID; 00055 typedef ItemID<HalfEdgeTag> HalfEdgeID; 00056 00057 static const VertexID InvalidVertexID; 00058 static const FaceID InvalidFaceID; 00059 static const HalfEdgeID InvalidHalfEdgeID; 00060 00061 template<typename T> 00062 inline ItemID<T>::ItemID() : index(INVALID_INDEX){} 00063 00064 template<typename T> 00065 inline ItemID<T>::ItemID(IndexType _index) : index(_index){} 00066 00067 template<typename T> 00068 inline bool ItemID<T>::operator ==(const ItemID& other) const 00069 { return index == other.index; } 00070 00071 template<typename T> 00072 inline bool ItemID<T>::operator !=(const ItemID& other) const 00073 { return index != other.index; } 00074 00075 template<typename T> 00076 inline bool ItemID<T>::operator <(const ItemID& other) const 00077 { return index < other.index; } 00078 00079 template<typename T> 00080 inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid) 00081 { 00082 return (os << iid.index); 00083 } 00084 00085 } 00086 00087 #endif