512 |
s042372 |
1 |
/* ----------------------------------------------------------------------- *
|
|
|
2 |
* This file is part of GEL, www.imm.dtu.dk/GEL
|
|
|
3 |
* Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics
|
|
|
4 |
*
|
|
|
5 |
* Principal authors:
|
|
|
6 |
* Christian Thode Larsen (thode2d@gmail.com)
|
|
|
7 |
* J. Andreas Baerentzen (jab@imm.dtu.dk)
|
|
|
8 |
*
|
|
|
9 |
* See LICENSE.txt for licensing information
|
|
|
10 |
* ----------------------------------------------------------------------- */
|
511 |
s042372 |
11 |
#ifndef __HMESH_HALFEDGEWALKER_H__
|
|
|
12 |
#define __HMESH_HALFEDGEWALKER_H__
|
|
|
13 |
|
|
|
14 |
#include "ConnectivityKernel.h"
|
|
|
15 |
|
|
|
16 |
namespace HMesh
|
|
|
17 |
{
|
512 |
s042372 |
18 |
class HalfEdgeWalker
|
|
|
19 |
{
|
|
|
20 |
public:
|
|
|
21 |
HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current);
|
511 |
s042372 |
22 |
|
512 |
s042372 |
23 |
HalfEdgeWalker next() const;
|
|
|
24 |
HalfEdgeWalker prev() const;
|
|
|
25 |
HalfEdgeWalker opp() const;
|
511 |
s042372 |
26 |
|
512 |
s042372 |
27 |
HalfEdgeWalker circulate_vertex_cw() const;
|
|
|
28 |
HalfEdgeWalker circulate_vertex_ccw() const;
|
511 |
s042372 |
29 |
|
512 |
s042372 |
30 |
HalfEdgeWalker circulate_face_cw() const;
|
|
|
31 |
HalfEdgeWalker circulate_face_ccw() const;
|
511 |
s042372 |
32 |
|
512 |
s042372 |
33 |
bool full_circle() const;
|
|
|
34 |
IndexType no_steps() const;
|
511 |
s042372 |
35 |
|
512 |
s042372 |
36 |
VertexID vertex() const;
|
|
|
37 |
FaceID face() const;
|
|
|
38 |
HalfEdgeID halfedge() const;
|
511 |
s042372 |
39 |
|
512 |
s042372 |
40 |
HalfEdgeWalker operator =(const HalfEdgeWalker& w);
|
511 |
s042372 |
41 |
|
512 |
s042372 |
42 |
private:
|
|
|
43 |
const ConnectivityKernel* const ck;
|
|
|
44 |
HalfEdgeID const last;
|
|
|
45 |
HalfEdgeID current;
|
|
|
46 |
IndexType counter;
|
511 |
s042372 |
47 |
|
512 |
s042372 |
48 |
HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current, HalfEdgeID _last, IndexType _counter);
|
|
|
49 |
};
|
511 |
s042372 |
50 |
|
512 |
s042372 |
51 |
inline HalfEdgeWalker::HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current)
|
|
|
52 |
: ck(&_ck), current(_current), last(_current), counter(0){}
|
511 |
s042372 |
53 |
|
512 |
s042372 |
54 |
inline HalfEdgeWalker::HalfEdgeWalker(const ConnectivityKernel& _ck, HalfEdgeID _current, HalfEdgeID _last, IndexType _counter)
|
|
|
55 |
: ck(&_ck), current(_current), last(_last), counter(_counter){}
|
511 |
s042372 |
56 |
|
512 |
s042372 |
57 |
inline HalfEdgeWalker HalfEdgeWalker::next() const
|
|
|
58 |
{ return HalfEdgeWalker(*ck, ck->next(current), last, counter + 1); }
|
511 |
s042372 |
59 |
|
512 |
s042372 |
60 |
inline HalfEdgeWalker HalfEdgeWalker::prev() const
|
|
|
61 |
{ return HalfEdgeWalker(*ck, ck->prev(current), last, counter + 1); }
|
511 |
s042372 |
62 |
|
512 |
s042372 |
63 |
inline HalfEdgeWalker HalfEdgeWalker::opp() const
|
|
|
64 |
{ return HalfEdgeWalker(*ck, ck->opp(current), last, counter + 1); }
|
511 |
s042372 |
65 |
|
512 |
s042372 |
66 |
inline HalfEdgeWalker HalfEdgeWalker::circulate_vertex_cw() const
|
|
|
67 |
{ return HalfEdgeWalker(*ck, ck->next(ck->opp(current)), last, counter + 1); }
|
511 |
s042372 |
68 |
|
512 |
s042372 |
69 |
inline HalfEdgeWalker HalfEdgeWalker::circulate_vertex_ccw() const
|
|
|
70 |
{ return HalfEdgeWalker(*ck, ck->opp(ck->prev(current)), last, counter + 1); }
|
511 |
s042372 |
71 |
|
512 |
s042372 |
72 |
inline HalfEdgeWalker HalfEdgeWalker::circulate_face_cw() const
|
|
|
73 |
{ return HalfEdgeWalker(*ck, ck->next(current), last, counter + 1); }
|
511 |
s042372 |
74 |
|
512 |
s042372 |
75 |
inline HalfEdgeWalker HalfEdgeWalker::circulate_face_ccw() const
|
|
|
76 |
{ return HalfEdgeWalker(*ck, ck->prev(current), last, counter + 1); }
|
511 |
s042372 |
77 |
|
512 |
s042372 |
78 |
inline bool HalfEdgeWalker::full_circle() const
|
|
|
79 |
{ return (counter > 0 && current == last) ? true : false; }
|
511 |
s042372 |
80 |
|
512 |
s042372 |
81 |
inline IndexType HalfEdgeWalker::no_steps() const
|
|
|
82 |
{ return counter; }
|
511 |
s042372 |
83 |
|
512 |
s042372 |
84 |
inline VertexID HalfEdgeWalker::vertex() const
|
|
|
85 |
{ return ck->vert(current); }
|
511 |
s042372 |
86 |
|
512 |
s042372 |
87 |
inline FaceID HalfEdgeWalker::face() const
|
|
|
88 |
{ return ck->face(current); }
|
511 |
s042372 |
89 |
|
512 |
s042372 |
90 |
inline HalfEdgeID HalfEdgeWalker::halfedge() const
|
|
|
91 |
{ return current; }
|
511 |
s042372 |
92 |
|
512 |
s042372 |
93 |
inline HalfEdgeWalker HalfEdgeWalker::operator =(const HalfEdgeWalker& w)
|
|
|
94 |
{
|
|
|
95 |
current = w.current;
|
|
|
96 |
counter = w.counter;
|
|
|
97 |
return *this;
|
|
|
98 |
}
|
511 |
s042372 |
99 |
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
#endif
|