Iterators.hh 27.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*===========================================================================*\
 *                                                                           *
 *                            OpenVolumeMesh                                 *
 *        Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen         *
 *                        www.openvolumemesh.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenVolumeMesh.                                     *
 *                                                                           *
 *  OpenVolumeMesh is free software: you can redistribute it and/or modify   *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenVolumeMesh is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenVolumeMesh.  If not,                              *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Date$                    *
 *   $LastChangedBy$                                                *
 *                                                                           *
\*===========================================================================*/

#ifndef ITERATORS_HH_
#define ITERATORS_HH_

46
#include <iterator>
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <set>
#include <vector>

#include "OpenVolumeMeshHandle.hh"

namespace OpenVolumeMesh {

class TopologyKernel;

template <
class OH /* Output handle type */>
class BaseIterator {
public:

	// STL compliance
	typedef std::bidirectional_iterator_tag iterator_category;
63
	typedef int						        difference_type;
64
	typedef const OH				        value_type;
65
66
	typedef const OH*				        pointer;
	typedef const OH&				        reference;
67
68


Max Lyon's avatar
Max Lyon committed
69
70
    BaseIterator(const TopologyKernel* _mesh, const OH& _ch) :
        valid_(true), cur_handle_(_ch), mesh_(_mesh) {}
71

Jan Möbius's avatar
Jan Möbius committed
72
    explicit BaseIterator(const TopologyKernel* _mesh) :
73
74
        valid_(true), mesh_(_mesh) {}

Max Lyon's avatar
Max Lyon committed
75
    // STL compliance (needs to have default constructor)
76
77
78
	BaseIterator() : valid_(false), mesh_(0) {}
	virtual ~BaseIterator() {}
	bool operator== (const BaseIterator& _c) const {
Max Lyon's avatar
Max Lyon committed
79
80
        return (this->cur_handle_ == _c.cur_handle() &&
                this->valid_ == _c.valid() &&
81
82
83
84
85
86
				this->mesh_ == _c.mesh());
	}
	bool operator!= (const BaseIterator& _c) const {
		return !this->operator==(_c);
	}

87
	pointer operator->() const {
88
89
90
		return &cur_handle_;
	}

91
	reference operator*() const {
92
93
94
		return cur_handle_;
	}

Mike Kremer's avatar
Mike Kremer committed
95
96
97
98
	bool operator< (const BaseIterator& _c) const {
	    return cur_handle_.idx() < _c.cur_handle_.idx();
	}

99
100
	BaseIterator& operator=(const BaseIterator& _c) {
		this->valid_ = _c.valid();
Max Lyon's avatar
Max Lyon committed
101
        this->cur_handle_ = _c.cur_handle();
102
103
104
105
106
107
108
109
110
111
		this->mesh_ = _c.mesh();
		return *this;
	}

	operator bool() const {
		return valid_;
	}

	void valid(bool _valid) {
		valid_ = _valid;
Max Lyon's avatar
Max Lyon committed
112
113
114
115
    }
    bool valid() const {
        return valid_;
    }
116
117
118
	void cur_handle(const OH& _h) {
		cur_handle_ = _h;
	}
119
	reference cur_handle() const {
120
		return cur_handle_;
Max Lyon's avatar
Max Lyon committed
121
    }
122
123
124
125
126
127
	const TopologyKernel* mesh() const {
		return mesh_;
	}

private:

Max Lyon's avatar
Max Lyon committed
128
129
    bool valid_;
    OH cur_handle_;
130
131
132
	const TopologyKernel* mesh_;
};

133
134
135
136
137
138
139
140
141
142
143
144

#if __cplusplus >= 201103L

#include <type_traits>

template<class I>
using is_ovm_iterator = std::is_base_of<BaseIterator<typename std::remove_const<typename I::value_type>::type>, I>;

// provide begin() and end() for the iterator pairs provided in TopologyKernel,
// so we can use range-for, e.g. for(const auto &vh: mesh.vertices()) works.
template<class I>
typename std::enable_if<is_ovm_iterator<I>::value, I>::type
Max Lyon's avatar
Max Lyon committed
145
begin(const std::pair<I, I>& iterpair)
146
147
148
149
150
151
{
    return iterpair.first;
}

template<class I>
typename std::enable_if<is_ovm_iterator<I>::value, I>::type
Max Lyon's avatar
Max Lyon committed
152
end(const std::pair<I, I>& iterpair)
153
154
155
156
157
158
{
    return iterpair.second;
}

#endif // C++11

Max Lyon's avatar
Max Lyon committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
template <
class IH /*  Input handle type */,
class OH /* Output handle type */>
class BaseCirculator : public BaseIterator<OH> {
public:

    typedef BaseIterator<OH> BaseIter;

    BaseCirculator(const TopologyKernel* _mesh, const IH& _ih, const OH& _oh, int _max_laps = 1) :
        BaseIter(_mesh, _oh),
        lap_(0),
        max_laps_(_max_laps),
        ref_handle_(_ih)
    {}

    BaseCirculator(const TopologyKernel* _mesh, const IH& _ih, int _max_laps = 1) :
        BaseIter(_mesh, OH()),
        lap_(0),
        max_laps_(_max_laps),
        ref_handle_(_ih)
    {}

    // STL compliance (needs to have default constructor)
    BaseCirculator() :
Mike Kremer's avatar
Mike Kremer committed
183
184
185
        BaseIter(),
        lap_(0),
        max_laps_(1)
Max Lyon's avatar
Max Lyon committed
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    {}

    virtual ~BaseCirculator() {}

    bool operator== (const BaseCirculator& _c) const {
        return (BaseIter::operator==(_c) &&
                this->lap() == _c.lap() &&
                this->ref_handle() == _c.ref_handle());
    }
    bool operator!= (const BaseCirculator& _c) const {
        return !this->operator==(_c);
    }

    bool operator< (const BaseCirculator& _c) const {
        if (lap_ == _c.lap_)
            return BaseIter::operator<(_c);
        else
            return lap_ < _c.lap_;
    }

    BaseCirculator& operator=(const BaseCirculator& _c) {
        BaseIter::operator=(_c);
        this->ref_handle_ = _c.ref_handle();
        this->lap_ = _c.lap_;
        this->max_laps_ = _c.max_laps_;
        return *this;
    }

    const IH& ref_handle() const {
        return ref_handle_;
    }

    void lap(int _lap) {
        lap_ = _lap;
    }
    int lap() const {
        return lap_;
    }

    void max_laps(int _max_laps) {
        max_laps_ = _max_laps;
    }
    int max_laps() const {
        return max_laps_;
    }

protected:
    int lap_;
    int max_laps_;
    IH ref_handle_;

};

239
240
241
//===========================================================================

class VertexOHalfEdgeIter :
Max Lyon's avatar
Max Lyon committed
242
    public BaseCirculator<
243
244
  VertexHandle,
  HalfEdgeHandle> {
245
public:
Max Lyon's avatar
Max Lyon committed
246
    typedef BaseCirculator<
247
248
      VertexHandle,
      HalfEdgeHandle> BaseIter;
249
250


251
  VertexOHalfEdgeIter(const VertexHandle& _vIdx,
Max Lyon's avatar
Max Lyon committed
252
            const TopologyKernel* _mesh, int _max_laps = 1);
253

254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
  // Post increment/decrement operator
  VertexOHalfEdgeIter operator++(int) {
    VertexOHalfEdgeIter cpy = *this;
    ++(*this);
    return cpy;
  }
  VertexOHalfEdgeIter operator--(int) {
    VertexOHalfEdgeIter cpy = *this;
    --(*this);
    return cpy;
  }
  VertexOHalfEdgeIter operator+(int _n) {
    VertexOHalfEdgeIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      ++cpy;
    }
    return cpy;
  }
  VertexOHalfEdgeIter operator-(int _n) {
    VertexOHalfEdgeIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      --cpy;
    }
    return cpy;
  }
  VertexOHalfEdgeIter& operator+=(int _n) {
    for(int i = 0; i < _n; ++i) {
      ++(*this);
    }
    return *this;
  }
  VertexOHalfEdgeIter& operator-=(int _n) {
    for(int i = 0; i < _n; ++i) {
      --(*this);
    }
    return *this;
  }

  VertexOHalfEdgeIter& operator++();
  VertexOHalfEdgeIter& operator--();

private:

    size_t cur_index_;
};



//===========================================================================

class VertexVertexIter :
    public BaseCirculator<
  VertexHandle,
  VertexHandle> {
public:
    typedef BaseCirculator<
      VertexHandle,
      VertexHandle> BaseIter;


  VertexVertexIter(const VertexHandle& _vIdx,
            const TopologyKernel* _mesh, int _max_laps = 1);

  // Post increment/decrement operator
  VertexVertexIter operator++(int) {
    VertexVertexIter cpy = *this;
    ++(*this);
    return cpy;
  }
  VertexVertexIter operator--(int) {
    VertexVertexIter cpy = *this;
    --(*this);
    return cpy;
  }
  VertexVertexIter operator+(int _n) {
    VertexVertexIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      ++cpy;
    }
    return cpy;
  }
  VertexVertexIter operator-(int _n) {
    VertexVertexIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      --cpy;
    }
    return cpy;
  }
  VertexVertexIter& operator+=(int _n) {
    for(int i = 0; i < _n; ++i) {
      ++(*this);
    }
    return *this;
  }
  VertexVertexIter& operator-=(int _n) {
    for(int i = 0; i < _n; ++i) {
      --(*this);
    }
    return *this;
  }
354

355
356
  VertexVertexIter& operator++();
  VertexVertexIter& operator--();
357
358
359

private:

Max Lyon's avatar
Max Lyon committed
360
    size_t cur_index_;
361
362
363
364
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
365
class HalfEdgeHalfFaceIter : public BaseCirculator<
366
367
368
	HalfEdgeHandle,
	HalfFaceHandle> {
public:
Max Lyon's avatar
Max Lyon committed
369
    typedef BaseCirculator<
370
371
372
373
			HalfEdgeHandle,
			HalfFaceHandle> BaseIter;


Max Lyon's avatar
Max Lyon committed
374
    HalfEdgeHalfFaceIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh, int _max_laps);
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

	// Post increment/decrement operator
	HalfEdgeHalfFaceIter operator++(int) {
		HalfEdgeHalfFaceIter cpy = *this;
		++(*this);
		return cpy;
	}
	HalfEdgeHalfFaceIter operator--(int) {
		HalfEdgeHalfFaceIter cpy = *this;
		--(*this);
		return cpy;
	}
	HalfEdgeHalfFaceIter operator+(int _n) {
		HalfEdgeHalfFaceIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	HalfEdgeHalfFaceIter operator-(int _n) {
		HalfEdgeHalfFaceIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	HalfEdgeHalfFaceIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	HalfEdgeHalfFaceIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	HalfEdgeHalfFaceIter& operator++();
	HalfEdgeHalfFaceIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
418
    size_t cur_index_;
419
420
421
};

//===========================================================================
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

class VertexFaceIter : public BaseCirculator<
  VertexHandle,
  FaceHandle> {
public:
    typedef BaseCirculator<
      VertexHandle,
      FaceHandle> BaseIter;

    VertexFaceIter(const VertexHandle& _vIdx, const TopologyKernel* _mesh, int _max_laps = 1);

  // Post increment/decrement operator
  VertexFaceIter operator++(int) {
    VertexFaceIter cpy = *this;
    ++(*this);
    return cpy;
  }
  VertexFaceIter operator--(int) {
    VertexFaceIter cpy = *this;
    --(*this);
    return cpy;
  }
  VertexFaceIter operator+(int _n) {
    VertexFaceIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      ++cpy;
    }
    return cpy;
  }
  VertexFaceIter operator-(int _n) {
    VertexFaceIter cpy = *this;
    for(int i = 0; i < _n; ++i) {
      --cpy;
    }
    return cpy;
  }
  VertexFaceIter& operator+=(int _n) {
    for(int i = 0; i < _n; ++i) {
      ++(*this);
    }
    return *this;
  }
  VertexFaceIter& operator-=(int _n) {
    for(int i = 0; i < _n; ++i) {
      --(*this);
    }
    return *this;
  }

  VertexFaceIter& operator++();
  VertexFaceIter& operator--();

private:
    std::vector<FaceHandle> faces_;
    size_t cur_index_;
};

//===========================================================================
480

Max Lyon's avatar
Max Lyon committed
481
class VertexCellIter : public BaseCirculator<
482
483
484
	VertexHandle,
	CellHandle> {
public:
Max Lyon's avatar
Max Lyon committed
485
    typedef BaseCirculator<
486
487
488
			VertexHandle,
			CellHandle> BaseIter;

Max Lyon's avatar
Max Lyon committed
489
    VertexCellIter(const VertexHandle& _vIdx, const TopologyKernel* _mesh, int _max_laps = 1);
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532

	// Post increment/decrement operator
	VertexCellIter operator++(int) {
		VertexCellIter cpy = *this;
		++(*this);
		return cpy;
	}
	VertexCellIter operator--(int) {
		VertexCellIter cpy = *this;
		--(*this);
		return cpy;
	}
	VertexCellIter operator+(int _n) {
		VertexCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	VertexCellIter operator-(int _n) {
		VertexCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	VertexCellIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	VertexCellIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	VertexCellIter& operator++();
	VertexCellIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
533
534
    std::vector<CellHandle> cells_;
    size_t cur_index_;
535
536
};

Max Lyon's avatar
Max Lyon committed
537
class HalfEdgeCellIter : public BaseCirculator<
538
539
540
	HalfEdgeHandle,
	CellHandle> {
public:
Max Lyon's avatar
Max Lyon committed
541
    typedef BaseCirculator<
542
543
544
545
			HalfEdgeHandle,
			CellHandle> BaseIter;


Max Lyon's avatar
Max Lyon committed
546
    HalfEdgeCellIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh, int _max_laps = 1);
547
548
549
550
551
552
553
554
555
556

	// Post increment/decrement operator
	HalfEdgeCellIter operator++(int) {
		HalfEdgeCellIter cpy = *this;
		++(*this);
		return cpy;
	}
	HalfEdgeCellIter operator--(int) {
		HalfEdgeCellIter cpy = *this;
		--(*this);
Max Lyon's avatar
Max Lyon committed
557
558
        return cpy;
    }
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
	HalfEdgeCellIter operator+(int _n) {
		HalfEdgeCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	HalfEdgeCellIter operator-(int _n) {
		HalfEdgeCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	HalfEdgeCellIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	HalfEdgeCellIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	HalfEdgeCellIter& operator++();
	HalfEdgeCellIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
590
591
592
593
594
    CellHandle getCellHandle(int _cur_index) const;

private:
    std::vector<CellHandle> cells_;
    size_t cur_index_;
595
596
597
598
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
599
class CellVertexIter : public BaseCirculator<
600
601
602
	CellHandle,
	VertexHandle> {
public:
Max Lyon's avatar
Max Lyon committed
603
    typedef BaseCirculator<
604
605
606
			CellHandle,
			VertexHandle> BaseIter;

Max Lyon's avatar
Max Lyon committed
607
    CellVertexIter(const CellHandle& _cIdx, const TopologyKernel* _mesh, int _max_laps = 1);
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650

	// Post increment/decrement operator
	CellVertexIter operator++(int) {
		CellVertexIter cpy = *this;
		++(*this);
		return cpy;
	}
	CellVertexIter operator--(int) {
		CellVertexIter cpy = *this;
		--(*this);
		return cpy;
	}
	CellVertexIter operator+(int _n) {
		CellVertexIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	CellVertexIter operator-(int _n) {
		CellVertexIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	CellVertexIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	CellVertexIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	CellVertexIter& operator++();
	CellVertexIter& operator--();

private:
651
	std::vector<VertexHandle> incident_vertices_;
Max Lyon's avatar
Max Lyon committed
652
    size_t cur_index_;
653
654
655
656
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
657
class CellCellIter : public BaseCirculator<
658
659
660
	CellHandle,
	CellHandle> {
public:
Max Lyon's avatar
Max Lyon committed
661
    typedef BaseCirculator<
662
663
664
			CellHandle,
			CellHandle> BaseIter;

Max Lyon's avatar
Max Lyon committed
665
    CellCellIter(const CellHandle& _cIdx, const TopologyKernel* _mesh, int _max_laps = 1);
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708

	// Post increment/decrement operator
	CellCellIter operator++(int) {
		CellCellIter cpy = *this;
		++(*this);
		return cpy;
	}
	CellCellIter operator--(int) {
		CellCellIter cpy = *this;
		--(*this);
		return cpy;
	}
	CellCellIter operator+(int _n) {
		CellCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	CellCellIter operator-(int _n) {
		CellCellIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	CellCellIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	CellCellIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	CellCellIter& operator++();
	CellCellIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
709
710
    std::vector<CellHandle> adjacent_cells_;
    size_t cur_index_;
711
712
713
714
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
715
class HalfFaceVertexIter : public BaseCirculator<
Mike Kremer's avatar
Mike Kremer committed
716
717
718
    HalfFaceHandle,
    VertexHandle> {
public:
Max Lyon's avatar
Max Lyon committed
719
    typedef BaseCirculator<
Mike Kremer's avatar
Mike Kremer committed
720
721
722
            HalfFaceHandle,
            VertexHandle> BaseIter;

Max Lyon's avatar
Max Lyon committed
723
    HalfFaceVertexIter(const HalfFaceHandle& _hIdx, const TopologyKernel* _mesh, int _max_laps = 1);
Mike Kremer's avatar
Mike Kremer committed
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767

    // Post increment/decrement operator
    HalfFaceVertexIter operator++(int) {
        HalfFaceVertexIter cpy = *this;
        ++(*this);
        return cpy;
    }
    HalfFaceVertexIter operator--(int) {
        HalfFaceVertexIter cpy = *this;
        --(*this);
        return cpy;
    }
    HalfFaceVertexIter operator+(int _n) {
        HalfFaceVertexIter cpy = *this;
        for(int i = 0; i < _n; ++i) {
            ++cpy;
        }
        return cpy;
    }
    HalfFaceVertexIter operator-(int _n) {
        HalfFaceVertexIter cpy = *this;
        for(int i = 0; i < _n; ++i) {
            --cpy;
        }
        return cpy;
    }
    HalfFaceVertexIter& operator+=(int _n) {
        for(int i = 0; i < _n; ++i) {
            ++(*this);
        }
        return *this;
    }
    HalfFaceVertexIter& operator-=(int _n) {
        for(int i = 0; i < _n; ++i) {
            --(*this);
        }
        return *this;
    }

    HalfFaceVertexIter& operator++();
    HalfFaceVertexIter& operator--();

private:
    std::vector<VertexHandle> vertices_;
Max Lyon's avatar
Max Lyon committed
768
    size_t cur_index_;
Mike Kremer's avatar
Mike Kremer committed
769
770
771
772
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
773
class BoundaryHalfFaceHalfFaceIter : public BaseCirculator<HalfFaceHandle,
774
775
    HalfFaceHandle> {
private:
Max Lyon's avatar
Max Lyon committed
776
    typedef BaseCirculator<HalfFaceHandle,
777
778
779
            HalfFaceHandle> BaseIter;
public:
    BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle& _ref_h,
Max Lyon's avatar
Max Lyon committed
780
            const TopologyKernel* _mesh, int _max_laps = 1);
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819

    // Post increment/decrement operator
    BoundaryHalfFaceHalfFaceIter operator++(int) {
        BoundaryHalfFaceHalfFaceIter cpy = *this;
        ++(*this);
        return cpy;
    }
    BoundaryHalfFaceHalfFaceIter operator--(int) {
        BoundaryHalfFaceHalfFaceIter cpy = *this;
        --(*this);
        return cpy;
    }
    BoundaryHalfFaceHalfFaceIter operator+(int _n) {
        BoundaryHalfFaceHalfFaceIter cpy = *this;
        for(int i = 0; i < _n; ++i) {
            ++cpy;
        }
        return cpy;
    }
    BoundaryHalfFaceHalfFaceIter operator-(int _n) {
        BoundaryHalfFaceHalfFaceIter cpy = *this;
        for(int i = 0; i < _n; ++i) {
            --cpy;
        }
        return cpy;
    }
    BoundaryHalfFaceHalfFaceIter& operator+=(int _n) {
        for(int i = 0; i < _n; ++i) {
            ++(*this);
        }
        return *this;
    }
    BoundaryHalfFaceHalfFaceIter& operator-=(int _n) {
        for(int i = 0; i < _n; ++i) {
            --(*this);
        }
        return *this;
    }

Max Lyon's avatar
Max Lyon committed
820
    const EdgeHandle& common_edge() const { return common_edges_[cur_index_]; }
821
822
823
824
825
826
827

    BoundaryHalfFaceHalfFaceIter& operator++();
    BoundaryHalfFaceHalfFaceIter& operator--();

private:
    std::vector<HalfFaceHandle> neighbor_halffaces_;
    std::vector<EdgeHandle> common_edges_;
Max Lyon's avatar
Max Lyon committed
828
    size_t cur_index_;
829
830
831
832
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
833
class VertexIter : public BaseIterator<VertexHandle> {
834
public:
Max Lyon's avatar
Max Lyon committed
835
    typedef BaseIterator<VertexHandle> BaseIter;
836
837


Max Lyon's avatar
Max Lyon committed
838
    VertexIter(const TopologyKernel* _mesh, const VertexHandle& _vh = VertexHandle(0));
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881

	// Post increment/decrement operator
	VertexIter operator++(int) {
		VertexIter cpy = *this;
		++(*this);
		return cpy;
	}
	VertexIter operator--(int) {
		VertexIter cpy = *this;
		--(*this);
		return cpy;
	}
	VertexIter operator+(int _n) {
		VertexIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	VertexIter operator-(int _n) {
		VertexIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	VertexIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	VertexIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	VertexIter& operator++();
	VertexIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
882
    int cur_index_;
883
884
885
886
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
887
class EdgeIter : public BaseIterator<EdgeHandle> {
888
public:
Max Lyon's avatar
Max Lyon committed
889
    typedef BaseIterator<EdgeHandle> BaseIter;
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935


	EdgeIter(const TopologyKernel* _mesh, const EdgeHandle& _eh = EdgeHandle(0));

	// Post increment/decrement operator
	EdgeIter operator++(int) {
		EdgeIter cpy = *this;
		++(*this);
		return cpy;
	}
	EdgeIter operator--(int) {
		EdgeIter cpy = *this;
		--(*this);
		return cpy;
	}
	EdgeIter operator+(int _n) {
		EdgeIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	EdgeIter operator-(int _n) {
		EdgeIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	EdgeIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	EdgeIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	EdgeIter& operator++();
	EdgeIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
936
    int cur_index_;
937
938
939
940
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
941
class HalfEdgeIter : public BaseIterator<HalfEdgeHandle> {
942
public:
Max Lyon's avatar
Max Lyon committed
943
    typedef BaseIterator<HalfEdgeHandle> BaseIter;
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989


	HalfEdgeIter(const TopologyKernel* _mesh, const HalfEdgeHandle& _heh = HalfEdgeHandle(0));

	// Post increment/decrement operator
	HalfEdgeIter operator++(int) {
		HalfEdgeIter cpy = *this;
		++(*this);
		return cpy;
	}
	HalfEdgeIter operator--(int) {
		HalfEdgeIter cpy = *this;
		--(*this);
		return cpy;
	}
	HalfEdgeIter operator+(int _n) {
		HalfEdgeIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			++cpy;
		}
		return cpy;
	}
	HalfEdgeIter operator-(int _n) {
		HalfEdgeIter cpy = *this;
		for(int i = 0; i < _n; ++i) {
			--cpy;
		}
		return cpy;
	}
	HalfEdgeIter& operator+=(int _n) {
		for(int i = 0; i < _n; ++i) {
			++(*this);
		}
		return *this;
	}
	HalfEdgeIter& operator-=(int _n) {
		for(int i = 0; i < _n; ++i) {
			--(*this);
		}
		return *this;
	}

	HalfEdgeIter& operator++();
	HalfEdgeIter& operator--();

private:
Max Lyon's avatar
Max Lyon committed
990
    int cur_index_;
991
992
993
994
};

//===========================================================================

Max Lyon's avatar
Max Lyon committed
995
class FaceIter : public BaseIterator<FaceHandle> {
996
public:
Max Lyon's avatar
Max Lyon committed
997
    typedef BaseIterator<FaceHandle> BaseIter;
998
999
1000


	FaceIter(const TopologyKernel* _mesh, const FaceHandle& _fh = FaceHandle(0));