VPTissue Reference Manual
ReduceCellWalls.h
Go to the documentation of this file.
1 #ifndef REDUCE_CELL_WALLS_H_INCLUDED
2 #define REDUCE_CELL_WALLS_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "Cell.h"
23 #include "Wall.h"
24 
25 namespace SimPT_Sim {
26 
30 template<typename R> R ReduceCellWalls(Cell* cell, std::function<R(Cell*, Cell*, Wall*)> f)
31 {
32  R sum = R();
33  for (auto const& wall : cell->GetWalls()) {
34  sum += (wall->GetC1() == cell) ?
35  f(wall->GetC1(), wall->GetC2(), wall) : f(wall->GetC2(), wall->GetC1(), wall);
36  }
37  return sum;
38 }
39 
40 }
41 
42 #endif // end_of_include_guard
A cell contains walls and nodes.
Definition: Cell.h:48
R ReduceCellWalls(Cell *cell, std::function< R(Cell *, Cell *, Wall *)> f)
Traverse walls of cell and apply functor.
const std::list< Wall * > & GetWalls() const
Access the cell's walls.
Definition: Cell.h:88
Namespace for the core simulator.
Interface for Cell.
A cell wall, runs between cell corner points and consists of wall elements.
Definition: Wall.h:48
Interface for Wall.