Subversion Repositories gelsvn

Rev

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