10#include <framework/logging/Logger.h>
33 template<
class ContainerType,
class NodeType,
class NeighbourContainerType>
44 short currentFamily = 0;
46 if (aNode->getFamily() != -1) {
50 aNode->setFamily(currentFamily);
52 NeighbourContainerType& innerNeighbours = aNode->getInnerNodes();
53 NeighbourContainerType& outerNeighbours = aNode->getOuterNodes();
54 NeighbourContainerType neighbours;
55 neighbours.reserve(innerNeighbours.size() + outerNeighbours.size());
56 neighbours.insert(neighbours.end(), innerNeighbours.begin(), innerNeighbours.end());
57 neighbours.insert(neighbours.end(), outerNeighbours.begin(), outerNeighbours.end());
59 while (neighbours.size() != 0) {
60 neighbours =
markNodes(currentFamily, neighbours);
69 NeighbourContainerType
markNodes(
short family,
const NeighbourContainerType& neighbours)
71 NeighbourContainerType newNeighbours;
72 for (
auto& neighbour : neighbours) {
74 if (neighbour->getFamily() != -1) {
75 short tmpFamily = neighbour->getFamily();
76 if (tmpFamily != family) {
77 B2FATAL(
"Node already assigned to different family: " << family <<
", " << tmpFamily);
82 neighbour->setFamily(family);
83 NeighbourContainerType& innerNeighbours = neighbour->getInnerNodes();
84 NeighbourContainerType& outerNeighbours = neighbour->getOuterNodes();
85 newNeighbours.reserve(innerNeighbours.size() + outerNeighbours.size());
86 newNeighbours.insert(newNeighbours.end(), innerNeighbours.begin(), innerNeighbours.end());
87 newNeighbours.insert(newNeighbours.end(), outerNeighbours.begin(), outerNeighbours.end());
This class assigns a common family identifier to all CACells in the network that are connected.
short defineFamilies(ContainerType &aNetwork)
Assign a common family identifier to all Nodes in the network that are connected.
NeighbourContainerType markNodes(short family, const NeighbourContainerType &neighbours)
Assign family to all connected nodes and return their neighbours.
NodeType
Enum of possible Nodes in parsing tree.
Abstract base class for different kinds of events.