dune-grid
2.2.0
|
00001 #ifndef DUNE_GEOGRID_IDSET_HH 00002 #define DUNE_GEOGRID_IDSET_HH 00003 00004 #include <dune/grid/common/indexidset.hh> 00005 00006 namespace Dune 00007 { 00008 00009 namespace GeoGrid 00010 { 00011 00012 // IdSet 00013 // ----- 00014 00015 template< class Grid, class HostIdSet > 00016 class IdSet 00017 : public Dune::IdSet< Grid, IdSet< Grid, HostIdSet >, typename HostIdSet::IdType > 00018 { 00019 typedef IdSet< Grid, HostIdSet > This; 00020 typedef Dune::IdSet< Grid, This, typename HostIdSet::IdType > Base; 00021 00022 typedef typename remove_const< Grid >::type::Traits Traits; 00023 00024 public: 00025 typedef typename HostIdSet::IdType IdType; 00026 00027 using Base::subId; 00028 00029 IdSet () 00030 : hostIdSet_( 0 ) 00031 {} 00032 00033 explicit IdSet ( const HostIdSet &hostIdSet ) 00034 : hostIdSet_( &hostIdSet ) 00035 {} 00036 00037 IdSet ( const This &other ) 00038 : hostIdSet_( other.hostIdSet_ ) 00039 {} 00040 00041 const This &operator= ( const This &other ) 00042 { 00043 hostIdSet_ = other.hostIdSet_; 00044 return *this; 00045 } 00046 00047 template< int codim > 00048 IdType id ( const typename Traits::template Codim< codim >::Entity &entity ) const 00049 { 00050 return Grid::getRealImplementation( entity ).id( hostIdSet() ); 00051 } 00052 00053 template< class Entity > 00054 IdType id ( const Entity &entity ) const 00055 { 00056 return id< Entity::codimension >( entity ); 00057 } 00058 00059 IdType subId ( const typename Traits::template Codim< 0 >::Entity &entity, int i, unsigned int codim ) const 00060 { 00061 return hostIdSet().subId( Grid::template getHostEntity< 0 >( entity ), i, codim ); 00062 } 00063 00064 operator bool () const { return bool( hostIdSet_ ); } 00065 00066 private: 00067 const HostIdSet &hostIdSet () const 00068 { 00069 assert( *this ); 00070 return *hostIdSet_; 00071 } 00072 00073 const HostIdSet *hostIdSet_; 00074 }; 00075 00076 } // namespace GeoGrid 00077 00078 } // namespace Dune 00079 00080 #endif // #ifndef DUNE_GEOGRID_IDSET_HH