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 #ifndef __HMESH_HALFEDGEWALKER_H__ 00012 #define __HMESH_HALFEDGEWALKER_H__ 00013 00014 #include "ConnectivityKernel.h" 00015 00016 namespace HMesh 00017 { 00018 class HalfEdgeWalker 00019 { 00020 public: 00022 HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current); 00023 00025 HalfEdgeWalker next() const; 00027 HalfEdgeWalker prev() const; 00029 HalfEdgeWalker opp() const; 00030 00032 HalfEdgeWalker circulate_vertex_cw() const; 00034 HalfEdgeWalker circulate_vertex_ccw() const; 00035 00037 HalfEdgeWalker circulate_face_cw() const; 00039 HalfEdgeWalker circulate_face_ccw() const; 00040 00042 bool full_circle() const; 00043 00045 int no_steps() const; 00046 00048 VertexID vertex() const; 00050 FaceID face() const; 00052 HalfEdgeID halfedge() const; 00053 00055 HalfEdgeWalker operator =(const HalfEdgeWalker& w); 00056 00057 private: 00058 const ConnectivityKernel* ck; 00059 HalfEdgeID current; 00060 HalfEdgeID last; 00061 int counter; 00062 00063 HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current, HalfEdgeID _last, int _counter); 00064 }; 00065 00066 inline HalfEdgeWalker::HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current) 00067 : ck(&_ck), current(_current), last(_current), counter(0){} 00068 00069 inline HalfEdgeWalker::HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current, HalfEdgeID _last, int _counter) 00070 : ck(&_ck), current(_current), last(_last), counter(_counter){} 00071 00072 inline HalfEdgeWalker HalfEdgeWalker::next() const 00073 { return HalfEdgeWalker(*ck, ck->next(current), last, counter + 1); } 00074 00075 inline HalfEdgeWalker HalfEdgeWalker::prev() const 00076 { return HalfEdgeWalker(*ck, ck->prev(current), last, counter + 1); } 00077 00078 inline HalfEdgeWalker HalfEdgeWalker::opp() const 00079 { return HalfEdgeWalker(*ck, ck->opp(current), last, counter + 1); } 00080 00081 inline HalfEdgeWalker HalfEdgeWalker::circulate_vertex_cw() const 00082 { return HalfEdgeWalker(*ck, ck->next(ck->opp(current)), last, counter + 1); } 00083 00084 inline HalfEdgeWalker HalfEdgeWalker::circulate_vertex_ccw() const 00085 { return HalfEdgeWalker(*ck, ck->opp(ck->prev(current)), last, counter + 1); } 00086 00087 inline HalfEdgeWalker HalfEdgeWalker::circulate_face_cw() const 00088 { return HalfEdgeWalker(*ck, ck->prev(current), last, counter + 1); } 00089 00090 inline HalfEdgeWalker HalfEdgeWalker::circulate_face_ccw() const 00091 { return HalfEdgeWalker(*ck, ck->next(current), last, counter + 1); } 00092 00093 inline bool HalfEdgeWalker::full_circle() const 00094 { return (counter > 0 && current == last) ? true : false; } 00095 00096 inline int HalfEdgeWalker::no_steps() const 00097 { return counter; } 00098 00099 inline VertexID HalfEdgeWalker::vertex() const 00100 { return ck->vert(current); } 00101 00102 inline FaceID HalfEdgeWalker::face() const 00103 { return ck->face(current); } 00104 00105 inline HalfEdgeID HalfEdgeWalker::halfedge() const 00106 { return current; } 00107 00108 inline HalfEdgeWalker HalfEdgeWalker::operator =(const HalfEdgeWalker& w) 00109 { 00110 current = w.current; 00111 counter = w.counter; 00112 ck = w.ck; 00113 last = w.last; 00114 return *this; 00115 } 00116 00117 } 00118 00119 #endif