Dune Core Modules (2.4.2)

intersectioniterator.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_INTERSECTIONITERATOR_HH
4#define DUNE_GRID_INTERSECTIONITERATOR_HH
5
8
9#include <dune/grid/common/intersection.hh>
10
11namespace Dune
12{
13
82 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
84 {
85#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
86 public:
87#else
88 protected:
89 // give the GridDefaultImplementation class access to the realImp
90 friend class GridDefaultImplementation<
91 GridImp::dimension, GridImp::dimensionworld,
92 typename GridImp::ctype,
93 typename GridImp::GridFamily> ;
94#endif
95 // type of underlying implementation, for internal use only
96 typedef IntersectionIteratorImp Implementation;
97
99 Implementation &impl () { return realIterator; }
101 const Implementation &impl () const { return realIterator; }
102
103 protected:
104 Implementation realIterator;
105
106 public:
109
110 //===========================================================
114 //===========================================================
115
116 // The behavior when dereferencing the IntersectionIterator facade depends on
117 // the way the grid implementation handles returning intersections. The implementation
118 // may either return a reference to an intersection stored inside the IntersectionIterator
119 // implementation or a temporary Intersection object. This object has to be forwarded through
120 // the facade to the user, which requires a little trickery, especially for operator->().
121 //
122 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
123 // function signatures to Doxygen and hide the actual implementations.
124
125#ifdef DOXYGEN
126
129
131 const Intersection* operator->() const;
132
133#else // DOXYGEN
134
136 typename std::conditional<
137 std::is_lvalue_reference<
138 decltype(realIterator.dereference())
139 >::value,
140 const Intersection&,
142 >::type
143 operator*() const
144 {
145 return this->realIterator.dereference();
146 }
147
149 decltype(handle_proxy_member_access(realIterator.dereference()))
150 operator->() const
151 {
152 return handle_proxy_member_access(realIterator.dereference());
153 }
154
155#endif // DOXYGEN
156
158
159
160 //===========================================================
164 //===========================================================
165
171 bool operator==(const IntersectionIterator& rhs) const
172 {
173 return rhs.equals(*this);
174 }
175
181 bool operator!=(const IntersectionIterator& rhs) const
182 {
183 return ! rhs.equals(*this);
184 }
186
189 {
190 this->realIterator.increment();
191 return *this;
192 }
193
196 {
197 IntersectionIterator copy(*this);
198 this->realIterator.increment();
199 return copy;
200 }
201
204 {}
205
206 //===========================================================
210 //===========================================================
211
213 bool equals(const IntersectionIterator& rhs) const
214 {
215 return this->realIterator.equals(rhs.realIterator);
216 }
217
219 IntersectionIterator ( const Implementation &impl )
220 : realIterator( impl )
221 {}
222
225 realIterator(i.realIterator) {}
227 };
228
229} // namespace Dune
230
231
232namespace std
233{
234
235 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
236 struct iterator_traits< Dune::IntersectionIterator< GridImp, IntersectionIteratorImp, IntersectionImp > >
237 {
238 typedef ptrdiff_t difference_type;
239 typedef const typename Dune::Intersection< GridImp, IntersectionImp > value_type;
240 typedef value_type *pointer;
241 typedef value_type &reference;
242 typedef forward_iterator_tag iterator_category;
243 };
244
245} // namespace std
246
247#include "intersection.hh"
248
249#endif // DUNE_GRID_INTERSECTIONITERATOR_HH
Definition: grid.hh:1030
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:84
IntersectionIterator()
Default constructor.
Definition: intersectioniterator.hh:203
const Intersection * operator->() const
Pointer operator.
IntersectionIterator & operator++()
Preincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:188
Intersection operator*() const
Dereferencing operator.
IntersectionIterator(const IntersectionIterator &i)
Definition: intersectioniterator.hh:224
bool operator==(const IntersectionIterator &rhs) const
Checks for equality. Only Iterators pointing to the same intersection from the same Entity are equal....
Definition: intersectioniterator.hh:171
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:108
IntersectionIterator operator++(int)
Postincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:195
Implementation & impl()
return reference to the real implementation
Definition: intersectioniterator.hh:99
const Implementation & impl() const
return reference to the real implementation
Definition: intersectioniterator.hh:101
bool operator!=(const IntersectionIterator &rhs) const
Checks for inequality. Only Iterators pointing to the same intersection from the same Entity are equa...
Definition: intersectioniterator.hh:181
IntersectionIterator(const Implementation &impl)
Definition: intersectioniterator.hh:219
bool equals(const IntersectionIterator &rhs) const
forward equality check to realIterator
Definition: intersectioniterator.hh:213
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
This file implements iterator facade classes for writing stl conformant iterators.
Dune namespace.
Definition: alignment.hh:10
pointer_or_proxy_holder handle_proxy_member_access(T &&t)
Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
STL namespace.
infrastructure for supporting operator->() on both references and proxies
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)