Dune Core Modules (2.4.2)

pointiterator.hh
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
12
13#include <dune/grid/io/file/vtk/corner.hh>
14#include <dune/grid/io/file/vtk/corneriterator.hh>
15
16namespace Dune
17{
20
21 namespace VTK {
22
24
47 template<typename CellIterator, typename IS>
50 < PointIterator<CellIterator, IS>,
51 const Corner<typename remove_const<typename std::iterator_traits<
52 CellIterator>::value_type>::type>,
53 const Corner<typename 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 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
66 DifferenceType;
67
68 static const unsigned mydim = std::iterator_traits<CellIterator>::
69 value_type::mydimension;
70
71 private:
73 DifferenceType> Facade;
74
76 const IS* is;
77 std::vector<bool> seen;
78
79 public:
80 Reference dereference() const {
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
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:141
iterate over the corners of some cell range
Definition: corneriterator.hh:37
simple class representing a corner of a cell
Definition: corner.hh:23
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
PointIterator(const CellIterator &cellend_)
construct a CornerIterator
Definition: pointiterator.hh:118
This file implements iterator facade classes for writing stl conformant iterators.
Dune namespace.
Definition: alignment.hh:10
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)