star-geometry-3d

Clean and decorate 3D geometries
git clone git://git.meso-star.fr/star-geometry-3d.git
Log | Files | Refs | README | LICENSE

commit c58035b877b13930a9e2cb8f46d9e06e1f202958
parent f11bf2c0090a48843acb2456da34c83c44f57c14
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue, 28 Nov 2023 15:05:46 +0100

Merge branch 'release_0.1.2'

Diffstat:
MREADME.md | 6+++++-
Mcmake/CMakeLists.txt | 2+-
Msrc/sg3d.h | 4++--
Msrc/sg3d_geometry.c | 26++++++++++++++++----------
Msrc/sg3d_geometry.h | 4++--
Msrc/test_sg3d_cube_behind_cube.c | 4++--
Msrc/test_sg3d_geometry.c | 2+-
Msrc/test_sg3d_geometry_2.c | 2+-
Msrc/test_sg3d_many_enclosures.c | 2+-
Msrc/test_sg3d_some_enclosures.c | 2+-
Msrc/test_sg3d_unspecified_properties.c | 2+-
11 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md @@ -23,6 +23,10 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.1.2 + +- Fix OBJ dump. + ### Version 0.1.1 - Fixed help headers failing to compile when included in C++ files. @@ -39,6 +43,6 @@ First version and implementation of the star-geometry-3d API. ## License Copyright © 2019, 2020, 2023 [|Méso|Star>](https://www.meso-star.com) -(<contact@meso-star.com>) It is free software released under the GPLv3+ +(<contact@meso-star.com>). It is free software released under the GPLv3+ license: GNU GPL version 3 or later. You are welcome to redistribute it under certain conditions; refer to the COPYING files for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -62,7 +62,7 @@ endif() ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 1) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(SG3D_FILES_SRC diff --git a/src/sg3d.h b/src/sg3d.h @@ -142,7 +142,7 @@ struct sg3d_geometry_add_callbacks { const unsigned merged_properties[SG3D_PROP_TYPES_COUNT__], void* context, int* merge_conflict_status); - /* Called if the itri_th triangle is degenerated. According to the value + /* Called if the itri_th triangle is degenerated. According to the value * of abort, sg3d_geometry_add will stop and return RES_BAD_ARG or continue * silently. */ res_T(*degenerated_triangle) /* Can be NULL <=> Drop triangle, don't abort */ @@ -215,7 +215,7 @@ sg3d_geometry_reserve * successive values for the same property across calls of sg3d_geometry_add, * not as the consistency of the values of the 3 properties of a triangle at * some given time (this question has its own callback (validate) in the - * sg3d_geometry_validate_properties API call). + * sg3d_geometry_validate_properties API call). * Duplicate triangles validity is either ruled by the user-provided * merge_triangle callback, or is just a matter of properties consistency if no * callback is provided. In either case, sg3d_geometry_add never stops diff --git a/src/sg3d_geometry.c b/src/sg3d_geometry.c @@ -871,15 +871,21 @@ sg3d_geometry_dump_as_obj /* Dump vertices */ vertices = darray_vertex_cdata_get(&geom->unique_vertices); FOR_EACH(i, 0, vsz) - fprintf(stream, "v %g %g %g\n", SPLIT3(vertices[i].coord)); + fprintf(stream, "v %.16g %.16g %.16g\n", SPLIT3(vertices[i].coord)); /* Dump triangles by groups */ - dump_partition(geom, stream, - "Valid_triangles", SG3D_OBJ_DUMP_VALID_PRIMITIVE); - dump_partition(geom, stream, - "Merge_conflicts", SG3D_OBJ_DUMP_MERGE_CONFLICTS); - dump_partition(geom, stream, - "Property_conflicts", SG3D_OBJ_DUMP_PROPERTY_CONFLICTS); + if(flags & SG3D_OBJ_DUMP_VALID_PRIMITIVE) { + dump_partition(geom, stream, + "Valid_triangles", SG3D_OBJ_DUMP_VALID_PRIMITIVE); + } + if(flags & SG3D_OBJ_DUMP_MERGE_CONFLICTS) { + dump_partition(geom, stream, + "Merge_conflicts", SG3D_OBJ_DUMP_MERGE_CONFLICTS); + } + if(flags & SG3D_OBJ_DUMP_PROPERTY_CONFLICTS) { + dump_partition(geom, stream, + "Property_conflicts", SG3D_OBJ_DUMP_PROPERTY_CONFLICTS); + } exit: return res; @@ -917,7 +923,7 @@ sg3d_geometry_dump_as_vtk fprintf(stream, "POINTS "PRTF_VRTX" double\n", (vrtx_id_t)vsz); vertices = darray_vertex_cdata_get(&geom->unique_vertices); FOR_EACH(i, 0, vsz) - fprintf(stream, "%g %g %g\n", SPLIT3(vertices[i].coord)); + fprintf(stream, "%.16g %.16g %.16g\n", SPLIT3(vertices[i].coord)); /* Dump triangles */ tsz = darray_triangle_size_get(&geom->unique_triangles); @@ -1061,9 +1067,9 @@ sg3d_geometry_dump_as_c_code qualifiers, name_prefix, (vrtx_id_t)(3 * vsz)); FOR_EACH(i, 0, vsz - 1) fprintf(stream, - " %g, %g, %g,\n", SPLIT3(vertices[i].coord)); + " %.16g, %.16g, %.16g,\n", SPLIT3(vertices[i].coord)); fprintf(stream, - " %g, %g, %g\n", SPLIT3(vertices[vsz - 1].coord)); + " %.16g, %.16g, %.16g\n", SPLIT3(vertices[vsz - 1].coord)); fprintf(stream, "};\n"); diff --git a/src/sg3d_geometry.h b/src/sg3d_geometry.h @@ -228,7 +228,7 @@ struct sg3d_geometry { /* Record which set defined what */ struct darray_trg_descriptions trg_descriptions; - + /* Counts */ unsigned set_id; trg_id_t triangle_count_including_duplicates; @@ -237,7 +237,7 @@ struct sg3d_geometry { trg_id_t trg_with_unspecified_intface_count; trg_id_t merge_conflict_count; trg_id_t properties_conflict_count; - + struct sg3d_device* dev; ref_T ref; }; diff --git a/src/test_sg3d_cube_behind_cube.c b/src/test_sg3d_cube_behind_cube.c @@ -22,7 +22,7 @@ /* cube_2 cube_3 - + +-----------------------+ | 3 | | @@ -90,7 +90,7 @@ main(int argc, char** argv) CHK(count == 0); OK(sg3d_geometry_dump_as_c_code(geom, stdout, "cube_behind_cube_2", SG3D_C_DUMP_CONST | SG3D_C_DUMP_STATIC)); - + d3(ctx.offset, -3, -3, 30); d3_splat(ctx.scale, 7); ctx.front_media = medium1; diff --git a/src/test_sg3d_geometry.c b/src/test_sg3d_geometry.c @@ -78,7 +78,7 @@ main(int argc, char** argv) unsigned count, i; struct context ctx = CONTEXT_NULL__; (void)argc, (void)argv; - + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); OK(sg3d_device_create(NULL, &allocator, 1, &dev)); diff --git a/src/test_sg3d_geometry_2.c b/src/test_sg3d_geometry_2.c @@ -100,7 +100,7 @@ main(int argc, char** argv) const unsigned property_count = sizeof(property) / sizeof(*property); unsigned count; (void)argc, (void)argv; - + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); OK(sg3d_device_create(NULL, &allocator, 1, &dev)); OK(sg3d_geometry_create(dev, &geom)); diff --git a/src/test_sg3d_many_enclosures.c b/src/test_sg3d_many_enclosures.c @@ -95,7 +95,7 @@ main(int argc, char** argv) OK(sg3d_geometry_get_unique_triangles_with_unspecified_side_count(geom, &count)); CHK(count == 0); OK(sg3d_geometry_dump_as_obj(geom, stdout, SG3D_OBJ_DUMP_ALL)); - + SG3D(geometry_ref_put(geom)); check_memory_allocator(&allocator); diff --git a/src/test_sg3d_some_enclosures.c b/src/test_sg3d_some_enclosures.c @@ -96,7 +96,7 @@ main(int argc, char** argv) CHK(count == 0); OK(sg3d_geometry_dump_as_c_code(geom, stdout, "some_enclosures", SG3D_C_DUMP_CONST | SG3D_C_DUMP_STATIC)); - + SG3D(geometry_ref_put(geom)); check_memory_allocator(&allocator); diff --git a/src/test_sg3d_unspecified_properties.c b/src/test_sg3d_unspecified_properties.c @@ -31,7 +31,7 @@ main(int argc, char** argv) const unsigned property_count = sizeof(property) / sizeof(*property); unsigned count; (void)argc, (void)argv; - + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); OK(sg3d_device_create(NULL, &allocator, 1, &dev)); OK(sg3d_geometry_create(dev, &geom));