star-stl

Load STereo Lithography (StL) file format
git clone git://git.meso-star.fr/star-stl.git
Log | Files | Refs | README | LICENSE

commit f943527737b2d3ce01ac3634ce7a6e6c95274300
parent f5bfb34a0a41b0297f7cb9d8872312376f6dc203
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 18 Apr 2025 12:48:24 +0200

Rename the sstl_read_type enum to sstl_type

This anticipates the future writer API, where the type of data written
would be defined by a symbolic constant of this type, and where the
prefix 'read' would therefore make no sense.

Diffstat:
Msrc/sstl.c | 8++++----
Msrc/sstl.h | 6+++---
Msrc/sstl_ascii.c | 2+-
Msrc/sstl_binary.c | 2+-
Msrc/sstl_c.h | 4++--
Msrc/sstl_main.c | 16++++++++--------
Msrc/test_sstl_load_ascii.c | 14+++++++-------
Msrc/test_sstl_load_binary.c | 14+++++++-------
8 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/sstl.c b/src/sstl.c @@ -46,7 +46,7 @@ file_type (struct sstl* sstl, FILE* fp, const char* name, - enum sstl_read_type* type) + enum sstl_type* type) { char buf[1024]; size_t sz = 0; @@ -99,7 +99,7 @@ load_stream (struct sstl* sstl, FILE* fp, const char* name, - enum sstl_read_type type) + enum sstl_type type) { res_T res = RES_OK; ASSERT((unsigned)type <= SSTL_NONE__); @@ -131,7 +131,7 @@ error: } static res_T -load(struct sstl* sstl, const char* filename, const enum sstl_read_type type) +load(struct sstl* sstl, const char* filename, const enum sstl_type type) { FILE* stream = NULL; res_T res = RES_OK; @@ -329,6 +329,6 @@ sstl_get_desc(struct sstl* sstl, struct sstl_desc* desc) desc->vertices = sstl->vertices; desc->indices = sstl->indices; desc->normals = sstl->normals; - desc->read_type = sstl->read_type; + desc->type = sstl->type; return RES_OK; } diff --git a/src/sstl.h b/src/sstl.h @@ -37,7 +37,7 @@ #endif /* The type of a read file */ -enum sstl_read_type { +enum sstl_type { SSTL_ASCII, SSTL_BINARY, SSTL_NONE__ @@ -47,7 +47,7 @@ enum sstl_read_type { struct sstl_desc { const char* filename; const char* solid_name; /* May be NULL <=> no name */ - enum sstl_read_type read_type; /* The type of the file */ + enum sstl_type type; /* The type of the file */ /* Front faces are CCW ordered and the normals follow the right handed rule */ const float* vertices; /* triangles_count * 3 coordinates */ @@ -74,7 +74,7 @@ BEGIN_DECLS SSTL_API res_T sstl_create - (struct logger* logger, /* NULL <=> use default logger*/ + (struct logger* logger, /* NULL <=> use default logger */ struct mem_allocator* allocator, /* NULL <=> use default allocator */ const int verbose, /* Verbosity level */ struct sstl** sstl); diff --git a/src/sstl_ascii.c b/src/sstl_ascii.c @@ -286,7 +286,7 @@ load_stream_ascii if((res = parse_solid(sstl, txtrdr)) != RES_OK) goto error; } - sstl->read_type = SSTL_ASCII; + sstl->type = SSTL_ASCII; exit: htable_vertex_purge(&sstl->vertex2id); /* Purge the helper structure */ diff --git a/src/sstl_binary.c b/src/sstl_binary.c @@ -135,7 +135,7 @@ load_stream_binary(struct sstl* sstl, FILE* fp, const char* name) if((res = parse_triangle(sstl, fp, name, i)) != RES_OK) goto error; } - sstl->read_type = SSTL_BINARY; + sstl->type = SSTL_BINARY; exit: htable_vertex_purge(&sstl->vertex2id); /* Purge the helper structure */ diff --git a/src/sstl_c.h b/src/sstl_c.h @@ -59,7 +59,7 @@ struct mem_allocator; struct sstl { struct str filename; struct str name; - enum sstl_read_type read_type; + enum sstl_type type; /* Temporary structure used to map a vertex to its id */ struct htable_vertex vertex2id; @@ -85,7 +85,7 @@ clear(struct sstl* sstl) sstl->indices = NULL; sstl->vertices = NULL; sstl->normals = NULL; - sstl->read_type = SSTL_NONE__; + sstl->type = SSTL_NONE__; htable_vertex_clear(&sstl->vertex2id); } diff --git a/src/sstl_main.c b/src/sstl_main.c @@ -26,7 +26,7 @@ struct args { char* const* meshes; unsigned nmeshes; - enum sstl_read_type read_type; /* Type of input meshes */ + enum sstl_type type; /* Type of input meshes */ int verbose; /* Verbosity level */ int quit; }; @@ -57,8 +57,8 @@ args_init(struct args* args, int argc, char** argv) while((opt = getopt(argc, argv, "abhv")) != -1) { switch(opt) { - case 'a': args->read_type = SSTL_ASCII; break; - case 'b': args->read_type = SSTL_BINARY; break; + case 'a': args->type = SSTL_ASCII; break; + case 'b': args->type = SSTL_BINARY; break; case 'h': usage(stdout); args->quit = 1; @@ -73,7 +73,7 @@ args_init(struct args* args, int argc, char** argv) args->meshes = argv + optind; args->nmeshes = (unsigned)(argc - optind); - if(!args->nmeshes && args->read_type == SSTL_NONE__) { + if(!args->nmeshes && args->type == SSTL_NONE__) { fprintf(stderr, "StL type must be defined for reading on stdin " "-- options '-a' or -b'\n"); @@ -113,7 +113,7 @@ error: } static INLINE const char* -read_type_to_cstr(const enum sstl_read_type type) +type_to_cstr(const enum sstl_type type) { const char* cstr = NULL; switch(type) { @@ -132,7 +132,7 @@ print_info(const struct cmd* cmd) SSTL(get_desc(cmd->sstl, &desc)); printf("%s\t%s\t%lu\t%lu\t%s\n", - read_type_to_cstr(desc.read_type), + type_to_cstr(desc.type), desc.solid_name ? desc.solid_name : "null", (unsigned long)desc.triangles_count, (unsigned long)desc.vertices_count, @@ -147,7 +147,7 @@ cmd_run(const struct cmd* cmd) /* Read from the standard input */ if(!cmd->args.nmeshes) { - switch(cmd->args.read_type) { + switch(cmd->args.type) { case SSTL_ASCII: res = sstl_load_stream_ascii(cmd->sstl, stdin, "stdin (ASCII)"); break; @@ -163,7 +163,7 @@ cmd_run(const struct cmd* cmd) } else { unsigned i; FOR_EACH(i, 0, cmd->args.nmeshes) { - switch(cmd->args.read_type) { + switch(cmd->args.type) { case SSTL_ASCII: res = sstl_load_ascii(cmd->sstl, cmd->args.meshes[i]); break; diff --git a/src/test_sstl_load_ascii.c b/src/test_sstl_load_ascii.c @@ -39,7 +39,7 @@ check_api(struct sstl* sstl) #define CHECK_EMPTY_FILE { \ CHK(sstl_get_desc(sstl, &desc) == RES_OK); \ CHK(!strcmp(desc.filename, filename)); \ - CHK(desc.read_type == SSTL_ASCII); \ + CHK(desc.type == SSTL_ASCII); \ CHK(desc.solid_name == NULL); \ CHK(desc.vertices_count == 0); \ CHK(desc.triangles_count == 0); \ @@ -95,7 +95,7 @@ check_no_triangle(struct sstl* sstl) CHK(sstl_load_stream(sstl, fp, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(!strcmp(desc.filename, filename)); CHK(!strcmp(desc.solid_name, "my_solid")); CHK(desc.vertices_count == 0); @@ -131,7 +131,7 @@ check_1_triangle(struct sstl* sstl) CHK(sstl_load_ascii(sstl, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 3); @@ -173,7 +173,7 @@ check_1_triangle_with_noise(struct sstl* sstl) CHK(sstl_load(sstl, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(!strcmp(desc.filename, filename)); CHK(!strcmp(desc.solid_name, "My Solid")); CHK(desc.vertices_count == 3); @@ -212,7 +212,7 @@ check_1_triangle_no_normal(struct sstl* sstl) CHK(sstl_load_stream(sstl, fp, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 3); @@ -378,7 +378,7 @@ check_tetrahedron(struct sstl* sstl) CHK(sstl_get_desc(sstl, &desc) == RES_OK); CHK(!strcmp(desc.filename, filename)); CHK(!strcmp(desc.solid_name, "cube corner")); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(desc.vertices_count == 4); CHK(desc.triangles_count == 4); @@ -440,7 +440,7 @@ check_no_seekable_file(struct sstl* sstl) CHK(fclose(fp) == 0); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_ASCII); + CHK(desc.type == SSTL_ASCII); CHK(!strcmp(desc.filename, filename)); CHK(!strcmp(desc.solid_name, "Triangle")); CHK(desc.vertices_count == 3); diff --git a/src/test_sstl_load_binary.c b/src/test_sstl_load_binary.c @@ -57,7 +57,7 @@ check_api(struct sstl* sstl) CHK(sstl_load_binary(sstl, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 0); @@ -65,7 +65,7 @@ check_api(struct sstl* sstl) CHK(sstl_load_stream_binary(sstl, fp, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 0); @@ -104,7 +104,7 @@ check_1_triangle(struct sstl* sstl) CHK(sstl_load(sstl, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 3); @@ -146,7 +146,7 @@ check_1_triangle_no_normal(struct sstl* sstl) CHK(sstl_load_stream(sstl, fp, filename) == RES_OK); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, filename)); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 3); @@ -194,7 +194,7 @@ check_invalid_file(struct sstl* sstl) CHK(fclose(fp) == 0); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, "Valid StL")); CHK(desc.vertices_count == 3); CHK(desc.triangles_count == 1); @@ -306,7 +306,7 @@ check_tetrahedron(struct sstl* sstl) CHK(fclose(fp) == 0); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, "Tetrahedron")); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 4); @@ -372,7 +372,7 @@ check_no_seekable_file(struct sstl* sstl) CHK(fclose(fp) == 0); CHK(sstl_get_desc(sstl, &desc) == RES_OK); - CHK(desc.read_type == SSTL_BINARY); + CHK(desc.type == SSTL_BINARY); CHK(!strcmp(desc.filename, "Piped StL")); CHK(desc.solid_name == NULL); CHK(desc.vertices_count == 3);