~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software Foundation,
 
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 *
 
18
 * ***** END GPL LICENSE BLOCK *****
 
19
 */
 
20
 
 
21
#ifndef __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__
 
22
#define __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__
 
23
 
 
24
/** \file blender/freestyle/intern/view_map/ViewMapAdvancedIterators.h
 
25
 *  \ingroup freestyle
 
26
 *  \brief Iterators used to iterate over the various elements of the ViewMap.
 
27
 *         These iterators can't be exported to python.
 
28
 *  \author Stephane Grabli
 
29
 *  \date 01/07/2003
 
30
 */
 
31
 
 
32
#include "ViewMap.h"
 
33
 
 
34
#include "../system/Iterator.h" //soc
 
35
 
 
36
namespace Freestyle {
 
37
 
 
38
/**********************************/
 
39
/*                                */
 
40
/*                                */
 
41
/*             ViewMap            */
 
42
/*                                */
 
43
/*                                */
 
44
/**********************************/
 
45
 
 
46
/**********************************/
 
47
/*                                */
 
48
/*                                */
 
49
/*             ViewVertex         */
 
50
/*                                */
 
51
/*                                */
 
52
/**********************************/
 
53
 
 
54
namespace ViewVertexInternal {
 
55
 
 
56
class edge_const_traits : public Const_traits< ::ViewVertex::directedViewEdge>
 
57
{
 
58
public:
 
59
        typedef vector< ::ViewVertex::directedViewEdge> edges_container;
 
60
        typedef edges_container::const_iterator edges_container_iterator;
 
61
        typedef vector< ::ViewVertex::directedViewEdge*> edge_pointers_container;
 
62
        typedef edge_pointers_container::const_iterator edge_pointers_container_iterator;
 
63
};
 
64
 
 
65
class edge_nonconst_traits : public Nonconst_traits< ::ViewVertex::directedViewEdge>
 
66
{
 
67
public:
 
68
        typedef vector< ::ViewVertex::directedViewEdge> edges_container;
 
69
        typedef edges_container::iterator edges_container_iterator;
 
70
        typedef vector< ::ViewVertex::directedViewEdge*> edge_pointers_container;
 
71
        typedef edge_pointers_container::iterator edge_pointers_container_iterator;
 
72
};
 
73
 
 
74
template<class Traits>
 
75
class edge_iterator_base : public IteratorBase<Traits, InputIteratorTag_Traits>
 
76
{
 
77
public:
 
78
        typedef typename Traits::value_type value_type;
 
79
        typedef typename Traits::difference_type difference_type;
 
80
        typedef typename Traits::pointer pointer;
 
81
        typedef typename Traits::reference reference;
 
82
        typedef edge_iterator_base<Traits> Self;
 
83
        typedef typename Traits::edges_container_iterator edges_container_iterator;
 
84
        typedef typename Traits::edge_pointers_container_iterator edge_pointers_container_iterator;
 
85
        typedef edge_iterator_base<edge_nonconst_traits> iterator;
 
86
        typedef edge_iterator_base<edge_const_traits> const_iterator;
 
87
 
 
88
public:
 
89
        friend class ViewVertex;
 
90
        friend class TVertex;
 
91
        friend class NonTVertex;
 
92
        friend class ViewEdge;
 
93
        friend class edge_iterator;
 
94
 
 
95
protected:
 
96
        Nature::VertexNature _Nature; // the nature of the underlying vertex
 
97
        // T vertex attributes
 
98
        edge_pointers_container_iterator _tbegin;
 
99
        edge_pointers_container_iterator _tend;
 
100
        edge_pointers_container_iterator _tvertex_iter;
 
101
 
 
102
#if 0
 
103
        mutable value_type _tvertex_iter;
 
104
        value_type _feA;
 
105
        value_type _feB;
 
106
        value_type _beA;
 
107
        value_type _beB;
 
108
#endif
 
109
 
 
110
        // Non TVertex attributes
 
111
        edges_container_iterator _begin;
 
112
        edges_container_iterator _end;
 
113
        edges_container_iterator _nontvertex_iter;
 
114
 
 
115
        typedef IteratorBase<Traits, InputIteratorTag_Traits> parent_class;
 
116
 
 
117
public:
 
118
        inline edge_iterator_base() : parent_class() {}
 
119
 
 
120
        inline edge_iterator_base(Nature::VertexNature iNature) : parent_class()
 
121
        {
 
122
                _Nature = iNature;
 
123
        }
 
124
 
 
125
        edge_iterator_base(const edge_iterator_base<edge_nonconst_traits>& iBrother) : parent_class(iBrother)
 
126
        {
 
127
                _Nature = iBrother._Nature;
 
128
                if (_Nature & Nature::T_VERTEX) {
 
129
#if 0
 
130
                        _feA = iBrother._feA;
 
131
                        _feB = iBrother._feB;
 
132
                        _beA = iBrother._beA;
 
133
                        _beB = iBrother._beB;
 
134
                        _tvertex_iter = iBrother._tvertex_iter;
 
135
#endif
 
136
                        _tbegin = iBrother._tbegin;
 
137
                        _tend = iBrother._tend;
 
138
                        _tvertex_iter = iBrother._tvertex_iter;
 
139
                }
 
140
                else {
 
141
                        _begin = iBrother._begin;
 
142
                        _end = iBrother._end;
 
143
                        _nontvertex_iter = iBrother._nontvertex_iter;
 
144
                }
 
145
        }
 
146
 
 
147
        edge_iterator_base(const edge_iterator_base<edge_const_traits>& iBrother) : parent_class(iBrother)
 
148
        {
 
149
                _Nature = iBrother._Nature;
 
150
                if (_Nature & Nature::T_VERTEX) {
 
151
#if 0
 
152
                        _feA = iBrother._feA;
 
153
                        _feB = iBrother._feB;
 
154
                        _beA = iBrother._beA;
 
155
                        _beB = iBrother._beB;
 
156
                        _tvertex_iter = iBrother._tvertex_iter;
 
157
#endif
 
158
                        _tbegin = iBrother._tbegin;
 
159
                        _tend = iBrother._tend;
 
160
                        _tvertex_iter = iBrother._tvertex_iter;
 
161
                }
 
162
                else {
 
163
                        _begin = iBrother._begin;
 
164
                        _end = iBrother._end;
 
165
                        _nontvertex_iter = iBrother._nontvertex_iter;
 
166
                }
 
167
        }
 
168
 
 
169
        virtual ~edge_iterator_base() {}
 
170
 
 
171
//protected://FIXME
 
172
public:
 
173
#if 0
 
174
        inline edge_iterator_base(value_type ifeA, value_type ifeB, value_type ibeA, value_type ibeB, value_type iter)
 
175
        : parent_class()
 
176
        {
 
177
                _Nature = Nature::T_VERTEX;
 
178
                _feA = ifeA;
 
179
                _feB = ifeB;
 
180
                _beA = ibeA;
 
181
                _beB = ibeB;
 
182
                _tvertex_iter = iter;
 
183
        }
 
184
#endif
 
185
 
 
186
        inline edge_iterator_base(edge_pointers_container_iterator begin, edge_pointers_container_iterator end,
 
187
                                  edge_pointers_container_iterator iter)
 
188
        : parent_class()
 
189
        {
 
190
                _Nature = Nature::T_VERTEX;
 
191
                _tbegin = begin;
 
192
                _tend = end;
 
193
                _tvertex_iter = iter;
 
194
        }
 
195
 
 
196
        inline edge_iterator_base(edges_container_iterator begin, edges_container_iterator end,
 
197
                                  edges_container_iterator iter)
 
198
        : parent_class()
 
199
        {
 
200
                _Nature = Nature::NON_T_VERTEX;
 
201
                _begin = begin;
 
202
                _end = end;
 
203
                _nontvertex_iter = iter;
 
204
        }
 
205
 
 
206
public:
 
207
        virtual bool begin() const
 
208
        {
 
209
                if (_Nature & Nature::T_VERTEX)
 
210
                        return (_tvertex_iter == _tbegin);
 
211
                        //return (_tvertex_iter == _feA);
 
212
                else
 
213
                        return (_nontvertex_iter == _begin);
 
214
        }
 
215
 
 
216
        virtual bool end() const
 
217
        {
 
218
                if (_Nature & Nature::T_VERTEX)
 
219
                        //return (_tvertex_iter.first == 0);
 
220
                        return (_tvertex_iter == _tend);
 
221
                else
 
222
                        return (_nontvertex_iter == _end);
 
223
        }
 
224
 
 
225
        // operators
 
226
        // operator corresponding to ++i
 
227
        virtual Self& operator++()
 
228
        {
 
229
                increment();
 
230
                return *this;
 
231
        }
 
232
 
 
233
        // operator corresponding to i++, i.e. which returns the value *and then* increments it.
 
234
        // That's why we store the value in a temp.
 
235
        virtual Self operator++(int)  // opérateur correspondant à i++ 
 
236
        {
 
237
                Self tmp = *this;
 
238
                increment();
 
239
                return tmp;
 
240
        }
 
241
 
 
242
        // comparibility
 
243
        virtual bool operator!=(const Self& b) const
 
244
        {
 
245
                if (_Nature & Nature::T_VERTEX)
 
246
                        return (_tvertex_iter != b._tvertex_iter);
 
247
                else
 
248
                        return (_nontvertex_iter != b._nontvertex_iter);
 
249
        }
 
250
 
 
251
        virtual bool operator==(const Self& b) const
 
252
        {
 
253
                return !(*this != b);
 
254
        }
 
255
 
 
256
        // dereferencing
 
257
        virtual reference operator*() const
 
258
        {
 
259
                if (_Nature & Nature::T_VERTEX)
 
260
                        //return _tvertex_iter;
 
261
                        return **_tvertex_iter;
 
262
                else
 
263
                        return (*_nontvertex_iter);
 
264
        }
 
265
 
 
266
        virtual pointer operator->() const
 
267
        {
 
268
                return &(operator*());
 
269
        }
 
270
 
 
271
protected:
 
272
        inline void increment()
 
273
        {
 
274
                if (_Nature & Nature::T_VERTEX) {
 
275
                        value_type tmp = (**_tvertex_iter);
 
276
                        ++_tvertex_iter;
 
277
                        value_type tmp2 = (**_tvertex_iter);
 
278
                        if (tmp2.first == tmp.first)
 
279
                                ++_tvertex_iter;
 
280
#if 0
 
281
                        // Hack to deal with cusp. the result of a cusp is a TVertex having two identical viewedges.
 
282
                        // In order to iterate properly, we chose to to skip these last ones.
 
283
                        if (_feB.first == _beA.first) {
 
284
                                if (_feA.first == _beB.first) {
 
285
                                        _tvertex_iter.first = 0;
 
286
                                        return;
 
287
                                }
 
288
 
 
289
                                if (_tvertex_iter.first == _feA.first)
 
290
                                        _tvertex_iter.first = _beB.first;
 
291
                                else if (_tvertex_iter.first == _beB.first)
 
292
                                        _tvertex_iter.first = 0;
 
293
                                else
 
294
                                        _tvertex_iter.first = _feA.first;
 
295
                                return;
 
296
                        }
 
297
                        if (_feA.first == _beB.first) {
 
298
                                if (_feB.first == _beA.first) {
 
299
                                        _tvertex_iter.first = 0;
 
300
                                        return;
 
301
                                }
 
302
 
 
303
                                if (_tvertex_iter.first == _feB.first)
 
304
                                        _tvertex_iter.first = _beA.first;
 
305
                                else if (_tvertex_iter.first == _beA.first)
 
306
                                        _tvertex_iter.first = 0;
 
307
                                else
 
308
                                        _tvertex_iter.first = _feB.first;
 
309
                                return;
 
310
                        }
 
311
                        // End of hack
 
312
 
 
313
                        if (_tvertex_iter.first == _feA.first) {
 
314
                                // we return bea or beb
 
315
                                // choose one of them
 
316
                                _tvertex_iter.first = _feB.first;
 
317
                                return;
 
318
                        }
 
319
                        if (_tvertex_iter.first == _feB.first) {
 
320
                                _tvertex_iter.first = _beA.first;
 
321
                                return;
 
322
                        }
 
323
                        if (_tvertex_iter.first == _beA.first) {
 
324
                                _tvertex_iter.first = _beB.first;
 
325
                                return;
 
326
                        }
 
327
                        if (_tvertex_iter.first == _beB.first) {
 
328
                                _tvertex_iter.first = 0;
 
329
                                return;
 
330
                        }
 
331
#endif
 
332
                }
 
333
                else {
 
334
                        ++_nontvertex_iter;
 
335
                }
 
336
        }
 
337
};
 
338
 
 
339
}  // ViewVertexInternal namespace
 
340
 
 
341
/**********************************/
 
342
/*                                */
 
343
/*                                */
 
344
/*             ViewEdge           */
 
345
/*                                */
 
346
/*                                */
 
347
/**********************************/
 
348
 
 
349
namespace ViewEdgeInternal {
 
350
 
 
351
/*!----------------------*/
 
352
/*! Iterators definition */
 
353
/*!----------------------*/
 
354
template<class Traits>
 
355
class edge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits>
 
356
{
 
357
public:
 
358
        typedef typename Traits::value_type value_type;
 
359
        typedef typename Traits::difference_type difference_type;
 
360
        typedef typename Traits::pointer pointer;
 
361
        typedef typename Traits::reference reference;
 
362
        typedef edge_iterator_base<Traits> Self;
 
363
 
 
364
public:
 
365
        mutable value_type _ViewEdge;
 
366
        //friend class edge_iterator_base<Nonconst_traits<ViewEdge*> >;
 
367
        //friend class edge_iterator_base<Const_traits<ViewEdge*> >;
 
368
        value_type _first;
 
369
        bool _orientation;
 
370
        typedef IteratorBase<Traits, BidirectionalIteratorTag_Traits> parent_class;
 
371
 
 
372
public:
 
373
        friend class ViewEdge;
 
374
        inline edge_iterator_base() : parent_class()
 
375
        {
 
376
                _orientation = true;
 
377
                _first = 0;
 
378
        }
 
379
 
 
380
        inline edge_iterator_base(const edge_iterator_base<Nonconst_traits< ::ViewEdge*> >& iBrother) : parent_class()
 
381
        {
 
382
                _ViewEdge = iBrother._ViewEdge;
 
383
                _first = iBrother._first;
 
384
                _orientation = iBrother._orientation;
 
385
        }
 
386
 
 
387
        inline edge_iterator_base(const edge_iterator_base<Const_traits< ::ViewEdge*> >& iBrother) : parent_class()
 
388
        {
 
389
                _ViewEdge = iBrother._ViewEdge;
 
390
                _first = iBrother._first;
 
391
                _orientation = iBrother._orientation;
 
392
        }
 
393
 
 
394
//protected://FIXME
 
395
public:
 
396
        inline edge_iterator_base(value_type iEdge, bool orientation = true) : parent_class()
 
397
        {
 
398
                _ViewEdge = iEdge;
 
399
                _first = iEdge;
 
400
                _orientation = orientation;
 
401
        }
 
402
 
 
403
public:
 
404
        virtual Self *clone() const
 
405
        {
 
406
                return new edge_iterator_base(*this);
 
407
        }
 
408
 
 
409
        virtual ~edge_iterator_base() {}
 
410
 
 
411
public:
 
412
        virtual bool orientation()
 
413
        {
 
414
                return _orientation;
 
415
        }
 
416
 
 
417
        virtual void set_edge(value_type iVE)
 
418
        {
 
419
                _ViewEdge = iVE;
 
420
        }
 
421
 
 
422
        virtual void set_orientation(bool iOrientation)
 
423
        {
 
424
                _orientation = iOrientation;
 
425
        }
 
426
 
 
427
        virtual void change_orientation()
 
428
        {
 
429
                _orientation = !_orientation;
 
430
        }
 
431
 
 
432
        // operators
 
433
        // operator corresponding to ++i
 
434
        inline Self& operator++()
 
435
        {
 
436
                //++_ViewEdge->getTimeStamp();
 
437
                increment();
 
438
                return *this;
 
439
        }
 
440
 
 
441
        // operator corresponding to i++, i.e. which returns the value *and then* increments it.
 
442
        // That's why we store the value in a temp.
 
443
        inline Self operator++(int)
 
444
        {
 
445
                //++_ViewEdge->getTimeStamp();
 
446
                Self tmp = *this;
 
447
                increment();
 
448
                return tmp;
 
449
        }
 
450
 
 
451
        // operator corresponding to --i
 
452
        inline Self& operator--()
 
453
        {
 
454
                //++_ViewEdge->getTimeStamp();
 
455
                decrement();
 
456
                return *this;
 
457
        }
 
458
 
 
459
        // operator corresponding to i--, i.e. which returns the value *and then* increments it.
 
460
        // That's why we store the value in a temp.
 
461
        inline Self operator--(int)
 
462
        {
 
463
                //++_ViewEdge->getTimeStamp();
 
464
                Self tmp = *this;
 
465
                decrement();
 
466
                return tmp;
 
467
        }
 
468
 
 
469
        // comparibility
 
470
        virtual bool operator!=(const Self& b) const
 
471
        {
 
472
                return (_ViewEdge != b._ViewEdge);
 
473
        }
 
474
 
 
475
        virtual bool operator==(const Self& b) const
 
476
        {
 
477
                return !(*this != b);
 
478
        }
 
479
 
 
480
        // dereferencing
 
481
        virtual reference operator*() const
 
482
        {
 
483
                return (_ViewEdge);
 
484
        }
 
485
 
 
486
        virtual pointer operator->() const
 
487
        {
 
488
                return &(operator*());
 
489
        }
 
490
 
 
491
public:
 
492
        virtual bool begin() const
 
493
        {
 
494
                return (_ViewEdge == _first) ? true : false;
 
495
        }
 
496
 
 
497
        virtual bool end() const
 
498
        {
 
499
                return (_ViewEdge == 0) ? true : false;
 
500
        }
 
501
 
 
502
protected:
 
503
        virtual void increment() {}
 
504
        virtual void decrement() {}
 
505
};
 
506
 
 
507
template<class Traits>
 
508
class fedge_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits>
 
509
{
 
510
public:
 
511
        typedef typename Traits::value_type value_type;
 
512
        typedef typename Traits::difference_type difference_type;
 
513
        typedef typename Traits::pointer pointer;
 
514
        typedef typename Traits::reference reference;
 
515
        typedef fedge_iterator_base<Traits> Self;
 
516
 
 
517
public:
 
518
        typedef IteratorBase<Traits, BidirectionalIteratorTag_Traits> parent_class;
 
519
        mutable value_type _FEdge;
 
520
        value_type _first;
 
521
        value_type _FEdgeB; // last fedge of the view edge
 
522
 
 
523
public:
 
524
        friend class ::ViewEdge;
 
525
        friend class fedge_iterator;
 
526
 
 
527
        inline fedge_iterator_base() : parent_class() {}
 
528
 
 
529
        inline fedge_iterator_base(const fedge_iterator_base<Nonconst_traits<FEdge*> >& iBrother) : parent_class()
 
530
        {
 
531
                _FEdge = iBrother._FEdge;
 
532
                _first = iBrother._first;
 
533
                _FEdgeB = iBrother._FEdgeB;
 
534
        }
 
535
 
 
536
        inline fedge_iterator_base(const fedge_iterator_base<Const_traits<FEdge*> >& iBrother) : parent_class()
 
537
        {
 
538
                _FEdge = iBrother._FEdge;
 
539
                _first = iBrother._first;
 
540
                _FEdgeB = iBrother._FEdgeB;
 
541
        }
 
542
 
 
543
//protected://FIXME
 
544
public:
 
545
        inline fedge_iterator_base(value_type iEdge, value_type iFEdgeB) : parent_class()
 
546
        {
 
547
                _FEdge = iEdge;
 
548
                _first = iEdge;
 
549
                _FEdgeB = iFEdgeB;
 
550
        }
 
551
 
 
552
public:
 
553
        virtual ~fedge_iterator_base() {}
 
554
 
 
555
        // operators
 
556
        // operator corresponding to ++i.
 
557
        inline Self& operator++()
 
558
        { 
 
559
        increment();
 
560
        return *this;
 
561
        }
 
562
 
 
563
        // operator corresponding to i++, i.e. which returns the value *and then* increments it.
 
564
        // That's why we store the value in a temp.
 
565
        inline Self operator++(int)
 
566
        {
 
567
                Self tmp = *this;
 
568
                increment();
 
569
                return tmp;
 
570
        }
 
571
 
 
572
        // operator corresponding to --i
 
573
        inline Self& operator--()
 
574
        {
 
575
                decrement();
 
576
                return *this;
 
577
        }
 
578
 
 
579
        // operator corresponding to i--, i.e. which returns the value *and then* increments it.
 
580
        // That's why we store the value in a temp.
 
581
        inline Self operator--(int)
 
582
        {
 
583
                Self tmp = *this;
 
584
                decrement();
 
585
                return tmp;
 
586
        }
 
587
 
 
588
        // comparibility
 
589
        virtual bool operator!=(const Self& b) const
 
590
        {
 
591
                return (_FEdge != b._FEdge);
 
592
        }
 
593
 
 
594
        virtual bool operator==(const Self& b) const
 
595
        {
 
596
                return !(*this != b);
 
597
        }
 
598
 
 
599
        // dereferencing
 
600
        virtual reference operator*() const
 
601
        {
 
602
                return (_FEdge);
 
603
        }
 
604
 
 
605
        virtual pointer operator->() const
 
606
        {
 
607
                return &(operator*());
 
608
        }
 
609
 
 
610
public:
 
611
        virtual bool begin() const
 
612
        {
 
613
                return (_FEdge == _first) ? true : false;
 
614
        }
 
615
 
 
616
        virtual bool end() const
 
617
        {
 
618
                return (_FEdge == 0) ? true : false;
 
619
        }
 
620
 
 
621
protected:
 
622
        virtual void increment()
 
623
        {
 
624
                _FEdge = _FEdge->nextEdge(); // we don't change or
 
625
        }
 
626
 
 
627
        virtual void decrement()
 
628
        {
 
629
                if (0 == _FEdge) {
 
630
                        _FEdge = _FEdgeB;
 
631
                        return;
 
632
                }
 
633
                _FEdge = _FEdge->previousEdge(); // we don't change or
 
634
        }
 
635
};
 
636
 
 
637
template<class Traits>
 
638
class vertex_iterator_base : public IteratorBase<Traits, BidirectionalIteratorTag_Traits>
 
639
{
 
640
public:
 
641
        typedef typename Traits::value_type value_type;
 
642
        typedef typename Traits::difference_type difference_type;
 
643
        typedef typename Traits::pointer pointer;
 
644
        typedef typename Traits::reference reference;
 
645
        typedef vertex_iterator_base<Traits> Self;
 
646
 
 
647
protected:
 
648
        typedef IteratorBase<Traits, BidirectionalIteratorTag_Traits> parent_class;
 
649
 
 
650
public:
 
651
        mutable value_type _SVertex;
 
652
        FEdge *_NextFEdge;
 
653
        FEdge *_PreviousFEdge;
 
654
 
 
655
public:
 
656
        friend class ViewEdge;
 
657
        friend class vertex_iterator;
 
658
 
 
659
        inline vertex_iterator_base() : parent_class() {}
 
660
 
 
661
        inline vertex_iterator_base(const vertex_iterator_base<Const_traits<SVertex*> >& iBrother) : parent_class()
 
662
        {
 
663
                _SVertex = iBrother._SVertex;
 
664
                _NextFEdge = iBrother._NextFEdge;
 
665
                _PreviousFEdge = iBrother._PreviousFEdge;
 
666
        }
 
667
 
 
668
        inline vertex_iterator_base(const vertex_iterator_base<Nonconst_traits<SVertex*> >& iBrother) : parent_class()
 
669
        {
 
670
                _SVertex = iBrother._SVertex;
 
671
                _NextFEdge = iBrother._NextFEdge;
 
672
                _PreviousFEdge = iBrother._PreviousFEdge;
 
673
        }
 
674
 
 
675
//protected://FIXME
 
676
public:
 
677
        inline vertex_iterator_base(value_type iVertex, FEdge *iPreviousFEdge, FEdge *iNextFEdge) : parent_class()
 
678
        {
 
679
                _SVertex = iVertex;
 
680
                _NextFEdge = iNextFEdge;
 
681
                _PreviousFEdge = iPreviousFEdge;
 
682
        }
 
683
 
 
684
public:
 
685
        virtual ~vertex_iterator_base() {}
 
686
 
 
687
        virtual bool begin() const
 
688
        {
 
689
                return (_PreviousFEdge == 0) ? true : false;
 
690
        }
 
691
 
 
692
        virtual bool end() const
 
693
        {
 
694
                return (_SVertex == 0) ? true : false;
 
695
        }
 
696
 
 
697
        // operators
 
698
        // operator corresponding to ++i
 
699
        inline Self& operator++()
 
700
        {
 
701
                increment();
 
702
                return *this;
 
703
        }
 
704
 
 
705
        // operator corresponding to i++, i.e. which returns the value *and then* increments it.
 
706
        // That's why we store the value in a temp.
 
707
        inline Self operator++(int)
 
708
        {
 
709
                Self tmp = *this;
 
710
                increment();
 
711
                return tmp;
 
712
        }
 
713
 
 
714
        // operator corresponding to --i
 
715
        inline Self& operator--()
 
716
        {
 
717
                decrement();
 
718
                return *this;
 
719
        }
 
720
 
 
721
        // operator corresponding to --i, i.e. which returns the value *and then* increments it.
 
722
        // That's why we store the value in a temp.
 
723
        inline Self operator--(int)
 
724
        {
 
725
                Self tmp = *this;
 
726
                decrement();
 
727
                return tmp;
 
728
        }
 
729
 
 
730
        // comparibility
 
731
        virtual bool operator!=(const Self& b) const
 
732
        {
 
733
                return (_SVertex != b._SVertex);
 
734
        }
 
735
 
 
736
        virtual bool operator==(const Self& b) const
 
737
        {
 
738
                return !(*this != b);
 
739
        }
 
740
 
 
741
        // dereferencing
 
742
        virtual reference operator*() const
 
743
        {
 
744
                return (_SVertex);
 
745
        }
 
746
 
 
747
        virtual pointer operator->() const
 
748
        {
 
749
                return &(operator*());
 
750
        }
 
751
 
 
752
protected:
 
753
        virtual void increment()
 
754
        {
 
755
                if (!_NextFEdge) {
 
756
                        _SVertex = NULL;
 
757
                        return;
 
758
                }
 
759
                _SVertex = _NextFEdge->vertexB();
 
760
                _PreviousFEdge = _NextFEdge;
 
761
                _NextFEdge = _NextFEdge->nextEdge();
 
762
        }
 
763
 
 
764
        virtual void decrement()
 
765
        {
 
766
#if 0
 
767
                if (!_SVertex) {
 
768
                        _SVertex = _PreviousFEdge->vertexB();
 
769
                        return;
 
770
                }
 
771
#endif
 
772
                if (!_PreviousFEdge) {
 
773
                        _SVertex = NULL;
 
774
                        return;
 
775
                }
 
776
                _SVertex = _PreviousFEdge->vertexA();
 
777
                _NextFEdge = _PreviousFEdge;
 
778
                _PreviousFEdge = _PreviousFEdge->previousEdge();
 
779
        }
 
780
};
 
781
 
 
782
} // end of namespace ViewEdgeInternal
 
783
 
 
784
} /* namespace Freestyle */
 
785
 
 
786
#endif // __FREESTYLE_VIEW_MAP_ADVANCED_ITERATORS_H__