Wayverb
scene_data_loader.h
1 #pragma once
2 
3 #include "core/scene_data.h"
4 
5 #include "utilities/aligned/unordered_map.h"
6 #include "utilities/map_to_vector.h"
7 
8 #include <experimental/optional>
9 
10 namespace wayverb {
11 namespace core {
12 
13 class scene_data_loader final {
14 public:
16  scene_data_loader(const std::string& fpath);
17 
18  // need to declare but not define these here because pimpl idiom wew
20  scene_data_loader& operator=(scene_data_loader&&) noexcept;
21  ~scene_data_loader() noexcept;
22 
23  void load(const std::string& f);
24  void save(const std::string& f) const;
25 
26  void clear();
27 
29  std::string get_extensions() const;
30 
32  const std::experimental::optional<scene_data>& get_scene_data() const;
33 
34 private:
35  class impl;
36  std::unique_ptr<impl> pimpl_;
37 };
38 
39 template <typename Vertex, typename Surface>
40 auto scene_with_extracted_surfaces(
42  const util::aligned::unordered_map<std::string, Surface>&
43  surface_table) {
44  const auto surfaces = util::map_to_vector(
45  begin(scene.get_surfaces()),
46  end(scene.get_surfaces()),
47  [&](const auto& i) {
48  const auto it = surface_table.find(i);
49  return it != surface_table.end() ? it->second : Surface();
50  });
51 
52  return make_scene_data(
53  scene.get_triangles(), scene.get_vertices(), std::move(surfaces));
54 }
55 
56 } // namespace core
57 } // namespace wayverb
Definition: scene_data.h:13
Definition: scene_data_loader.h:13
Definition: traits.cpp:2
Definition: scene_data_loader.cpp:16
Definition: capsule_base.h:9
std::string get_extensions() const
Get all file extensions that the loader might understand.
Definition: scene_data_loader.cpp:123