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 (res.ec == std::errc::invalid_argument || res.ec == std::errc::result_out_of_range) {
103 start =
const_cast<char *
>(res.ptr);
109 for (
int i = 0; i < 3; i++) {
119 fprintf(stderr,
"STL Importer: cannot read from ASCII STL file: '%s'\n", filepath);
124 int num_reserved_tris = 1024;
127 STLMeshHelper stl_mesh(num_reserved_tris, use_custom_normals);
128 float triangle_buf[3][3];
129 float custom_normal_buf[3];
140 if (use_custom_normals) {
142 triangle_buf[0], triangle_buf[1], triangle_buf[2], custom_normal_buf);
145 stl_mesh.
add_triangle(triangle_buf[0], triangle_buf[1], triangle_buf[2]);
157 return stl_mesh.
to_mesh(bmain, mesh_name);
struct Mesh * BKE_mesh_add(struct Main *bmain, const char *name)
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)
Mesh * to_mesh(Main *bmain, char *mesh_name)
bool add_triangle(const float3 &a, const float3 &b, const float3 &c)
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)
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Mesh * read_stl_ascii(const char *filepath, Main *bmain, char *mesh_name, bool use_custom_normals)
static void parse_float3(StringBuffer &buf, float out[3])
static const pxr::TfToken out("out", pxr::TfToken::Immortal)