10#include <system_error>
24#include "fast_float.h"
51 while ((start < end) && (*start) <=
' ') {
58 while ((start < end) && (*start) >
' ') {
65 while (start < end && *start !=
'\n') {
73 if (end - start < token_length + 1) {
76 if (memcmp(start, token, token_length) != 0) {
79 if (start[token_length] >
' ') {
82 start += token_length + 1;
96 if (start < end && *start ==
'+') {
99 fast_float::from_chars_result res = fast_float::from_chars(start, end, out);
100 if (
ELEM(res.ec, std::errc::invalid_argument, std::errc::result_out_of_range)) {
103 start =
const_cast<char *
>(res.ptr);
109 for (
int i = 0; i < 3; i++) {
118 if (buffer ==
nullptr) {
119 fprintf(stderr,
"STL Importer: cannot read from ASCII STL file: '%s'\n", filepath);
124 constexpr int num_reserved_tris = 1024;
126 StringBuffer str_buf(
static_cast<char *
>(buffer), buffer_len);
127 STLMeshHelper stl_mesh(num_reserved_tris, use_custom_normals);
void * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
File and directory operations.
#define BLI_SCOPED_DEFER(function_to_defer)
bool add_triangle(const PackedTriangle &data)
bool parse_token(const char *token, size_t token_length)
void parse_float(float &out)
void drop_leading_control_chars()
void drop_leading_non_control_chars()
StringBuffer(char *buf, size_t len)
void MEM_freeN(void *vmemh)
static void parse_float3(StringBuffer &buf, float3 &out)
Mesh * read_stl_ascii(const char *filepath, const bool use_custom_normals)