dune-grid  2.2.0
albertagrid/intersectioniterator.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALBERTA_INTERSECTIONITERATOR_HH
00002 #define DUNE_ALBERTA_INTERSECTIONITERATOR_HH
00003 
00004 #include <dune/grid/common/intersectioniterator.hh>
00005 
00006 #include <dune/grid/albertagrid/intersection.hh>
00007 
00013 #if HAVE_ALBERTA
00014 
00015 namespace Dune
00016 {
00017 
00018   // AlbertaGridLeafIntersectionIterator
00019   // -----------------------------------
00020 
00021   template< class GridImp >
00022   class AlbertaGridLeafIntersectionIterator 
00023   {
00024     typedef AlbertaGridLeafIntersectionIterator< GridImp > This;
00025 
00026   public:
00027     typedef Dune::Intersection< GridImp, AlbertaGridLeafIntersection > Intersection;
00028 
00029     static const int dimension = Intersection::dimension;
00030 
00031     struct Begin {};
00032     struct End {};
00033 
00034   private:
00035     typedef AlbertaGridLeafIntersection< GridImp > IntersectionImp;
00036 
00037   public:
00038     template< class EntityImp >
00039     AlbertaGridLeafIntersectionIterator ( const EntityImp &entity, Begin )
00040     : intersection_( IntersectionImp( entity, 0 ) )
00041     {}
00042 
00043     template< class EntityImp >
00044     AlbertaGridLeafIntersectionIterator ( const EntityImp &entity, End )
00045     : intersection_( IntersectionImp( entity, dimension+1 ) )
00046     {}
00047 
00048     AlbertaGridLeafIntersectionIterator ( const This &other )
00049     : intersection_( other.intersectionImp() )
00050     {}
00051 
00052     This &operator= ( const This &other )
00053     {
00054       intersectionImp() = other.intersectionImp();
00055       return *this;
00056     }
00057 
00058     const Intersection &dereference () const
00059     {
00060       return intersection_;
00061     }
00062 
00063     bool equals ( const This &other ) const
00064     {
00065       return (intersectionImp() == other.intersectionImp());
00066     }
00067 
00068     void increment ()
00069     {
00070       intersectionImp().next();
00071     }
00072 
00073   private: 
00074     const IntersectionImp &intersectionImp () const
00075     {
00076       return GridImp::getRealImplementation( intersection_ );
00077     }
00078 
00079     IntersectionImp &intersectionImp ()
00080     {
00081       return GridImp::getRealImplementation( intersection_ );
00082     }
00083 
00084     Intersection intersection_;
00085   };
00086 
00087 }
00088 
00089 #endif // #if HAVE_ALBERTA
00090 
00091 #endif // #ifndef DUNE_ALBERTA_INTERSECTIONITERATOR_HH