00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef OPENMESH_HANDLES_HH
00032 #define OPENMESH_HANDLES_HH
00033
00034
00035
00036
00037 #include <OpenMesh/Core/System/config.hh>
00038 #include <iostream>
00039
00040
00041
00042
00043 namespace OpenMesh {
00044
00045
00046
00047
00049 class BaseHandle
00050 {
00051 public:
00052
00053 explicit BaseHandle(int _idx=-1) : idx_(_idx) {}
00054
00056 int idx() const { return idx_; }
00057
00059 bool is_valid() const { return idx_ != -1; }
00060
00062 void reset() { idx_=-1; }
00064 void invalidate() { idx_ = -1; }
00065
00066 bool operator==(const BaseHandle& _rhs) const {
00067 return idx_ == _rhs.idx_;
00068 }
00069
00070 bool operator!=(const BaseHandle& _rhs) const {
00071 return idx_ != _rhs.idx_;
00072 }
00073
00074 bool operator<(const BaseHandle& _rhs) const {
00075 return idx_ < _rhs.idx_;
00076 }
00077
00078
00079
00080 void __increment() { ++idx_; }
00081 void __decrement() { --idx_; }
00082
00083
00084 private:
00085
00086 int idx_;
00087 };
00088
00089
00090
00091
00093 inline std::ostream& operator<<(std::ostream& _os, const BaseHandle& _hnd)
00094 {
00095 return (_os << _hnd.idx());
00096 }
00097
00098
00099
00100
00101
00103 struct VertexHandle : public BaseHandle
00104 {
00105 explicit VertexHandle(int _idx=-1) : BaseHandle(_idx) {}
00106 };
00107
00108
00110 struct HalfedgeHandle : public BaseHandle
00111 {
00112 explicit HalfedgeHandle(int _idx=-1) : BaseHandle(_idx) {}
00113 };
00114
00115
00117 struct EdgeHandle : public BaseHandle
00118 {
00119 explicit EdgeHandle(int _idx=-1) : BaseHandle(_idx) {}
00120 };
00121
00122
00124 struct FaceHandle : public BaseHandle
00125 {
00126 explicit FaceHandle(int _idx=-1) : BaseHandle(_idx) {}
00127 };
00128
00129
00130
00131 }
00132
00133 #endif // OPENMESH_HANDLES_HH
00134