Dune Core Modules (2.5.0)

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
79 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
81 {
82#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
83 public:
84#else
85 protected:
86 // give the GridDefaultImplementation class access to the realImp
87 friend class GridDefaultImplementation<
88 GridImp::dimension, GridImp::dimensionworld,
89 typename GridImp::ctype,
90 typename GridImp::GridFamily> ;
91#endif
92 // type of underlying implementation, for internal use only
93 typedef IntersectionIteratorImp Implementation;
94
96 Implementation &impl () { return realIterator; }
98 const Implementation &impl () const { return realIterator; }
99
100 protected:
101 Implementation realIterator;
102
103 public:
106
107 //===========================================================
111 //===========================================================
112
113 // The behavior when dereferencing the IntersectionIterator facade depends on
114 // the way the grid implementation handles returning intersections. The implementation
115 // may either return a reference to an intersection stored inside the IntersectionIterator
116 // implementation or a temporary Intersection object. This object has to be forwarded through
117 // the facade to the user, which requires a little trickery, especially for operator->().
118 //
119 // In order to avoid confusing users reading the Doxygen documentation, we provide "clean"
120 // function signatures to Doxygen and hide the actual implementations.
121
122#ifdef DOXYGEN
123
126
128 const Intersection* operator->() const;
129
130#else // DOXYGEN
131
133 typename std::conditional<
134 std::is_lvalue_reference<
135 decltype(realIterator.dereference())
136 >::value,
137 const Intersection&,
139 >::type
140 operator*() const
141 {
142 return this->realIterator.dereference();
143 }
144
146 decltype(handle_proxy_member_access(realIterator.dereference()))
147 operator->() const
148 {
149 return handle_proxy_member_access(realIterator.dereference());
150 }
151
152#endif // DOXYGEN
153
155
156
157 //===========================================================
161 //===========================================================
162
168 bool operator==(const IntersectionIterator& rhs) const
169 {
170 return rhs.equals(*this);
171 }
172
178 bool operator!=(const IntersectionIterator& rhs) const
179 {
180 return ! rhs.equals(*this);
181 }
183
186 {
187 this->realIterator.increment();
188 return *this;
189 }
190
193 {
194 IntersectionIterator copy(*this);
195 this->realIterator.increment();
196 return copy;
197 }
198
201 {}
202
203 //===========================================================
207 //===========================================================
208
210 bool equals(const IntersectionIterator& rhs) const
211 {
212 return this->realIterator.equals(rhs.realIterator);
213 }
214
216 IntersectionIterator ( const Implementation &impl )
217 : realIterator( impl )
218 {}
219
222 realIterator(i.realIterator) {}
224 };
225
226} // namespace Dune
227
228
229namespace std
230{
231
232 template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
233 struct iterator_traits< Dune::IntersectionIterator< GridImp, IntersectionIteratorImp, IntersectionImp > >
234 {
235 typedef ptrdiff_t difference_type;
236 typedef const typename Dune::Intersection< GridImp, IntersectionImp > value_type;
237 typedef value_type *pointer;
238 typedef value_type &reference;
239 typedef forward_iterator_tag iterator_category;
240 };
241
242} // namespace std
243
244#include "intersection.hh"
245
246#endif // DUNE_GRID_INTERSECTIONITERATOR_HH
Definition: grid.hh:920
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
IntersectionIterator()
Default constructor.
Definition: intersectioniterator.hh:200
const Intersection * operator->() const
Pointer operator.
IntersectionIterator & operator++()
Preincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:185
Intersection operator*() const
Dereferencing operator.
IntersectionIterator(const IntersectionIterator &i)
Definition: intersectioniterator.hh:221
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:168
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:105
IntersectionIterator operator++(int)
Postincrement operator. Proceed to next intersection.
Definition: intersectioniterator.hh:192
Implementation & impl()
return reference to the real implementation
Definition: intersectioniterator.hh:96
const Implementation & impl() const
return reference to the real implementation
Definition: intersectioniterator.hh:98
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:178
IntersectionIterator(const Implementation &impl)
Definition: intersectioniterator.hh:216
bool equals(const IntersectionIterator &rhs) const
forward equality check to realIterator
Definition: intersectioniterator.hh:210
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:162
This file implements iterator facade classes for writing stl conformant iterators.
Dune namespace.
Definition: alignment.hh:11
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 (Nov 23, 23:29, 2024)