Helios++
Helios software for LiDAR simulations
SAHKDTreeComputeLossNodesSubTask.h
1 #pragma once
2 
3 #include <SharedSubTask.h>
4 #include <SharedTaskSequencer.h>
5 
18 protected:
19  // *** ATTRIBUTES *** //
20  // ******************** //
25  vector<Primitive *> const &primitives;
29  double const start;
33  double const step;
37  int const splitAxis;
41  double const minBound;
45  double const boundLength;
50  size_t const startNode;
55  size_t const endNode;
59  double &partialLoss;
63  double &partialSplitPos;
68  std::function<double(
69  vector<Primitive *> const &primitives,
70  int const splitAxis,
71  double const splitPos,
72  double const r
74 
75 public:
76  // *** CONSTRUCTION / DESTRUCTION *** //
77  // ************************************ //
82  std::shared_ptr<SharedTaskSequencer> ch,
83  vector<Primitive *> const &primitives,
84  double const start,
85  double const step,
86  int const splitAxis,
87  double const minBound,
88  double const boundLength,
89  size_t const startNode,
90  size_t const endNode,
91  double &partialLoss,
92  double &partialSplitPos,
93  std::function<double(
94  vector<Primitive *> const &primitives,
95  int const splitAxis,
96  double const splitPos,
97  double const r
98  )> splitLoss
99  ) :
100  SharedSubTask(ch),
102  start(start),
103  step(step),
108  endNode(endNode),
112  {}
114 
115  // *** RUNNABLE SHARED TASK *** //
116  // ****************************** //
122  void run() override{
123  for(size_t i = startNode ; i < endNode ; ++i){
124  double const phi = start + ((double)i)*step;
125  double const newLoss = splitLoss(
126  primitives,
127  splitAxis,
128  phi,
129  (phi-minBound) / boundLength
130  );
131  if(newLoss < partialLoss){
132  partialLoss = newLoss;
133  partialSplitPos = phi;
134  }
135  }
136  }
137 };
Shared sub-task to compute loss nodes when finding the split position during SAH KDTree building....
Definition: SAHKDTreeComputeLossNodesSubTask.h:17
double const start
Start split position.
Definition: SAHKDTreeComputeLossNodesSubTask.h:29
int const splitAxis
Split axis for current partition case.
Definition: SAHKDTreeComputeLossNodesSubTask.h:37
double const minBound
Min coordinate of boundary.
Definition: SAHKDTreeComputeLossNodesSubTask.h:41
double const step
Step size between consecutive split positions.
Definition: SAHKDTreeComputeLossNodesSubTask.h:33
double & partialLoss
Where the best loss must be stored.
Definition: SAHKDTreeComputeLossNodesSubTask.h:59
double & partialSplitPos
Where the split position associated to best loss must be stored.
Definition: SAHKDTreeComputeLossNodesSubTask.h:63
void run() override
Implementation of the compute loss nodes method.
Definition: SAHKDTreeComputeLossNodesSubTask.h:122
size_t const endNode
End node (exclusive) for the iterative workload that must be computed by this sub-task.
Definition: SAHKDTreeComputeLossNodesSubTask.h:55
double const boundLength
Boundary length.
Definition: SAHKDTreeComputeLossNodesSubTask.h:45
size_t const startNode
Start node (inclusive) for the iterative workload that must be computed by this sub-task.
Definition: SAHKDTreeComputeLossNodesSubTask.h:50
std::function< double(vector< Primitive * > const &primitives, int const splitAxis, double const splitPos, double const r)> splitLoss
Function to colculate the loss itself for a given split.
Definition: SAHKDTreeComputeLossNodesSubTask.h:73
vector< Primitive * > const & primitives
Primitives being splitted to compute corresponding loss function.
Definition: SAHKDTreeComputeLossNodesSubTask.h:25
SAHKDTreeComputeLossNodesSubTask(std::shared_ptr< SharedTaskSequencer > ch, vector< Primitive * > const &primitives, double const start, double const step, int const splitAxis, double const minBound, double const boundLength, size_t const startNode, size_t const endNode, double &partialLoss, double &partialSplitPos, std::function< double(vector< Primitive * > const &primitives, int const splitAxis, double const splitPos, double const r)> splitLoss)
Main constructor for SAH KDTree compute loss nodes sub-task.
Definition: SAHKDTreeComputeLossNodesSubTask.h:81
A shared task is said to be a collection of shared sub-tasks. Each shared sub-task can be computed in...
Definition: SharedSubTask.h:16
std::shared_ptr< SharedSubTaskCompletionHandler > ch
The shared sub-task completion handler that handles what must be done after a shared sub-task executi...
Definition: SharedSubTask.h:28