dune-grid  2.3.1
geometrygrid/intersectioniterator.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 #ifndef DUNE_GEOGRID_INTERSECTIONITERATOR_HH
4 #define DUNE_GEOGRID_INTERSECTIONITERATOR_HH
5 
8 
9 namespace Dune
10 {
11 
12  namespace GeoGrid
13  {
14 
15  // IntersectionIterator
16  // --------------------
17 
18  template< class Grid, class HostIntersectionIterator >
20  {
21  typedef typename remove_const< Grid >::type::Traits Traits;
22 
24 
25  typedef typename Traits::template Codim< 0 >::EntityPointerImpl EntityPointerImpl;
26  typedef typename Traits::template Codim< 0 >::Geometry ElementGeometry;
27 
28  public:
30 
31  typedef typename Traits::template Codim< 0 >::EntityPointer EntityPointer;
32 
33  template< class Entity >
34  IntersectionIterator ( const Entity &inside,
35  const HostIntersectionIterator &hostIterator )
36  : hostIterator_( hostIterator ),
37  intersection_( IntersectionImpl( inside.geometry() ) )
38  {}
39 
41  : hostIterator_( other.hostIterator_ ),
42  intersection_( IntersectionImpl( Grid::getRealImplementation( other.intersection_ ) ) )
43  {}
44 
46  {
47  hostIterator_ = other.hostIterator_;
48  Grid::getRealImplementation( intersection_ ) = Grid::getRealImplementation( other.intersection_ );
49  return *this;
50  }
51 
52  bool equals ( const IntersectionIterator &other ) const
53  {
54  return (hostIterator_ == other.hostIterator_);
55  }
56 
57  void increment ()
58  {
59  ++hostIterator_;
60  intersectionImpl().invalidate();
61  }
62 
63  const Intersection &dereference () const
64  {
65  if( !intersectionImpl() )
66  intersectionImpl().initialize( *hostIterator_ );
67  return intersection_;
68  }
69 
70  private:
71  IntersectionImpl &intersectionImpl () const
72  {
73  return Grid::getRealImplementation( intersection_ );
74  }
75 
76  HostIntersectionIterator hostIterator_;
77  mutable Intersection intersection_;
78  };
79 
80  } // namespace GeoGrid
81 
82 } // namespace Dune
83 
84 #endif // #ifndef DUNE_GEOGRID_INTERSECTIONITERATOR_HH