1
0

feature: stages

stages: separate scanning and parsing, allowing `v`, `vn`, `vt` lines to
be mapped to line numbers and store line data (once).

first stage parsing: parse face data and validate vertices.

TODO:
* improve validation (detect partial normals/texcoords);
* maybe improve storage of triangle line number instead of storing line
  number for each vertex;
This commit is contained in:
2025-10-19 13:45:55 +03:00
parent aadd9d8661
commit adeeae3aff
11 changed files with 776 additions and 294 deletions

33
src/scan.hpp Normal file
View File

@@ -0,0 +1,33 @@
#ifndef __WAVEFRONT_FILE_HPP__
#define __WAVEFRONT_FILE_HPP__
#include <cstdint>
#include <map>
#include <string>
#include <stdexcept>
#include <vector>
#include "settings.hpp"
namespace wavefront {
class scan_error : public std::runtime_error {
public:
explicit scan_error(const std::string &message);
};
struct scan_result {
std::size_t total_lines;
std::map<std::size_t, std::string> line_data;
std::map<std::string, std::vector<std::size_t>> category_map;
scan_result();
};
scan_result scan(
std::istream &input,
const std::vector<std::string> &selected_objects = {},
const std::vector<std::string> &selected_groups = {}
);
}
#endif // __WAVEFRONT_PARSER_FILE_HPP__