Belle II Software development
WeightedFastHoughTree< T, ADomain, ADomainDivsion > Class Template Reference

Dynamic tree structure with weighted items in each node which are markable through out the tree. More...

#include <WeightedFastHoughTree.h>

Inheritance diagram for WeightedFastHoughTree< T, ADomain, ADomainDivsion >:
WeightedParititioningDynTree< WithSharedMark< T >, ADomain, ADomainDivsion > DynTree< WithWeightedItems< ADomain, T >, ADomainDivsion >

Public Types

using Node = typename Super::Node
 Type of the node in the tree.
 

Public Member Functions

template<class Ts>
void seed (const Ts &items)
 Take the item set and insert them into the top node of the hough space.
 
template<class AItemInDomainMeasure>
std::vector< std::pair< ADomain, std::vector< T > > > findHeavyLeavesDisjoint (AItemInDomainMeasure &weightItemInDomain, int maxLevel, double minWeight)
 Find all children node at maximum level and add them to the result list. Skip nodes if their weight is below minWeight.
 
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::vector< std::pair< ADomain, std::vector< T > > > findLeavesDisjoint (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
 Find all children node at maximum level and add them to the result list. Skip nodes if skipNode returns true.
 
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
 Go through all children until maxLevel is reached and find the heaviest leaves.
 
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::unique_ptr< std::pair< ADomain, std::vector< T > > > findHeaviestLeafSingle (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
 Go through all children until the maxLevel is reached and find the leaf with the highest weight.
 
template<class AItemInDomainMeasure, class ASkipNodePredicate>
Node * findHeaviestLeaf (AItemInDomainMeasure &weightItemInDomain, int maxLevel, ASkipNodePredicate &skipNode)
 Go through all children until the maxLevel is reached and find the leaf with the highest weight.
 
template<class AItemInDomainMeasure, class AIsLeafPredicate>
void fillWalk (AItemInDomainMeasure &weightItemInDomain, AIsLeafPredicate &isLeaf, bool isLeafMarksItems=true)
 Walk through the children and fill them if necessary until isLeaf returns true.
 
template<class ATreeWalker>
void walkHeighWeightFirst (ATreeWalker &walker, bool walkerMarksItems=true)
 Walk the tree investigating the heaviest children with priority.
 
void fell ()
 Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.
 
void raze ()
 Like fell but also releases all memory the tree has acquired during long executions.
 
Node & getTopNode ()
 Getter for the top node of the tree.
 
const Node & getTopNode () const
 Constant getter for the top node of the tree.
 
Node & getTopNode ()
 Getter for the top node of the tree.
 
const Node & getTopNode () const
 Constant getter for the top node of the tree.
 
int getNNodes () const
 Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.
 
int getNNodes () const
 Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.
 
std::map< int, int > getNNodesByLevel () const
 Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.
 
std::map< int, int > getNNodesByLevel () const
 Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.
 
void walk (AWalker &walker)
 Forward walk to the top node.
 
void walk (AWalker &walker, APriorityMeasure &priority)
 Forward walk to the top node.
 
void walk (AWalker &walker)
 Forward walk to the top node.
 
void walk (AWalker &walker, APriorityMeasure &priority)
 Forward walk to the top node.
 

Static Public Member Functions

template<class AItemInDomainMeasure>
static std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated (AItemInDomainMeasure &weightItemInDomain, int maxLevel, const TrackingUtilities::Weight minWeight=NAN)
 Go through all children until maxLevel is reached and find the heaviest leaves.
 

Public Attributes

SubPropertiesFactory m_subPropertiesFactory
 Instance of the properties factory for the sub nodes.
 
SubPropertiesFactory m_subPropertiesFactory
 Instance of the properties factory for the sub nodes.
 
Node m_topNode
 Memory for the top node of the tree.
 
Node m_topNode
 Memory for the top node of the tree.
 
std::deque< typename Node::Children > m_children
 Central point to provide memory for the child structures.
 
std::deque< typename Node::Children > m_children
 Central point to provide memory for the child structures.
 
size_t m_nUsedChildren
 Last index of used children.
 
size_t m_nUsedChildren
 Last index of used children.
 

Private Types

using Super = WeightedParititioningDynTree<WithSharedMark<T>, ADomain, ADomainDivsion>
 Type of the Tree the partitions using markable items the hough space.
 
using This
 Type of this class.
 
using Properties
 Type of the Properties.
 
using SubPropertiesFactory
 Type of the factory for the sub node properties.
 

Private Member Functions

std::vector< Node > * createChildren (Node *parentNode)
 Create child nodes for the given parents.
 
std::vector< Node > * createChildren (Node *parentNode)
 Create child nodes for the given parents.
 
std::vector< Node > * getUnusedChildren ()
 Acquire the next unused child node structure, recycling all memory.
 
std::vector< Node > * getUnusedChildren ()
 Acquire the next unused child node structure, recycling all memory.
 

Private Attributes

std::deque< bool > m_marks
 Memory of the used marks of the items.
 

Detailed Description

template<class T, class ADomain, class ADomainDivsion>
class Belle2::TrackFindingCDC::WeightedFastHoughTree< T, ADomain, ADomainDivsion >

Dynamic tree structure with weighted items in each node which are markable through out the tree.

Used to build fast hough type algorithms, where objects are allowed to carry weights relative to the hough space part (here called a ADomain) they are contained in. The shared marks allow for iterative extraction of hough peaks such that other areas of the hough space notice that certain element have already been consumed.

Definition at line 51 of file WeightedFastHoughTree.h.

Member Typedef Documentation

◆ Node

template<class T, class ADomain, class ADomainDivsion>
using Node = typename Super::Node

Type of the node in the tree.

Definition at line 63 of file WeightedFastHoughTree.h.

◆ Properties

using Properties
privateinherited

Type of the Properties.

Definition at line 41 of file DynTree.h.

◆ SubPropertiesFactory

using SubPropertiesFactory
privateinherited

Type of the factory for the sub node properties.

Definition at line 44 of file DynTree.h.

◆ Super

template<class T, class ADomain, class ADomainDivsion>
using Super = WeightedParititioningDynTree<WithSharedMark<T>, ADomain, ADomainDivsion>
private

Type of the Tree the partitions using markable items the hough space.

Definition at line 56 of file WeightedFastHoughTree.h.

◆ This

using This
privateinherited

Type of this class.

Definition at line 38 of file DynTree.h.

Member Function Documentation

◆ createChildren() [1/2]

std::vector< Node > * createChildren ( Node * parentNode)
inlineprivateinherited

Create child nodes for the given parents.

Definition at line 284 of file DynTree.h.

285 {
286 std::vector<Node>* result = getUnusedChildren();
287 auto subProperties = m_subPropertiesFactory(*parentNode);
288 if (subProperties.empty()) {
289 result->clear();
290 } else {
291 // Initialize new elements with dummy property.
292 result->resize(subProperties.size(), Node(subProperties.back()));
293 size_t iSubNode = 0;
294 for (const auto& properties : subProperties) {
295 TrackingUtilities::clearIfApplicable(result->at(iSubNode));
296 result->at(iSubNode) = properties;
297 ++iSubNode;
298 }
299 }
300 return result;
301 }

◆ createChildren() [2/2]

std::vector< Node > * createChildren ( Node * parentNode)
inlineprivateinherited

Create child nodes for the given parents.

Definition at line 284 of file DynTree.h.

285 {
286 std::vector<Node>* result = getUnusedChildren();
287 auto subProperties = m_subPropertiesFactory(*parentNode);
288 if (subProperties.empty()) {
289 result->clear();
290 } else {
291 // Initialize new elements with dummy property.
292 result->resize(subProperties.size(), Node(subProperties.back()));
293 size_t iSubNode = 0;
294 for (const auto& properties : subProperties) {
295 TrackingUtilities::clearIfApplicable(result->at(iSubNode));
296 result->at(iSubNode) = properties;
297 ++iSubNode;
298 }
299 }
300 return result;
301 }

◆ fell()

template<class T, class ADomain, class ADomainDivsion>
void fell ( )
inline

Fell to tree meaning deleting all child nodes from the tree. Keeps the top node.

Definition at line 326 of file WeightedFastHoughTree.h.

327 {
328 this->getTopNode().clear();
329 m_marks.clear();
330 Super::fell();
331 }

◆ fillWalk()

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class AIsLeafPredicate>
void fillWalk ( AItemInDomainMeasure & weightItemInDomain,
AIsLeafPredicate & isLeaf,
bool isLeafMarksItems = true )
inline

Walk through the children and fill them if necessary until isLeaf returns true.

Uses the weightItemInDomain to create weights for the items (or decide if an item belongs to a mode or not).

Definition at line 243 of file WeightedFastHoughTree.h.

246 {
247 auto walker = [&weightItemInDomain, &isLeaf](Node * node) {
248 // Check if node is a leaf
249 // Do not create children in this case
250 if (isLeaf(node)) {
251 // Do not walk children.
252 return false;
253 }
254
255 // Node is not a leaf.
256 // Check if it has children.
257 // If children have not been created, create and fill them.
258 typename Node::Children* children = node->getChildren();
259 if (not children) {
260 node->createChildren();
261 children = node->getChildren();
262 if constexpr(std::is_invocable_v<AItemInDomainMeasure&, const T&, Node*>) {
263 // Weighting function does not modify the item: fill all children in a single pass
264 // over the parent items without copies. Each child receives the items in the same order.
265 for (const WithSharedMark<T>& markableItem : *node) {
266 // Weighting function should not see the mark, but only the item itself.
267 const T& item(markableItem);
268 for (Node& childNode : *children) {
269 const TrackingUtilities::Weight weight = weightItemInDomain(item, &childNode);
270 if (not std::isnan(weight)) {
271 childNode.insert(markableItem, weight);
272 }
273 }
274 }
275 } else {
276 for (Node& childNode : *children) {
277 assert(childNode.getChildren() == nullptr);
278 assert(childNode.size() == 0);
279 auto measure =
280 // cppcheck-suppress constParameterReference ; the item is unwrapped as a non-const reference below
281 [&childNode, &weightItemInDomain](WithSharedMark<T>& markableItem) -> TrackingUtilities::Weight {
282 // Weighting function should not see the mark, but only the item itself.
283 T & item(markableItem);
284 return weightItemInDomain(item, &childNode);
285 };
286 childNode.insert(*node, measure);
287 }
288 }
289 }
290 // Continue to walk the children.
291 return true;
292 };
293 walkHeighWeightFirst(walker, isLeafMarksItems);
294 }

◆ findHeaviestLeaf()

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
Node * findHeaviestLeaf ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
ASkipNodePredicate & skipNode )
inline

Go through all children until the maxLevel is reached and find the leaf with the highest weight.

If no node could be found, return a nullptr. A node is skipped if skipNode is returns true for this node.

Definition at line 203 of file WeightedFastHoughTree.h.

206 {
207 Node* heaviestNode = nullptr;
208 TrackingUtilities::Weight heighestWeigth = NAN;
209 auto isLeaf = [&heaviestNode, &heighestWeigth, maxLevel, &skipNode](Node * node) {
210 // Skip the expansion and the filling of the children
211 if (skipNode(node)) {
212 return true;
213 }
214
215 TrackingUtilities::Weight nodeWeight = node->getWeight();
216 // Skip the expansion and filling of the children if the node has not enough weight
217 if (not std::isnan(heighestWeigth) and not(nodeWeight > heighestWeigth)) {
218 return true;
219 }
220
221 // Node is a leaf at the maximum level and is heavier than everything seen before.
222 // Save its content
223 // Do not walk children
224 if (node->getLevel() >= maxLevel) {
225 heaviestNode = node;
226 heighestWeigth = nodeWeight;
227 return true;
228 }
229 return false;
230 };
231 // The isLeaf predicate does not mark any items.
232 const bool isLeafMarksItems = false;
233 fillWalk(weightItemInDomain, isLeaf, isLeafMarksItems);
234 return heaviestNode;
235 }

◆ findHeaviestLeafRepeated() [1/2]

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
ASkipNodePredicate & skipNode )
inline

Go through all children until maxLevel is reached and find the heaviest leaves.

For this, the single heaviest leaf is found and added to an internal list. The process is repeated until no leaf can be found anymore. A node is skipped if skipNode is returns true for this node.

Definition at line 156 of file WeightedFastHoughTree.h.

159 {
160 std::vector<std::pair<ADomain, std::vector<T> > > found;
161 Node* node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
162 while (node) {
163 const ADomain* domain = node;
164 found.emplace_back(*domain, std::vector<T>(node->begin(), node->end()));
165 for (WithSharedMark<T>& markableItem : *node) {
166 markableItem.mark();
167 }
168 node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
169 }
170 return found;
171 }

◆ findHeaviestLeafRepeated() [2/2]

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure>
static std::vector< std::pair< ADomain, std::vector< T > > > findHeaviestLeafRepeated ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
const TrackingUtilities::Weight minWeight = NAN )
inlinestatic

Go through all children until maxLevel is reached and find the heaviest leaves.

For this, the single heaviest leaf is found and added to an internal list. The process is repeated until no leaf can be found anymore. A node is skipped if the weight is below minWeight.

Definition at line 137 of file WeightedFastHoughTree.h.

140 {
141 auto skipLowWeightNode = [minWeight](const Node * node) {
142 return not(node->getWeight() >= minWeight);
143 };
144 return findHeaviestLeafRepeated(weightItemInDomain, maxLevel, skipLowWeightNode);
145 }

◆ findHeaviestLeafSingle()

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::unique_ptr< std::pair< ADomain, std::vector< T > > > findHeaviestLeafSingle ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
ASkipNodePredicate & skipNode )
inline

Go through all children until the maxLevel is reached and find the leaf with the highest weight.

If no node could be found, return an empty list, otherwise return a list with just on element. A node is skipped if skipNode is returns true for this node.

Definition at line 180 of file WeightedFastHoughTree.h.

183 {
184 using Result = std::pair<ADomain, std::vector<T> >;
185 std::unique_ptr<Result> found = nullptr;
186 Node* node = findHeaviestLeaf(weightItemInDomain, maxLevel, skipNode);
187 if (node) {
188 const ADomain* domain = node;
189 found.reset(new Result(*domain, std::vector<T>(node->begin(), node->end())));
190 for (WithSharedMark<T>& markableItem : *node) {
191 markableItem.mark();
192 }
193 }
194 return found;
195 }

◆ findHeavyLeavesDisjoint()

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure>
std::vector< std::pair< ADomain, std::vector< T > > > findHeavyLeavesDisjoint ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
double minWeight )
inline

Find all children node at maximum level and add them to the result list. Skip nodes if their weight is below minWeight.

Definition at line 83 of file WeightedFastHoughTree.h.

86 {
87 auto skipLowWeightNode = [minWeight](const Node * node) {
88 return not(node->getWeight() >= minWeight);
89 };
90 return findLeavesDisjoint(weightItemInDomain, maxLevel, skipLowWeightNode);
91 }

◆ findLeavesDisjoint()

template<class T, class ADomain, class ADomainDivsion>
template<class AItemInDomainMeasure, class ASkipNodePredicate>
std::vector< std::pair< ADomain, std::vector< T > > > findLeavesDisjoint ( AItemInDomainMeasure & weightItemInDomain,
int maxLevel,
ASkipNodePredicate & skipNode )
inline

Find all children node at maximum level and add them to the result list. Skip nodes if skipNode returns true.

Definition at line 96 of file WeightedFastHoughTree.h.

99 {
100 std::vector<std::pair<ADomain, std::vector<T> > > found;
101 auto isLeaf = [&found, &skipNode, maxLevel](Node * node) {
102 // Skip the expansion and the filling of the children
103 if (skipNode(node)) {
104 return true;
105 }
106
107 // Node is a leaf at the maximum level
108 // Save its content
109 // Do not walk children
110 if (node->getLevel() >= maxLevel) {
111 const ADomain* domain = node;
112 found.emplace_back(*domain, std::vector<T>(node->begin(), node->end()));
113 for (WithSharedMark<T>& markableItem : *node) {
114 markableItem.mark();
115 }
116 return true;
117 }
118
119 // Else to node has enough weight and is not at the lowest level
120 // Signal that it is not a leaf
121 // Continue to create and fill children.
122 return false;
123 };
124 fillWalk(weightItemInDomain, isLeaf);
125 return found;
126 }

◆ getNNodes() [1/2]

int getNNodes ( ) const
inlineinherited

Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.

Definition at line 248 of file DynTree.h.

249 {
250 int nNodes = 0;
251 auto countNodes = [&nNodes](const Node*) -> bool {
252 ++nNodes;
253 return true;
254 };
255 const_cast<DynTree&>(*this).walk(countNodes);
256 //walk(countNodes);
257 return nNodes;
258 }

◆ getNNodes() [2/2]

int getNNodes ( ) const
inlineinherited

Gets the number of nodes currently contained in the tree Also demonstrates how to walk over the tree.

Definition at line 248 of file DynTree.h.

249 {
250 int nNodes = 0;
251 auto countNodes = [&nNodes](const Node*) -> bool {
252 ++nNodes;
253 return true;
254 };
255 const_cast<DynTree&>(*this).walk(countNodes);
256 //walk(countNodes);
257 return nNodes;
258 }

◆ getNNodesByLevel() [1/2]

std::map< int, int > getNNodesByLevel ( ) const
inlineinherited

Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.

Definition at line 264 of file DynTree.h.

265 {
266 std::map<int, int> nNodesByLevel;
267 auto countNodes = [&nNodesByLevel](const Node * node) -> bool {
268 if (nNodesByLevel.count(node->getLevel()) == 0)
269 {
270 nNodesByLevel[node->getLevel()] = 1;
271 } else
272 {
273 nNodesByLevel[node->getLevel()]++;
274 }
275 return true;
276 };
277 const_cast<DynTree&>(*this).walk(countNodes);
278 //walk(countNodes);
279 return nNodesByLevel;
280 }

◆ getNNodesByLevel() [2/2]

std::map< int, int > getNNodesByLevel ( ) const
inlineinherited

Gets the number of nodes by level in the tree Also demonstrates how to walk over the tree.

Definition at line 264 of file DynTree.h.

265 {
266 std::map<int, int> nNodesByLevel;
267 auto countNodes = [&nNodesByLevel](const Node * node) -> bool {
268 if (nNodesByLevel.count(node->getLevel()) == 0)
269 {
270 nNodesByLevel[node->getLevel()] = 1;
271 } else
272 {
273 nNodesByLevel[node->getLevel()]++;
274 }
275 return true;
276 };
277 const_cast<DynTree&>(*this).walk(countNodes);
278 //walk(countNodes);
279 return nNodesByLevel;
280 }

◆ getTopNode() [1/4]

Node & getTopNode ( )
inlineinherited

Getter for the top node of the tree.

Definition at line 237 of file DynTree.h.

238 { return m_topNode; }

◆ getTopNode() [2/4]

Node & getTopNode ( )
inlineinherited

Getter for the top node of the tree.

Definition at line 237 of file DynTree.h.

238 { return m_topNode; }

◆ getTopNode() [3/4]

const Node & getTopNode ( ) const
inlineinherited

Constant getter for the top node of the tree.

Definition at line 241 of file DynTree.h.

242 { return m_topNode; }

◆ getTopNode() [4/4]

const Node & getTopNode ( ) const
inlineinherited

Constant getter for the top node of the tree.

Definition at line 241 of file DynTree.h.

242 { return m_topNode; }

◆ getUnusedChildren() [1/2]

std::vector< Node > * getUnusedChildren ( )
inlineprivateinherited

Acquire the next unused child node structure, recycling all memory.

Definition at line 304 of file DynTree.h.

305 {
306 if (m_nUsedChildren >= m_children.size()) {
307 m_children.emplace_back();
308 }
309 ++m_nUsedChildren;
310 return &(m_children[m_nUsedChildren - 1]);
311 }

◆ getUnusedChildren() [2/2]

std::vector< Node > * getUnusedChildren ( )
inlineprivateinherited

Acquire the next unused child node structure, recycling all memory.

Definition at line 304 of file DynTree.h.

305 {
306 if (m_nUsedChildren >= m_children.size()) {
307 m_children.emplace_back();
308 }
309 ++m_nUsedChildren;
310 return &(m_children[m_nUsedChildren - 1]);
311 }

◆ raze()

template<class T, class ADomain, class ADomainDivsion>
void raze ( )
inline

Like fell but also releases all memory the tree has acquired during long executions.

Definition at line 335 of file WeightedFastHoughTree.h.

336 {
337 this->fell();
338 Super::raze();
339 m_marks.shrink_to_fit();
340 }

◆ seed()

template<class T, class ADomain, class ADomainDivsion>
template<class Ts>
void seed ( const Ts & items)
inline

Take the item set and insert them into the top node of the hough space.

Definition at line 68 of file WeightedFastHoughTree.h.

69 {
70 this->fell();
71 Node& topNode = this->getTopNode();
72 for (auto&& item : items) {
73 m_marks.push_back(false);
74 bool& markOfItem = m_marks.back();
75 TrackingUtilities::Weight weight = DBL_MAX;
76 topNode.insert(WithSharedMark<T>(T(item), &markOfItem), weight);
77 }
78 }

◆ walk() [1/4]

void walk ( AWalker & walker)
inlineinherited

Forward walk to the top node.

Definition at line 316 of file DynTree.h.

317 {
318 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
319
320 getTopNode().walk(walker);
321 }

◆ walk() [2/4]

void walk ( AWalker & walker)
inlineinherited

Forward walk to the top node.

Definition at line 316 of file DynTree.h.

317 {
318 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
319
320 getTopNode().walk(walker);
321 }

◆ walk() [3/4]

void walk ( AWalker & walker,
APriorityMeasure & priority )
inlineinherited

Forward walk to the top node.

Definition at line 325 of file DynTree.h.

326 {
327 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
328 static_assert(std::is_assignable<std::function<float(Node*)>, APriorityMeasure>(), "");
329
330 getTopNode().walk(walker, priority);
331 }

◆ walk() [4/4]

void walk ( AWalker & walker,
APriorityMeasure & priority )
inlineinherited

Forward walk to the top node.

Definition at line 325 of file DynTree.h.

326 {
327 static_assert(std::is_assignable<std::function<bool(Node*)>, AWalker>(), "");
328 static_assert(std::is_assignable<std::function<float(Node*)>, APriorityMeasure>(), "");
329
330 getTopNode().walk(walker, priority);
331 }

◆ walkHeighWeightFirst()

template<class T, class ADomain, class ADomainDivsion>
template<class ATreeWalker>
void walkHeighWeightFirst ( ATreeWalker & walker,
bool walkerMarksItems = true )
inline

Walk the tree investigating the heaviest children with priority.

If the walker is known not to mark items and no item is marked yet, the removal of marked items can be skipped as it would never erase anything.

Clear items that have been marked as used before evaluating the weight.

Definition at line 302 of file WeightedFastHoughTree.h.

303 {
304 if (not walkerMarksItems and std::find(m_marks.begin(), m_marks.end(), true) == m_marks.end()) {
305 auto unmarkedPriority = [](Node * node) -> float {
306 return node->getWeight();
307 };
308 this->walk(walker, unmarkedPriority);
309 return;
310 }
311
312 auto priority = [](Node * node) -> float {
314 auto isMarked = [](const WithSharedMark<T>& markableItem) -> bool {
315 return markableItem.isMarked();
316 };
317 node->eraseIf(isMarked);
318 return node->getWeight();
319 };
320
321 this->walk(walker, priority);
322 }

Member Data Documentation

◆ m_children [1/2]

std::deque<typename Node::Children> m_children
inherited

Central point to provide memory for the child structures.

Definition at line 365 of file DynTree.h.

◆ m_children [2/2]

std::deque<typename Node::Children> m_children
inherited

Central point to provide memory for the child structures.

Definition at line 365 of file DynTree.h.

◆ m_marks

template<class T, class ADomain, class ADomainDivsion>
std::deque<bool> m_marks
private

Memory of the used marks of the items.

Definition at line 344 of file WeightedFastHoughTree.h.

◆ m_nUsedChildren [1/2]

size_t m_nUsedChildren
inherited

Last index of used children.

Definition at line 368 of file DynTree.h.

◆ m_nUsedChildren [2/2]

size_t m_nUsedChildren
inherited

Last index of used children.

Definition at line 368 of file DynTree.h.

◆ m_subPropertiesFactory [1/2]

SubPropertiesFactory m_subPropertiesFactory
inherited

Instance of the properties factory for the sub nodes.

Definition at line 359 of file DynTree.h.

◆ m_subPropertiesFactory [2/2]

SubPropertiesFactory m_subPropertiesFactory
inherited

Instance of the properties factory for the sub nodes.

Definition at line 359 of file DynTree.h.

◆ m_topNode [1/2]

Node m_topNode
inherited

Memory for the top node of the tree.

Definition at line 362 of file DynTree.h.

◆ m_topNode [2/2]

Node m_topNode
inherited

Memory for the top node of the tree.

Definition at line 362 of file DynTree.h.


The documentation for this class was generated from the following file: