Dune Core Modules (2.3.1)

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_GEOGRID_INTERSECTIONITERATOR_HH
4#define DUNE_GEOGRID_INTERSECTIONITERATOR_HH
5
6#include <dune/grid/geometrygrid/entitypointer.hh>
7#include <dune/grid/geometrygrid/intersection.hh>
8
9namespace Dune
10{
11
12 namespace GeoGrid
13 {
14
15 // IntersectionIterator
16 // --------------------
17
18 template< class Grid, class HostIntersectionIterator >
19 class IntersectionIterator
20 {
21 typedef typename remove_const< Grid >::type::Traits Traits;
22
23 typedef GeoGrid::Intersection< Grid, typename HostIntersectionIterator::Intersection > IntersectionImpl;
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
40 IntersectionIterator ( const IntersectionIterator &other )
41 : hostIterator_( other.hostIterator_ ),
42 intersection_( IntersectionImpl( Grid::getRealImplementation( other.intersection_ ) ) )
43 {}
44
45 IntersectionIterator &operator= ( const IntersectionIterator &other )
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
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)