Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Handles.hh

00001 //=============================================================================
00002 //                                                                            
00003 //                               OpenMesh                                     
00004 //      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen       
00005 //                           www.openmesh.org                                 
00006 //                                                                            
00007 //-----------------------------------------------------------------------------
00008 //                                                                            
00009 //                                License                                     
00010 //                                                                            
00011 //   This library is free software; you can redistribute it and/or modify it 
00012 //   under the terms of the GNU Library General Public License as published  
00013 //   by the Free Software Foundation, version 2.                             
00014 //                                                                             
00015 //   This library is distributed in the hope that it will be useful, but       
00016 //   WITHOUT ANY WARRANTY; without even the implied warranty of                
00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00018 //   Library General Public License for more details.                          
00019 //                                                                            
00020 //   You should have received a copy of the GNU Library General Public         
00021 //   License along with this library; if not, write to the Free Software       
00022 //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 
00023 //                                                                            
00024 //-----------------------------------------------------------------------------
00025 //                                                                            
00026 //   $Revision: 1.1.1.1 $
00027 //   $Date: 2004/09/06 12:35:20 $
00028 //                                                                            
00029 //=============================================================================
00030 
00031 #ifndef OPENMESH_HANDLES_HH
00032 #define OPENMESH_HANDLES_HH
00033 
00034 
00035 //== INCLUDES =================================================================
00036 
00037 #include <OpenMesh/Core/System/config.hh>
00038 #include <iostream>
00039 
00040 
00041 //== NAMESPACES ===============================================================
00042 
00043 namespace OpenMesh {
00044 
00045 //== CLASS DEFINITION =========================================================
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   // this is to be used only by the iterators
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 } // namespace OpenMesh
00132 //=============================================================================
00133 #endif // OPENMESH_HANDLES_HH
00134 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .