/usr/include/dune/grid/geometrygrid/entitypointer.hh is in libdune-grid-dev 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GEOGRID_ENTITYPOINTER_HH
#define DUNE_GEOGRID_ENTITYPOINTER_HH
#include <dune/grid/common/grid.hh>
#include <dune/grid/geometrygrid/declaration.hh>
#include <dune/grid/geometrygrid/capabilities.hh>
#include <dune/grid/geometrygrid/entityseed.hh>
namespace Dune
{
namespace GeoGrid
{
// External Forward Declarations
// -----------------------------
template< int, int, class >
class Entity;
template< class, class >
class ExportParams;
// Internal Forward Declarations
// -----------------------------
template< int codim, class Grid >
struct EntityPointerTraits;
template< class Traits, bool fake = Traits::fake >
class EntityPointer;
// EntityPointerTraits
// -------------------
template< int codim, class Grid >
struct EntityPointerTraits;
/** \cond */
template< int codim, class Grid >
struct EntityPointerTraits< codim, const Grid >
: public EntityPointerTraits< codim, Grid >
{};
/** \endcond */
template< int codim, class HostGrid, class CoordFunction, class Allocator >
struct EntityPointerTraits< codim, GeometryGrid< HostGrid, CoordFunction, Allocator > >
: public ExportParams< HostGrid, CoordFunction >
{
typedef Dune::GeometryGrid< HostGrid, CoordFunction, Allocator > Grid;
static const bool fake = !Capabilities::hasHostEntity< Grid, codim >::v;
typedef typename HostGrid::ctype ctype;
static const int dimension = HostGrid::dimension;
static const int codimension = codim;
typedef Dune::Entity< codimension, dimension, const Grid, GeoGrid::Entity > Entity;
typedef Dune::EntitySeed< const Grid, GeoGrid::EntitySeed< codimension, const Grid > > EntitySeed;
typedef typename HostGrid::template Codim< codim >::Entity HostEntity;
typedef typename HostGrid::template Codim< codim >::EntityPointer HostEntityPointer;
typedef HostEntityPointer HostEntityIterator;
typedef typename HostGrid::template Codim< 0 >::Entity HostElement;
typedef typename HostGrid::template Codim< 0 >::EntityPointer HostElementIterator;
};
// EntityPointer (real)
// --------------------
template< class Traits >
class EntityPointer< Traits, false >
{
typedef EntityPointer< Traits, false > This;
typedef typename Traits::Grid Grid;
typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
friend class EntityPointer< BaseTraits, false >;
public:
static const int dimension = Traits::dimension;
static const int codimension = Traits::codimension;
typedef typename Traits::Entity Entity;
static const bool fake = Traits::fake;
typedef EntityPointer< BaseTraits, fake > EntityPointerImp;
protected:
typedef typename Traits::HostEntityPointer HostEntityPointer;
typedef typename Traits::HostEntityIterator HostEntityIterator;
typedef typename Traits::HostElement HostElement;
typedef typename Traits::EntitySeed EntitySeed;
typedef GeoGrid::Entity< codimension, dimension, const Grid > EntityImpl;
typedef typename EntityImpl::GeometryImpl GeometryImpl;
public:
EntityPointer ( const GeometryImpl &geo, const HostEntityIterator &hostEntityIterator )
: entity_( EntityImpl( geo ) ),
hostEntityIterator_( hostEntityIterator )
{}
EntityPointer ( const Grid &grid, const HostEntityIterator &hostEntityIterator )
: entity_( EntityImpl( grid ) ),
hostEntityIterator_( hostEntityIterator )
{}
EntityPointer ( const Grid &grid, const HostElement &hostElement, int subEntity )
: entity_( EntityImpl( grid ) ),
hostEntityIterator_( hostElement.template subEntity< codimension >( subEntity ) )
{}
EntityPointer ( const Grid &grid, const EntitySeed &seed )
: entity_( EntityImpl( grid ) ),
hostEntityIterator_( grid.hostGrid().entityPointer( grid.getRealImplementation(seed).hostEntitySeed() ) )
{}
explicit EntityPointer ( const EntityImpl &entity )
: entity_( entity ),
hostEntityIterator_( entity.hostEntity() )
{}
EntityPointer ( const This &other )
: entity_( other.entityImpl() ),
hostEntityIterator_( other.hostEntityIterator_ )
{}
template< class T >
explicit EntityPointer ( const EntityPointer< T, fake > &other )
: entity_( other.entityImpl() ),
hostEntityIterator_( other.hostEntityIterator_ )
{}
const This &operator= ( const This &other )
{
entityImpl() = other.entityImpl();
hostEntityIterator_ = other.hostEntityIterator_;
return *this;
}
template< class T >
const This &operator= ( const EntityPointer< T, fake > &other )
{
entityImpl() = other.entityImpl();
hostEntityIterator_ = other.hostEntityIterator_;
return *this;
}
template< class T >
bool equals ( const EntityPointer< T, fake > &other ) const
{
return (hostIterator() == other.hostIterator());
}
Entity &dereference () const
{
if( !entityImpl() )
entityImpl().initialize( *hostIterator() );
return entity_;
}
int level () const { return hostIterator().level(); }
const HostEntityIterator &hostIterator() const { return hostEntityIterator_; }
const Grid &grid () const { return entityImpl().grid(); }
protected:
EntityImpl &entityImpl () const
{
return Grid::getRealImplementation( entity_ );
}
private:
mutable Entity entity_;
protected:
HostEntityIterator hostEntityIterator_;
};
// EntityPointer (fake)
// --------------------
template< class Traits >
class EntityPointer< Traits, true >
{
typedef EntityPointer< Traits, true > This;
typedef typename Traits::Grid Grid;
typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
friend class EntityPointer< BaseTraits, true >;
public:
static const int dimension = Traits::dimension;
static const int codimension = Traits::codimension;
typedef typename Traits::Entity Entity;
static const bool fake = Traits::fake;
typedef EntityPointer< BaseTraits, fake > EntityPointerImp;
protected:
typedef typename Traits::HostEntityPointer HostEntityPointer;
typedef typename Traits::HostElementIterator HostElementIterator;
typedef typename Traits::HostElement HostElement;
typedef typename Traits::EntitySeed EntitySeed;
typedef GeoGrid::Entity< codimension, dimension, const Grid > EntityImpl;
typedef typename EntityImpl::GeometryImpl GeometryImpl;
public:
EntityPointer ( const GeometryImpl &geo, const HostElementIterator &hostElementIterator, int subEntity )
: entity_( EntityImpl( geo, subEntity ) ),
hostElementIterator_( hostElementIterator )
{}
EntityPointer ( const Grid &grid, const HostElementIterator &hostElementIterator, int subEntity )
: entity_( EntityImpl( grid, subEntity ) ),
hostElementIterator_( hostElementIterator )
{}
EntityPointer ( const Grid &grid, const HostElement &hostElement, int subEntity )
: entity_( EntityImpl( grid, subEntity ) ),
hostElementIterator_( hostElement )
{}
EntityPointer ( const Grid &grid, const EntitySeed &seed )
: entity_( EntityImpl( grid, grid.getRealImplementation(seed).subEntity() ) ),
hostElementIterator_( grid.hostGrid().entityPointer( grid.getRealImplementation(seed).hostElementSeed() ) )
{}
explicit EntityPointer ( const EntityImpl &entity )
: entity_( entity ),
hostElementIterator_( entity.hostElement() )
{}
EntityPointer ( const This &other )
: entity_( other.entityImpl() ),
hostElementIterator_( other.hostElementIterator_ )
{}
template< class T >
explicit EntityPointer ( const EntityPointer< T, fake > &other )
: entity_( other.entityImpl() ),
hostElementIterator_( other.hostElementIterator_ )
{}
const This &operator= ( const This &other )
{
entityImpl() = other.entityImpl();
hostElementIterator_ = other.hostElementIterator_;
return *this;
}
template< class T >
const This &operator= ( const EntityPointer< T, fake > &other )
{
entityImpl() = other.entityImpl();
hostElementIterator_ = other.hostElementIterator_;
return *this;
}
template< class T >
bool equals ( const EntityPointer< T, fake > &other ) const
{
const bool thisEnd = (subEntity() < 0);
const bool otherEnd = (other.subEntity() < 0);
if( thisEnd || otherEnd )
return thisEnd && otherEnd;
const int lvl = level();
if( lvl != other.level() )
return false;
const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
= grid().hostGrid().levelIndexSet( lvl );
const HostElement &thisElement = *hostElementIterator();
assert( indexSet.contains( thisElement ) );
const HostElement &otherElement = *(other.hostElementIterator());
assert( indexSet.contains( otherElement ) );
const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
return (thisIndex == otherIndex);
}
Entity &dereference () const
{
if( !entityImpl() )
entityImpl().initialize( *hostElementIterator() );
return entity_;
}
int level () const { return hostElementIterator().level(); }
const Grid &grid () const { return entityImpl().grid(); }
int subEntity () const { return entityImpl().subEntity(); }
protected:
EntityImpl &entityImpl () const
{
return Grid::getRealImplementation( entity_ );
}
const HostElementIterator &hostElementIterator () const
{
return hostElementIterator_;
}
private:
mutable Entity entity_;
protected:
HostElementIterator hostElementIterator_;
};
} // namespace GeoGrid
} // namespace Dune
#endif // #ifndef DUNE_GEOGRID_ENTITYPOINTER_HH
|