ug4
neighborhood_util_impl.hpp
Go to the documentation of this file.
1 
33 #include "neighborhood_util.h"
34 #include "grid.h"
35 #include "lib_grid/selector.h"
37 
38 namespace ug {
40  template <typename TElem>
42  (
43  Grid& grid,
44  size_t extSize,
45  TElem* elem,
48  ) {
49  Selector sel(grid);
50  typedef typename geometry_traits<TElem>::const_iterator Iter;
51  sel.template select<TElem>(elem);
52  grid.begin_marking();
53  for (size_t extIters = 0; extIters < extSize; ++extIters)
54  {
56  for(size_t lvl = 0; lvl < sel.num_levels(); ++lvl){
57  for(Iter iter = sel.template begin<TElem>(lvl);
58  iter != sel.template end<TElem>(lvl); ++iter)
59  {
60  TElem* el = *iter;
61  if(!grid.is_marked(el)){
62  grid.mark(el);
63  typename Grid::traits<TElem>::secure_container elemsOut;
64  grid.template associated_elements<TElem>(elemsOut, el);
65  size_t size = elemsOut.size();
66  for (size_t i = 0; i < size; i++) {
67  sel.template select<TElem>(elemsOut[i], 1);
68  }
69  }
70  }
71  }
72  }
73  grid.end_marking();
74  begin = sel.template begin<TElem>();
75  end = sel.template end<TElem>();
76  }
77 } // namespace ug
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
void begin_marking()
begin marking.
Definition: grid.cpp:1262
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
size_t size() const
returns the size of the associated array.
Definition: pointer_const_array_impl.hpp:106
specialization of ISelector for a grid of class Grid.
Definition: selector_grid.h:96
size_t num_levels() const
always returns 1
Definition: selector_grid_impl.hpp:180
Definition: grid_base_object_traits.h:68
void GetNeighborhood(const TSparseMatrix &A, size_t node, size_t depth, std::vector< size_t > &indices, std::vector< bool > &bVisited, bool bResetVisitedFlags=true)
Definition: sparsematrix_util.h:495
void SelectAssociatedGridObjects(TSelector &sel, ISelector::status_t status)
selects associated geometric objects of selected ones on each level.
Definition: selection_util.cpp:221
the ug namespace