/usr/include/dune/grid/onedgrid/onedgridhieriterator.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 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ONE_D_GRID_HIERITERATOR_HH
#define DUNE_ONE_D_GRID_HIERITERATOR_HH
/** \file
* \brief The OneDGridHierarchicIterator class
*/
#include <stack>
#include <dune/grid/onedgrid/onedgridentitypointer.hh>
namespace Dune {
//**********************************************************************
//
// --OneDGridHierarchicIterator
// --HierarchicIterator
/** \brief Iterator over the descendants of an entity.
* \ingroup OneDGrid
Mesh entities of codimension 0 ("elements") allow to visit all entities of
codimension 0 obtained through nested, hierarchic refinement of the entity.
Iteration over this set of entities is provided by the HierarchicIterator,
starting from a given entity.
*/
template<class GridImp>
class OneDGridHierarchicIterator :
public Dune::OneDGridEntityPointer <0,GridImp>
{
enum { dim = GridImp::dimension };
friend class OneDGridEntity<0,dim,GridImp>;
// Stack entry
typedef OneDGridList<OneDEntityImp<1> >::iterator StackEntry;
public:
typedef typename GridImp::template Codim<0>::Entity Entity;
//! Constructor
OneDGridHierarchicIterator(int maxlevel) : OneDGridEntityPointer<0,GridImp>(OneDGridNullIteratorFactory<1>::null()),
maxlevel_(maxlevel), elemStack()
{}
//! prefix increment
void increment() {
if (elemStack.empty())
return;
StackEntry old_target = elemStack.top();
elemStack.pop();
// Traverse the tree no deeper than maxlevel
if (old_target->level_ < maxlevel_) {
// Load sons of old target onto the iterator stack
if (!old_target->isLeaf()) {
elemStack.push(old_target->sons_[0]);
// Add the second son only if it is different from the first one
// i.e. the son is not just a copy of the father
if (old_target->sons_[0] != old_target->sons_[1])
elemStack.push(old_target->sons_[1]);
}
}
GridImp::getRealImplementation(this->virtualEntity_).setToTarget((elemStack.empty())
? OneDGridNullIteratorFactory<1>::null() : elemStack.top());
}
private:
//! max level to go down
int maxlevel_;
std::stack<StackEntry> elemStack;
};
} // end namespace Dune
#endif
|