Helios++
Helios software for LiDAR simulations
KDTreeFactoryThreadPool.h
1 #pragma once
2 
3 #include <MDThreadPool.h>
4 #include <KDTreeBuildType.h>
5 
6 
18  KDTreeBuildType,
19  KDTreeNode *,
20  bool const,
21  vector<Primitive*> &,
22  int const,
23  int const
24 >{
25 public:
26  // *** CONSTRUCTION / DESTRUCTION *** //
27  // ************************************ //
32  explicit KDTreeFactoryThreadPool(std::size_t const _pool_size) :
35  KDTreeNode *,
36  bool const,
37  vector<Primitive*> &,
38  int const,
39  int const
40  >(_pool_size)
41  {}
48  KDTreeFactoryThreadPool(std::thread::hardware_concurrency())
49  {}
50  virtual ~KDTreeFactoryThreadPool() {}
51 
52 protected:
59  inline void do_md_task(
60  boost::function<void(
61  KDTreeNode *,
62  bool const,
63  vector<Primitive*> &,
64  int const,
65  int const
66  )> &task,
67  KDTreeBuildType *data
68  ) override {
69  task(
70  data->parent,
71  data->left,
72  data->primitives,
73  data->depth,
74  data->index
75  );
76  delete data;
77  }
78 };
Build type to wrap data required for recursive building of KDTree nodes when using a KDTreeFactory ba...
Definition: KDTreeBuildType.h:11
KDTreeNode * parent
The parent node.
Definition: KDTreeBuildType.h:19
vector< Primitive * > primitives
Primitives to build KDTree node from.
Definition: KDTreeBuildType.h:30
int index
Index of node at current depth.
Definition: KDTreeBuildType.h:40
bool left
True if given node is a left child, false otherwise. Notice root node is not left nor right,...
Definition: KDTreeBuildType.h:25
int depth
Depth of node.
Definition: KDTreeBuildType.h:35
Class implementing a thread pool to deal with multi thread KDTree building process.
Definition: KDTreeFactoryThreadPool.h:24
KDTreeFactoryThreadPool(std::size_t const _pool_size)
KDTree factory thread pool constructor.
Definition: KDTreeFactoryThreadPool.h:32
void do_md_task(boost::function< void(KDTreeNode *, bool const, vector< Primitive * > &, int const, int const)> &task, KDTreeBuildType *data) override
Do a recursive build of KDTree node task.
Definition: KDTreeFactoryThreadPool.h:59
KDTreeFactoryThreadPool()
KDTree factory thread pool constructor which uses concurrent threads supported by the system as the d...
Definition: KDTreeFactoryThreadPool.h:47
Class representing a KDTree node.
Definition: KDTreeNode.h:9
Abstract class extending basic thread pool implementation to provide a basis layer to handle tasks wi...
Definition: MDThreadPool.h:22
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:24