Subversion Repositories gelsvn

Rev

Rev 511 | Rev 513 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 511 Rev 512
Line -... Line 1...
-
 
1
/* ----------------------------------------------------------------------- *
-
 
2
 * This file is part of GEL, www.imm.dtu.dk/GEL
-
 
3
 * Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics
1
/*
4
 *
2
* Written by Christian Thode Larsen 2009-2010
5
 * Principal authors:
3
* Contact: thode2d@gmail.com
6
 *  Christian Thode Larsen (thode2d@gmail.com)
4
* Based on original work by J. Andreas Baerentzen
-
 
5
* Inspired by OpenMesh (www.openmesh.org)
7
 *  J. Andreas Baerentzen (jab@imm.dtu.dk)
6
*/
8
 *
-
 
9
 * See LICENSE.txt for licensing information
-
 
10
 * ----------------------------------------------------------------------- */
7
 
11
 
8
#ifndef __HMESH_ITERATORS_H__
12
#ifndef __HMESH_ITERATORS_H__
9
#define __HMESH_ITERATORS_H__
13
#define __HMESH_ITERATORS_H__
10
 
14
 
11
#include "ConnectivityKernel.h"
15
#include "ConnectivityKernel.h"
12
 
16
 
13
namespace HMesh
17
namespace HMesh
14
{
18
{
15
	class VertexIDIterator
19
    class VertexIDIterator
16
	{
20
    {
17
	public:
21
    public:
18
		/// constructor (default: skipping enabled)
22
        /// constructor (default: skipping enabled)
19
		VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip = true);
23
        VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip = true);
20
 
24
 
21
		/// prefix increment 
25
        /// prefix increment 
22
		VertexIDIterator& operator ++();		
26
        VertexIDIterator& operator ++();		
23
		/// postfix increment
27
        /// postfix increment
24
		VertexIDIterator& operator ++(int);
28
        VertexIDIterator& operator ++(int);
25
		/// prefix decrement
29
        /// prefix decrement
26
		VertexIDIterator& operator --();
30
        VertexIDIterator& operator --();
27
		/// postfix decrement
31
        /// postfix decrement
28
		VertexIDIterator& operator --(int);
32
        VertexIDIterator& operator --(int);
29
 
33
 
30
		/// equal to
34
        /// equal to
31
		bool operator ==(const VertexIDIterator& other) const;
35
        bool operator ==(const VertexIDIterator& other) const;
32
		/// not equal to
36
        /// not equal to
33
		bool operator !=(const VertexIDIterator& other) const;
37
        bool operator !=(const VertexIDIterator& other) const;
34
 
38
 
35
		/// indirection
39
        /// indirection
36
		VertexID operator *();
40
        VertexID operator *();
37
		/// member by pointer
41
        /// member by pointer
38
		VertexID* operator ->();
42
        VertexID* operator ->();
39
		/// cast
43
        /// cast
40
		//operator VertexID() const;
44
        //operator VertexID() const;
41
 
45
 
42
	private:
46
    private:
43
		const ConnectivityKernel* ck;
47
        const ConnectivityKernel* ck;
44
		VertexID id;
48
        VertexID id;
45
		bool skip;
49
        bool skip;
46
	};
50
    };
47
 
51
 
48
	class FaceIDIterator
52
    class FaceIDIterator
49
	{
53
    {
50
	public:
54
    public:
51
		/// constructor (default: skipping enabled)
55
        /// constructor (default: skipping enabled)
52
		FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip = true);
56
        FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip = true);
53
 
57
 
54
		/// prefix increment
58
        /// prefix increment
55
		FaceIDIterator& operator ++();
59
        FaceIDIterator& operator ++();
56
		/// postfix increment
60
        /// postfix increment
57
		FaceIDIterator& operator ++(int);
61
        FaceIDIterator& operator ++(int);
58
		/// prefix decrement
62
        /// prefix decrement
59
		FaceIDIterator& operator --();
63
        FaceIDIterator& operator --();
60
		/// postfix decrement
64
        /// postfix decrement
61
		FaceIDIterator& operator --(int);
65
        FaceIDIterator& operator --(int);
62
 
66
 
63
		/// equal to
67
        /// equal to
64
		bool operator ==(const FaceIDIterator& other) const;
68
        bool operator ==(const FaceIDIterator& other) const;
65
		/// not equal to
69
        /// not equal to
66
		bool operator !=(const FaceIDIterator& other) const;
70
        bool operator !=(const FaceIDIterator& other) const;
67
 
71
 
68
 
72
 
69
		/// indirection
73
        /// indirection
70
		FaceID operator *();
74
        FaceID operator *();
71
		/// member by pointer
75
        /// member by pointer
72
		FaceID* operator ->();
76
        FaceID* operator ->();
73
		/// cast
77
        /// cast
74
		//operator FaceID() const;
78
        //operator FaceID() const;
75
 
79
 
76
 
80
 
77
	private:
81
    private:
78
		const ConnectivityKernel* ck;
82
        const ConnectivityKernel* ck;
79
		FaceID id;
83
        FaceID id;
80
		bool skip;
84
        bool skip;
81
	};
85
    };
82
 
86
 
83
	class HalfEdgeIDIterator
87
    class HalfEdgeIDIterator
84
	{
88
    {
85
	public:
89
    public:
86
		/// constructor (default: skipping enabled)
90
        /// constructor (default: skipping enabled)
87
		HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip = true);
91
        HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip = true);
88
 
92
 
89
		/// prefix increment
93
        /// prefix increment
90
		HalfEdgeIDIterator& operator ++();
94
        HalfEdgeIDIterator& operator ++();
91
		/// postfix increment
95
        /// postfix increment
92
		HalfEdgeIDIterator& operator ++(int);
96
        HalfEdgeIDIterator& operator ++(int);
93
		/// prefix decrement
97
        /// prefix decrement
94
		HalfEdgeIDIterator& operator --();
98
        HalfEdgeIDIterator& operator --();
95
		/// postfix decrement
99
        /// postfix decrement
96
		HalfEdgeIDIterator& operator --(int);
100
        HalfEdgeIDIterator& operator --(int);
97
 
101
 
98
		/// equal to
102
        /// equal to
99
		bool operator ==(const HalfEdgeIDIterator& other) const;
103
        bool operator ==(const HalfEdgeIDIterator& other) const;
100
		/// not equal to
104
        /// not equal to
101
		bool operator !=(const HalfEdgeIDIterator& other) const;
105
        bool operator !=(const HalfEdgeIDIterator& other) const;
102
 
106
 
103
		/// indirection
107
        /// indirection
104
		HalfEdgeID operator *();
108
        HalfEdgeID operator *();
105
		/// member by pointer
109
        /// member by pointer
106
		HalfEdgeID* operator ->();
110
        HalfEdgeID* operator ->();
107
		/// cast
111
        /// cast
108
		//operator HalfEdgeID() const;
112
        //operator HalfEdgeID() const;
109
 
113
 
110
	private:
114
    private:
111
		const ConnectivityKernel* ck;
115
        const ConnectivityKernel* ck;
112
		HalfEdgeID id;
116
        HalfEdgeID id;
113
		bool skip;
117
        bool skip;
114
	};
118
    };
115
 
119
 
116
	inline VertexIDIterator::VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
120
    inline VertexIDIterator::VertexIDIterator(const ConnectivityKernel& _ck, VertexID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
117
 
121
 
118
 
122
 
119
	inline VertexIDIterator& VertexIDIterator::operator ++()
123
    inline VertexIDIterator& VertexIDIterator::operator ++()
120
	{
124
    {
121
		id = ck->vertices_next(id, skip);
125
        id = ck->vertices_next(id, skip);
122
		return *this;
126
        return *this;
123
	}
127
    }
124
 
128
 
125
	inline VertexIDIterator& VertexIDIterator::operator ++(int)
129
    inline VertexIDIterator& VertexIDIterator::operator ++(int)
126
	{ return ++(*this); }
130
    { return ++(*this); }
127
 
131
 
128
 
132
 
129
	inline VertexIDIterator& VertexIDIterator::operator --()
133
    inline VertexIDIterator& VertexIDIterator::operator --()
130
	{
134
    {
131
		id = ck->vertices_prev(id, skip);
135
        id = ck->vertices_prev(id, skip);
132
		return *this;
136
        return *this;
133
	}
137
    }
134
 
138
 
135
	inline VertexIDIterator& VertexIDIterator::operator --(int)
139
    inline VertexIDIterator& VertexIDIterator::operator --(int)
136
	{ return --(*this); }
140
    { return --(*this); }
137
 
141
 
138
 
142
 
139
	inline bool VertexIDIterator::operator ==(const VertexIDIterator& other) const
143
    inline bool VertexIDIterator::operator ==(const VertexIDIterator& other) const
140
	{ return ck == other.ck && id == other.id; }
144
    { return ck == other.ck && id == other.id; }
141
 
145
 
142
	inline bool VertexIDIterator::operator !=(const VertexIDIterator& other) const
146
    inline bool VertexIDIterator::operator !=(const VertexIDIterator& other) const
143
	{ return ck == other.ck && id == other.id; }
147
    { return ck == other.ck && id == other.id; }
144
 
148
 
145
 
149
 
146
	inline VertexID VertexIDIterator::operator *()
150
    inline VertexID VertexIDIterator::operator *()
147
	{ return id; }
151
    { return id; }
148
 
152
 
149
	inline VertexID* VertexIDIterator::operator ->()
153
    inline VertexID* VertexIDIterator::operator ->()
150
	{ return &id; }
154
    { return &id; }
151
 
155
 
152
	//inline VertexIDIterator::operator VertexID() const
156
    //inline VertexIDIterator::operator VertexID() const
153
	//{ return id; }
157
    //{ return id; }
154
 
158
 
155
 
159
 
156
 
160
 
157
	inline FaceIDIterator::FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
161
    inline FaceIDIterator::FaceIDIterator(const ConnectivityKernel& _ck, FaceID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
158
 
162
 
159
 
163
 
160
	inline FaceIDIterator& FaceIDIterator::operator ++()
164
    inline FaceIDIterator& FaceIDIterator::operator ++()
161
	{
165
    {
162
		id = ck->faces_next(id, skip);
166
        id = ck->faces_next(id, skip);
163
		return *this;
167
        return *this;
164
	}
168
    }
165
 
169
 
166
	inline FaceIDIterator& FaceIDIterator::operator ++(int)
170
    inline FaceIDIterator& FaceIDIterator::operator ++(int)
167
	{ return ++(*this); }
171
    { return ++(*this); }
168
 
172
 
169
	inline FaceIDIterator& FaceIDIterator::operator --()
173
    inline FaceIDIterator& FaceIDIterator::operator --()
170
	{
174
    {
171
		id = ck->faces_prev(id, skip);
175
        id = ck->faces_prev(id, skip);
172
		return *this;
176
        return *this;
173
	}
177
    }
174
 
178
 
175
	inline FaceIDIterator& FaceIDIterator::operator --(int)
179
    inline FaceIDIterator& FaceIDIterator::operator --(int)
176
	{ return --(*this); }
180
    { return --(*this); }
177
 
181
 
178
 
182
 
179
	inline bool FaceIDIterator::operator ==(const FaceIDIterator& other) const
183
    inline bool FaceIDIterator::operator ==(const FaceIDIterator& other) const
180
	{ return ck == other.ck && id == other.id; }
184
    { return ck == other.ck && id == other.id; }
181
 
185
 
182
	inline bool FaceIDIterator::operator !=(const FaceIDIterator& other) const
186
    inline bool FaceIDIterator::operator !=(const FaceIDIterator& other) const
183
	{ return ck == other.ck && id == other.id; }
187
    { return ck == other.ck && id == other.id; }
184
 
188
 
185
 
189
 
186
	inline FaceID FaceIDIterator::operator *()
190
    inline FaceID FaceIDIterator::operator *()
187
	{ return id; }
191
    { return id; }
188
 
192
 
189
	inline FaceID* FaceIDIterator::operator ->()
193
    inline FaceID* FaceIDIterator::operator ->()
190
	{return &id; }
194
    {return &id; }
191
 
195
 
192
	//inline FaceIDIterator::operator FaceID() const
196
    //inline FaceIDIterator::operator FaceID() const
193
	//{ return id; }
197
    //{ return id; }
194
 
198
 
195
 
199
 
196
	inline HalfEdgeIDIterator::HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
200
    inline HalfEdgeIDIterator::HalfEdgeIDIterator(const ConnectivityKernel& _ck, HalfEdgeID _id, bool _skip) : ck(&_ck), id(_id), skip(_skip){}
197
 
201
 
198
 
202
 
199
	inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++()
203
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++()
200
	{
204
    {
201
		id = ck->halfedges_next(id, skip);
205
        id = ck->halfedges_next(id, skip);
202
		return *this;
206
        return *this;
203
	}
207
    }
204
 
208
 
205
	inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++(int)
209
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator ++(int)
206
	{ return ++(*this); }
210
    { return ++(*this); }
207
 
211
 
208
	inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --()
212
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --()
209
	{
213
    {
210
		id = ck->halfedges_prev(id, skip);
214
        id = ck->halfedges_prev(id, skip);
211
		return *this;
215
        return *this;
212
	}
216
    }
213
 
217
 
214
	inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --(int)
218
    inline HalfEdgeIDIterator& HalfEdgeIDIterator::operator --(int)
215
	{ return --(*this); }
219
    { return --(*this); }
216
 
220
 
217
 
221
 
218
	inline bool HalfEdgeIDIterator::operator ==(const HalfEdgeIDIterator& other) const
222
    inline bool HalfEdgeIDIterator::operator ==(const HalfEdgeIDIterator& other) const
219
	{ return ck == other.ck && id == other.id; }
223
    { return ck == other.ck && id == other.id; }
220
 
224
 
221
	inline bool HalfEdgeIDIterator::operator !=(const HalfEdgeIDIterator& other) const
225
    inline bool HalfEdgeIDIterator::operator !=(const HalfEdgeIDIterator& other) const
222
	{ return ck == other.ck && id == other.id; }
226
    { return ck == other.ck && id == other.id; }
223
 
227
 
224
 
228
 
225
	inline HalfEdgeID HalfEdgeIDIterator::operator *()
229
    inline HalfEdgeID HalfEdgeIDIterator::operator *()
226
	{ return id; }
230
    { return id; }
227
 
231
 
228
	inline HalfEdgeID* HalfEdgeIDIterator::operator ->()
232
    inline HalfEdgeID* HalfEdgeIDIterator::operator ->()
229
	{ return &id; }
233
    { return &id; }
230
 
234
 
231
	//inline HalfEdgeIDIterator::operator HalfEdgeID() const
235
    //inline HalfEdgeIDIterator::operator HalfEdgeID() const
232
	//{ return id; }
236
    //{ return id; }
233
 
237
 
234
 
238
 
235
}
239
}
236
 
240
 
237
#endif
241
#endif
238
 
242