Blender V5.3
obj_import_file_reader.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "IO_wavefront_obj.hh"
12
13#include "BLI_map.hh"
14#include "BLI_vector.hh"
15
16#include "obj_import_objects.hh"
17
18namespace blender {
19struct BLI_mmap_file;
20}
21
22namespace blender::io::obj {
23
24struct MTLMaterial;
25
26class OBJParser {
27 private:
28 const OBJImportParams &import_params_;
29 Vector<std::string> mtl_libraries_;
30 BLI_mmap_file *mmap_file_ = nullptr;
31 std::string line_buffer_;
32
33 public:
37 OBJParser(const OBJImportParams &import_params);
38 ~OBJParser();
39
44 void parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries,
45 GlobalVertices &r_global_vertices);
50
51 private:
52 void add_mtl_library(StringRef path);
53 void add_default_mtl_library();
54 StringRef read_next_obj_line(StringRef &buffer);
55 void parse_string_buffer(StringRef &buffer_str,
56 Vector<std::unique_ptr<Geometry>> &r_all_geometries,
57 GlobalVertices &r_global_vertices,
58 Geometry *&curr_geom);
59};
60
61class MTLParser {
62 private:
63 char mtl_file_path_[FILE_MAX];
67 char mtl_dir_path_[FILE_MAX];
68
69 public:
73 MTLParser(StringRefNull mtl_library_, StringRefNull obj_filepath);
74
78 void parse_and_store(Map<std::string, std::unique_ptr<MTLMaterial>> &r_materials);
79};
80} // namespace blender::io::obj
#define FILE_MAX
void parse_and_store(Map< std::string, std::unique_ptr< MTLMaterial > > &r_materials)
MTLParser(StringRefNull mtl_library_, StringRefNull obj_filepath)
OBJParser(const OBJImportParams &import_params)
Span< std::string > mtl_libraries() const
void parse(Vector< std::unique_ptr< Geometry > > &r_all_geometries, GlobalVertices &r_global_vertices)
BMesh Iterators.