Subversion Repositories gelsvn

Rev

Rev 513 | Rev 518 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
12
#ifndef __HMESH_ITERATORS_H__
13
#define __HMESH_ITERATORS_H__
14
 
15
#include "ConnectivityKernel.h"
16
 
17
namespace HMesh
18
{
512 s042372 19
    class VertexIDIterator
20
    {
21
    public:
515 s042372 22
        typedef VertexID value_type;
23
 
24
        typedef std::bidirectional_iterator_tag iterator_category;
25
        typedef ptrdiff_t difference_type;
26
        typedef value_type reference;
27
        typedef value_type* pointer;
512 s042372 28
        /// constructor (default: skipping enabled)
29
        VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip = true);
511 s042372 30
 
512 s042372 31
        /// prefix increment 
32
        VertexIDIterator& operator ++();		
33
        /// postfix increment
34
        VertexIDIterator& operator ++(int);
35
        /// prefix decrement
36
        VertexIDIterator& operator --();
37
        /// postfix decrement
38
        VertexIDIterator& operator --(int);
511 s042372 39
 
512 s042372 40
        /// equal to
41
        bool operator ==(const VertexIDIterator& other) const;
42
        /// not equal to
43
        bool operator !=(const VertexIDIterator& other) const;
511 s042372 44
 
512 s042372 45
        /// indirection
46
        VertexID operator *();
47
        /// member by pointer
48
        VertexID* operator ->();
49
        /// cast
50
        //operator VertexID() const;
511 s042372 51
 
512 s042372 52
    private:
53
        const ConnectivityKernel* ck;
54
        VertexID id;
55
        bool skip;
56
    };
511 s042372 57
 
512 s042372 58
    class FaceIDIterator
59
    {
60
    public:
515 s042372 61
        typedef FaceID value_type;
62
 
63
        typedef std::bidirectional_iterator_tag iterator_category;
64
        typedef ptrdiff_t difference_type;
65
        typedef value_type reference;
66
        typedef value_type* pointer;
67
 
512 s042372 68
        /// constructor (default: skipping enabled)
69
        FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip = true);
511 s042372 70
 
512 s042372 71
        /// prefix increment
72
        FaceIDIterator& operator ++();
73
        /// postfix increment
74
        FaceIDIterator& operator ++(int);
75
        /// prefix decrement
76
        FaceIDIterator& operator --();
77
        /// postfix decrement
78
        FaceIDIterator& operator --(int);
511 s042372 79
 
512 s042372 80
        /// equal to
81
        bool operator ==(const FaceIDIterator& other) const;
82
        /// not equal to
83
        bool operator !=(const FaceIDIterator& other) const;
511 s042372 84
 
85
 
512 s042372 86
        /// indirection
87
        FaceID operator *();
88
        /// member by pointer
89
        FaceID* operator ->();
90
        /// cast
91
        //operator FaceID() const;
511 s042372 92
 
93
 
512 s042372 94
    private:
95
        const ConnectivityKernel* ck;
96
        FaceID id;
97
        bool skip;
98
    };
511 s042372 99
 
512 s042372 100
    class HalfEdgeIDIterator
101
    {
102
    public:
515 s042372 103
        typedef HalfEdgeID value_type;
104
 
105
        typedef std::bidirectional_iterator_tag iterator_category;
106
        typedef ptrdiff_t difference_type;
107
        typedef value_type reference;
108
        typedef value_type* pointer;
109
 
512 s042372 110
        /// constructor (default: skipping enabled)
111
        HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip = true);
511 s042372 112
 
512 s042372 113
        /// prefix increment
114
        HalfEdgeIDIterator& operator ++();
115
        /// postfix increment
116
        HalfEdgeIDIterator& operator ++(int);
117
        /// prefix decrement
118
        HalfEdgeIDIterator& operator --();
119
        /// postfix decrement
120
        HalfEdgeIDIterator& operator --(int);
511 s042372 121
 
512 s042372 122
        /// equal to
123
        bool operator ==(const HalfEdgeIDIterator& other) const;
124
        /// not equal to
125
        bool operator !=(const HalfEdgeIDIterator& other) const;
511 s042372 126
 
512 s042372 127
        /// indirection
128
        HalfEdgeID operator *();
129
        /// member by pointer
130
        HalfEdgeID* operator ->();
131
        /// cast
132
        //operator HalfEdgeID() const;
511 s042372 133
 
512 s042372 134
    private:
135
        const ConnectivityKernel* ck;
136
        HalfEdgeID id;
137
        bool skip;
138
    };
511 s042372 139
 
512 s042372 140
    inline VertexIDIterator::VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
511 s042372 141
 
142
 
512 s042372 143
    inline VertexIDIterator& VertexIDIterator::operator ++()
144
    {
145
        id = ck->vertices_next(id, skip);
146
        return *this;
147
    }
511 s042372 148
 
512 s042372 149
    inline VertexIDIterator& VertexIDIterator::operator ++(int)
150
    { return ++(*this); }
511 s042372 151
 
152
 
512 s042372 153
    inline VertexIDIterator& VertexIDIterator::operator --()
154
    {
155
        id = ck->vertices_prev(id, skip);
156
        return *this;
157
    }
511 s042372 158
 
512 s042372 159
    inline VertexIDIterator& VertexIDIterator::operator --(int)
160
    { return --(*this); }
511 s042372 161
 
162
 
512 s042372 163
    inline bool VertexIDIterator::operator ==(const VertexIDIterator& other) const
164
    { return ck == other.ck && id == other.id; }
511 s042372 165
 
512 s042372 166
    inline bool VertexIDIterator::operator !=(const VertexIDIterator& other) const
513 s042372 167
    { return ck != other.ck || id != other.id; }
511 s042372 168
 
169
 
512 s042372 170
    inline VertexID VertexIDIterator::operator *()
171
    { return id; }
511 s042372 172
 
512 s042372 173
    inline VertexID* VertexIDIterator::operator ->()
174
    { return &id; }
511 s042372 175
 
512 s042372 176
    //inline VertexIDIterator::operator VertexID() const
177
    //{ return id; }
511 s042372 178
 
179
 
180
 
512 s042372 181
    inline FaceIDIterator::FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
511 s042372 182
 
183
 
512 s042372 184
    inline FaceIDIterator& FaceIDIterator::operator ++()
185
    {
186
        id = ck->faces_next(id, skip);
187
        return *this;
188
    }
511 s042372 189
 
512 s042372 190
    inline FaceIDIterator& FaceIDIterator::operator ++(int)
191
    { return ++(*this); }
511 s042372 192
 
512 s042372 193
    inline FaceIDIterator& FaceIDIterator::operator --()
194
    {
195
        id = ck->faces_prev(id, skip);
196
        return *this;
197
    }
511 s042372 198
 
512 s042372 199
    inline FaceIDIterator& FaceIDIterator::operator --(int)
200
    { return --(*this); }
511 s042372 201
 
202
 
512 s042372 203
    inline bool FaceIDIterator::operator ==(const FaceIDIterator& other) const
204
    { return ck == other.ck && id == other.id; }
511 s042372 205
 
512 s042372 206
    inline bool FaceIDIterator::operator !=(const FaceIDIterator& other) const
513 s042372 207
    { return ck != other.ck || id != other.id; }
511 s042372 208
 
209
 
512 s042372 210
    inline FaceID FaceIDIterator::operator *()
211
    { return id; }
511 s042372 212
 
512 s042372 213
    inline FaceID* FaceIDIterator::operator ->()
214
    {return &id; }
511 s042372 215
 
512 s042372 216
    //inline FaceIDIterator::operator FaceID() const
217
    //{ return id; }
511 s042372 218
 
219
 
512 s042372 220
    inline HalfEdgeIDIterator::HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
511 s042372 221
 
222
 
512 s042372 223
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++()
224
    {
225
        id = ck->halfedges_next(id, skip);
226
        return *this;
227
    }
511 s042372 228
 
512 s042372 229
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++(int)
230
    { return ++(*this); }
511 s042372 231
 
512 s042372 232
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --()
233
    {
234
        id = ck->halfedges_prev(id, skip);
235
        return *this;
236
    }
511 s042372 237
 
512 s042372 238
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --(int)
239
    { return --(*this); }
511 s042372 240
 
241
 
512 s042372 242
    inline bool HalfEdgeIDIterator::operator ==(const HalfEdgeIDIterator& other) const
243
    { return ck == other.ck && id == other.id; }
511 s042372 244
 
512 s042372 245
    inline bool HalfEdgeIDIterator::operator !=(const HalfEdgeIDIterator& other) const
513 s042372 246
    { return ck != other.ck || id != other.id; }
511 s042372 247
 
248
 
512 s042372 249
    inline HalfEdgeID HalfEdgeIDIterator::operator *()
250
    { return id; }
511 s042372 251
 
512 s042372 252
    inline HalfEdgeID* HalfEdgeIDIterator::operator ->()
253
    { return &id; }
511 s042372 254
 
512 s042372 255
    //inline HalfEdgeIDIterator::operator HalfEdgeID() const
256
    //{ return id; }
511 s042372 257
 
258
 
259
}
260
 
261
#endif