Commit 20406ff3 authored by Christian Engwer's avatar Christian Engwer Committed by Steffen Müthing

Merge branch 'feature/make-intersectioniterator-a-forward-iterator' into 'master'

Feature/make intersectioniterator a forward iterator

In flyspray/FS#1496 the second patch got missed.
This branch now contains all changes needed to use the intersection iterator as a std::forward_iterator.

See merge request !12
(cherry picked from commit a4136432)
Signed-off-by: Steffen Müthing's avatarSteffen Müthing <muething@dune-project.org>
parent 522325f7
......@@ -191,6 +191,14 @@ namespace Dune
return *this;
}
/** @brief Postincrement operator. Proceed to next intersection.*/
IntersectionIterator operator++(int)
{
IntersectionIterator copy(*this);
this->realIterator.increment();
return copy;
}
/** @brief Default constructor. */
IntersectionIterator()
{}
......@@ -220,6 +228,22 @@ namespace Dune
} // namespace Dune
namespace std
{
template< class GridImp, class IntersectionIteratorImp, class IntersectionImp >
struct iterator_traits< Dune::IntersectionIterator< GridImp, IntersectionIteratorImp, IntersectionImp > >
{
typedef ptrdiff_t difference_type;
typedef const typename Dune::Intersection< GridImp, IntersectionImp > value_type;
typedef value_type *pointer;
typedef value_type &reference;
typedef forward_iterator_tag iterator_category;
};
} // namespace std
#include "intersection.hh"
#endif // DUNE_GRID_INTERSECTIONITERATOR_HH
......@@ -5,9 +5,12 @@
#include <cmath>
#include <dune/common/test/iteratortest.hh>
#include <dune/geometry/quadraturerules.hh>
#include <dune/geometry/referenceelements.hh>
#include "checkiterators.hh"
#include "checkgeometry.hh"
/** \file
......@@ -439,10 +442,12 @@ void checkIntersectionIterator ( const GridViewType &view,
bool hasBoundaryIntersection = false;
typename Intersection::GlobalCoordinate sumNormal( ctype( 0 ) );
// check default-constructibility and copy constructor
IntersectionIterator idefault;
idefault = view.iend( *eIt );
const IntersectionIterator iend = idefault;
// check wether intersection iterator is a forward iterator
NoopFunctor< Intersection > op;
if( 0 != testForwardIterator( view.ibegin( *eIt ), view.iend( *eIt ), op ) )
DUNE_THROW( Dune::Exception, "IntersectionIterator does not fulfill the forward iterator concept" );
const IntersectionIterator iend = view.iend( *eIt );
for( IntersectionIterator iIt = view.ibegin( *eIt ); iIt != iend; ++iIt )
{
const Intersection &intersection = *iIt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment