dune-grid 2.8.0
Loading...
Searching...
No Matches
pointiterator.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_GRID_IO_FILE_VTK_POINTITERATOR_HH
5#define DUNE_GRID_IO_FILE_VTK_POINTITERATOR_HH
6
7#include <iterator>
8#include <vector>
9
10#include <dune/common/iteratorfacades.hh>
11#include <dune/common/typetraits.hh>
12
15
16namespace Dune
17{
20
21 namespace VTK {
22
24
47 template<typename CellIterator, typename IS>
49 : public ForwardIteratorFacade
50 < PointIterator<CellIterator, IS>,
51 const Corner<typename std::remove_const<typename std::iterator_traits<
52 CellIterator>::value_type>::type>,
53 const Corner<typename std::remove_const<typename std::iterator_traits<
54 CellIterator>::value_type>::type>&,
55 typename std::iterator_traits<CellIterator>::difference_type>
56 {
57 public:
58 typedef VTK::Corner<typename std::remove_const<typename std::iterator_traits<
59 CellIterator>::value_type>::type> Corner;
60
61 // reiterate the facades typedefs here
63 typedef const Corner Value;
64 typedef Value& Reference;
65 typedef typename std::iterator_traits<CellIterator>::difference_type
67
68 static const unsigned mydim = std::iterator_traits<CellIterator>::
69 value_type::mydimension;
70
71 private:
72 typedef ForwardIteratorFacade<DerivedType, Value, Reference,
73 DifferenceType> Facade;
74
76 const IS* is;
77 std::vector<bool> seen;
78
79 public:
81 return *cornerit;
82 }
83
84 bool isDereferencable() const {
85 return cornerit.isDereferencable();
86 }
87
88 bool equals(const DerivedType& other) const {
89 return cornerit == other.cornerit;
90 }
91
92 void increment() {
93 for(++cornerit; isDereferencable(); ++cornerit) {
94 typename IS::IndexType index =
95 is->subIndex(cornerit->cell(), cornerit->duneIndex(), mydim);
96
97 if(!seen[index]) {
98 seen[index] = true;
99 break;
100 }
101 }
102 }
103
105
110 PointIterator(const CellIterator& cellit, const CellIterator& cellend,
111 const IS& is_)
112 : cornerit(cellit, cellend), is(&is_), seen(is->size(mydim), false)
113 { }
115
118 PointIterator(const CellIterator& cellend_)
119 : cornerit(cellend_), is(0)
120 { }
121 };
122
123 } // namespace VTK
124
126
127} // namespace Dune
128
129#endif // DUNE_GRID_IO_FILE_VTK_POINTITERATOR_HH
Include standard header files.
Definition: agrid.hh:58
simple class representing a corner of a cell
Definition: corner.hh:23
iterate over the corners of some cell range
Definition: corneriterator.hh:37
bool isDereferencable() const
Definition: corneriterator.hh:67
iterate over the points of some corner range
Definition: pointiterator.hh:56
PointIterator(const CellIterator &cellit, const CellIterator &cellend, const IS &is_)
construct a CornerIterator
Definition: pointiterator.hh:110
void increment()
Definition: pointiterator.hh:92
VTK::Corner< typename std::remove_const< typename std::iterator_traits< CellIterator >::value_type >::type > Corner
Definition: pointiterator.hh:59
Reference dereference() const
Definition: pointiterator.hh:80
std::iterator_traits< CellIterator >::difference_type DifferenceType
Definition: pointiterator.hh:66
static const unsigned mydim
Definition: pointiterator.hh:68
PointIterator(const CellIterator &cellend_)
construct a CornerIterator
Definition: pointiterator.hh:118
bool equals(const DerivedType &other) const
Definition: pointiterator.hh:88
PointIterator< CellIterator, IS > DerivedType
Definition: pointiterator.hh:62
const Corner Value
Definition: pointiterator.hh:63
Value & Reference
Definition: pointiterator.hh:64
bool isDereferencable() const
Definition: pointiterator.hh:84