Blender  V3.3
obj_import_file_reader.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "BLI_fileops.hh"
10 #include "IO_wavefront_obj.h"
11 #include "obj_import_mtl.hh"
12 #include "obj_import_objects.hh"
13 
14 namespace blender::io::obj {
15 
16 /* NOTE: the OBJ parser implementation is planned to get fairly large changes "soon",
17  * so don't read too much into current implementation... */
18 class OBJParser {
19  private:
20  const OBJImportParams &import_params_;
21  FILE *obj_file_;
22  Vector<std::string> mtl_libraries_;
23  size_t read_buffer_size_;
24 
25  public:
29  OBJParser(const OBJImportParams &import_params, size_t read_buffer_size);
30  ~OBJParser();
31 
36  void parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries,
37  GlobalVertices &r_global_vertices);
42 
43  private:
44  void add_mtl_library(StringRef path);
45  void add_default_mtl_library();
46 };
47 
48 class MTLParser {
49  private:
50  char mtl_file_path_[FILE_MAX];
54  char mtl_dir_path_[FILE_MAX];
55 
56  public:
60  MTLParser(StringRefNull mtl_library_, StringRefNull obj_filepath);
61 
65  void parse_and_store(Map<std::string, std::unique_ptr<MTLMaterial>> &r_materials);
66 };
67 } // namespace blender::io::obj
File and directory operations.
#define FILE_MAX
void parse_and_store(Map< std::string, std::unique_ptr< MTLMaterial >> &r_materials)
MTLParser(StringRefNull mtl_library_, StringRefNull obj_filepath)
Span< std::string > mtl_libraries() const
void parse(Vector< std::unique_ptr< Geometry >> &r_all_geometries, GlobalVertices &r_global_vertices)
OBJParser(const OBJImportParams &import_params, size_t read_buffer_size)