00001 /*===========================================================================*\ 00002 * * 00003 * IsoEx * 00004 * Copyright (C) 2002 by Computer Graphics Group, RWTH Aachen * 00005 * www.rwth-graphics.de * 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 //============================================================================= 00027 // 00028 // CLASS Edge2VertexMapT 00029 // 00030 //============================================================================= 00031 00032 00033 #ifndef ISOEX_EDGE2VERTEXMAPT_HH 00034 #define ISOEX_EDGE2VERTEXMAPT_HH 00035 00036 00037 //== INCLUDES ================================================================= 00038 00039 #include <map> 00040 00041 //== NAMESPACES =============================================================== 00042 00043 namespace IsoEx { 00044 00045 //== CLASS DEFINITION ========================================================= 00046 00057 template <class PointIdx, class VertexHandle> 00058 class Edge2VertexMapT 00059 { 00060 public: 00061 00063 Edge2VertexMapT() {} 00064 00065 00067 void clear() { map_.clear(); } 00068 00070 void insert(PointIdx _p0, PointIdx _p1, VertexHandle _vhnd) 00071 { 00072 map_[EdgeKey(_p0, _p1)] = _vhnd; 00073 } 00074 00076 VertexHandle find(PointIdx _p0, PointIdx _p1) const 00077 { 00078 MyMapIterator it = map_.find(EdgeKey(_p0, _p1)); 00079 if (it != map_.end()) return it->second; 00080 else return VertexHandle(); 00081 } 00082 00083 00084 private: 00085 00086 class EdgeKey 00087 { 00088 public: 00089 00090 EdgeKey(PointIdx _p0, PointIdx _p1) { 00091 if (_p0 < _p1) { p0_ = _p0; p1_ = _p1; } 00092 else { p0_ = _p1; p1_ = _p0; } 00093 } 00094 00095 bool operator<(const EdgeKey& _rhs) const 00096 { 00097 if (p0_ != _rhs.p0_) 00098 return (p0_ < _rhs.p0_); 00099 else 00100 return (p1_ < _rhs.p1_); 00101 } 00102 00103 private: 00104 PointIdx p0_, p1_; 00105 }; 00106 00107 00108 typedef std::map<EdgeKey, VertexHandle> MyMap; 00109 typedef typename MyMap::const_iterator MyMapIterator; 00110 00111 MyMap map_; 00112 }; 00113 00114 00115 //============================================================================= 00116 } // namespace IsoEx 00117 //============================================================================= 00118 #endif // ISOEX_EDGE2VERTEXMAPT_HH defined 00119 //============================================================================= 00120