Wayverb
postprocess_branches.h
1 #pragma once
2 
3 #include "raytracer/cl/structs.h"
4 #include "raytracer/image_source/tree.h"
5 
6 #include "core/callback_accumulator.h"
7 #include "core/spatial_division/voxelised_scene_data.h"
8 
9 #include "utilities/aligned/vector.h"
10 
11 #include <future>
12 
13 namespace wayverb {
14 namespace raytracer {
15 namespace image_source {
16 
17 util::aligned::vector<impulse<core::simulation_bands>> postprocess_branches(
18  const multitree<path_element>& tree,
19  const glm::vec3& source,
20  const glm::vec3& receiver,
21  const core::voxelised_scene_data<cl_float3,
22  core::surface<core::simulation_bands>>&
23  voxelised,
24  bool flip_phase);
25 
26 template <typename It>
27 auto postprocess_branches(
28  It b_branches,
29  It e_branches,
30  const glm::vec3& source,
31  const glm::vec3& receiver,
32  const core::voxelised_scene_data<cl_float3,
33  core::surface<core::simulation_bands>>&
34  voxelised,
35  bool flip_phase) {
36  auto futures = util::map_to_vector(
37  b_branches, e_branches, [&](const auto& branch) {
38  return std::async(std::launch::async, [&] {
39  return postprocess_branches(
40  branch, source, receiver, voxelised, flip_phase);
41  });
42  });
43 
44  using value_type = decltype(
45  std::declval<typename decltype(futures)::value_type>().get());
46 
47  // Collect futures.
48  value_type ret;
49  for (auto& fut : futures) {
50  const auto thread_results = fut.get();
51  ret.insert(ret.end(), thread_results.begin(), thread_results.end());
52  }
53 
54  return ret;
55 }
56 
57 } // namespace image_source
58 } // namespace raytracer
59 } // namespace wayverb
Definition: pressure.h:22
Definition: capsule_base.h:9