Subversion Repositories gelsvn

Rev

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

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