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 150780eba2a08c240e005a8f27dfd0d9ad00d3db
parent cbea6cf92a5ee9fd1ee9d7a8a8d8ea1e41510e95
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 30 Jan 2020 16:47:16 +0100

Swap param order in an API call because of coherency

Diffstat:
Msrc/sg3.h | 2+-
Msrc/sg3_geometry.c | 2+-
Msrc/test_sg3_cube_behind_cube.c | 6+++---
Msrc/test_sg3_cube_in_cube.c | 6+++---
Msrc/test_sg3_cube_on_cube.c | 6+++---
Msrc/test_sg3_geometry.c | 16++++++++--------
Msrc/test_sg3_geometry_2.c | 30+++++++++++++++---------------
Msrc/test_sg3_many_enclosures.c | 2+-
Msrc/test_sg3_many_triangles.c | 2+-
Msrc/test_sg3_some_enclosures.c | 2+-
Msrc/test_sg3_some_triangles.c | 2+-
Msrc/test_sg3_unspecified_properties.c | 12++++++------
12 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/src/sg3.h b/src/sg3.h @@ -228,8 +228,8 @@ sg3_geometry_reserve SG3_API res_T sg3_geometry_add (struct sg3_geometry* geometry, - const unsigned triangles_count, const unsigned vertices_count, + const unsigned triangles_count, const struct sg3_geometry_add_callbacks* callbacks, void* context); /* Can be NULL */ diff --git a/src/sg3_geometry.c b/src/sg3_geometry.c @@ -356,8 +356,8 @@ error: res_T sg3_geometry_add (struct sg3_geometry* geom, - const unsigned ntris, const unsigned nverts, + const unsigned ntris, const struct sg3_geometry_add_callbacks* callbacks, void* ctx) /* Can be NULL */ { diff --git a/src/test_sg3_cube_behind_cube.c b/src/test_sg3_cube_behind_cube.c @@ -74,13 +74,13 @@ main(int argc, char** argv) ctx.intface = intface0; /* First cube (front: 0, back: 1), right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); d3(ctx.offset, -2, -2, 20); ctx.scale = 5; /* Second cube (front: 0, back: 1), right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); @@ -97,7 +97,7 @@ main(int argc, char** argv) ctx.back_media = medium0; /* Third cube (front: 1, back: 0), right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); diff --git a/src/test_sg3_cube_in_cube.c b/src/test_sg3_cube_in_cube.c @@ -64,14 +64,14 @@ main(int argc, char** argv) ctx.intface = intface0; /* First cube (front: 0, back: 1), right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); d3(ctx.offset, -1, -1, -1); ctx.scale = 3; ctx.reverse_vrtx = 1; /* Second cube (front: 0, back: 1), right-handed normal inside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); @@ -90,7 +90,7 @@ main(int argc, char** argv) ctx.back_media = medium0; /* Third cube (front: 0, back: 1), right-handed normal inside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); diff --git a/src/test_sg3_cube_on_cube.c b/src/test_sg3_cube_on_cube.c @@ -63,14 +63,14 @@ main(int argc, char** argv) /* First cube (front: 0 on top face, 1 elsewhere, back: 0), * right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); d3(ctx.offset, 1, 1, 1); ctx.front_media = medium1_back0; /* Second cube (front: 0 on bottom face, 1 elsewhere, back: 0), * right-handed normal outside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); ctx.positions = box_vertices; /* Can use distorded cube for cube #3 */ d3(ctx.offset, 0, 0, 0); @@ -81,7 +81,7 @@ main(int argc, char** argv) ctx.back_media = medium1; /* Third cube (front: 2, back: 1), right-handed normal inside */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); diff --git a/src/test_sg3_geometry.c b/src/test_sg3_geometry.c @@ -161,7 +161,7 @@ main(int argc, char** argv) BA(sg3_geometry_add(NULL, 0, 0, &callbacks, NULL)); OK(sg3_geometry_get_added_primitives_count(geom, &count)); CHK(count == 0); - BA(sg3_geometry_add(geom, ntriangles, nvertices, NULL, NULL)); + BA(sg3_geometry_add(geom, nvertices, ntriangles, NULL, NULL)); OK(sg3_geometry_get_added_primitives_count(geom, &count)); CHK(count == ntriangles); /* Mandatory callbacks are NULL */ @@ -194,7 +194,7 @@ main(int argc, char** argv) callbacks.get_properties = get_properties; callbacks.get_position = get_position; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_dump_as_obj(geom, stdout, SG3_OBJ_DUMP_ALL)); OK(sg3_geometry_dump_as_vtk(geom, stdout)); OK(sg3_geometry_dump_as_c_code(geom, stdout, NULL, 0)); @@ -246,7 +246,7 @@ main(int argc, char** argv) /* Conflicts with merge_trg callback */ callbacks.merge_triangle = merge_trg; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); /* Due to merge_trg internals, all but the first triangle have conflict */ CHK(count == ntriangles - 1); @@ -259,9 +259,9 @@ main(int argc, char** argv) /* Conflicts without merge_trg callback */ OK(sg3_geometry_create(dev, &geom)); callbacks.merge_triangle = NULL; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); ctx.front_media = medium1_front0; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); FOR_EACH(i, 0, ntriangles) if(medium0[i] != medium1_front0[i]) count--; CHK(count == 0); @@ -273,15 +273,15 @@ main(int argc, char** argv) /* Degenerated triangles */ ctx.indices = degenerated; /* Without callback : OK */ - OK(sg3_geometry_add(geom, 1, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, 1, &callbacks, &ctx)); /* With callback : OK */ callbacks.degenerated_triangle = degenerated_triangle; ctx.custom = &i; i = 0; - OK(sg3_geometry_add(geom, 1, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, 1, &callbacks, &ctx)); /* With callback : KO */ i= 1; - BA(sg3_geometry_add(geom, 1, nvertices, &callbacks, &ctx)); + BA(sg3_geometry_add(geom, nvertices, 1, &callbacks, &ctx)); OK(sg3_geometry_ref_put(geom)); OK(sg3_device_ref_put(dev)); diff --git a/src/test_sg3_geometry_2.c b/src/test_sg3_geometry_2.c @@ -130,7 +130,7 @@ main(int argc, char** argv) /* If add fails, add geometry fails the same way */ add_geom_ctx.add_res = RES_BAD_ARG; - BA(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + BA(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); CHK(count == nvertices); @@ -139,7 +139,7 @@ main(int argc, char** argv) OK(sg3_geometry_get_unique_primitives_count(geom, &count)); CHK(count == 0); add_geom_ctx.add_res = RES_MEM_ERR; - ME(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + ME(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == 0); CHK(count == 0); OK(sg3_geometry_get_added_primitives_count(geom, &count)); @@ -157,7 +157,7 @@ main(int argc, char** argv) /* Successful add geometry with add callback */ add_geom_ctx.add_res = RES_OK; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -185,7 +185,7 @@ main(int argc, char** argv) /* Successful add geometry without add callback */ add_geom_ctx.add_cpt = 0; callbacks.add_triangle = NULL; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == 0); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -206,12 +206,12 @@ main(int argc, char** argv) /* If merge fails, add geometry fails the same way */ add_geom_ctx.merge_res = RES_BAD_ARG; callbacks.add_triangle = add_trg; - BA(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + BA(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_added_primitives_count(geom, &count)); CHK(count == 2 * ntriangles); add_geom_ctx.merge_res = RES_MEM_ERR; - ME(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + ME(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_added_primitives_count(geom, &count)); CHK(count == 3 * ntriangles); @@ -230,7 +230,7 @@ main(int argc, char** argv) /* Successful add geometry without merge callback */ callbacks.merge_triangle = NULL; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); CHK(count == nvertices); @@ -250,7 +250,7 @@ main(int argc, char** argv) /* Successful add geometry with merge callback */ add_geom_ctx.merge_res = RES_OK; callbacks.merge_triangle = merge_trg; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -279,10 +279,10 @@ main(int argc, char** argv) /* Successful add geometry with add callback * First half of the triangles, then all of them */ add_geom_ctx.add_res = RES_OK; - OK(sg3_geometry_add(geom, ntriangles / 2, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles / 2, &callbacks, &ctx)); OK(sg3_geometry_get_added_primitives_count(geom, &count)); CHK(count == ntriangles / 2); - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == ntriangles / 2); add_geom_ctx.add_cpt = 0; @@ -316,7 +316,7 @@ main(int argc, char** argv) /* Successful add geometry with add callback and no defined properties */ add_geom_ctx.add_res = RES_OK; callbacks.get_properties = NULL; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == 0); add_geom_ctx.add_cpt = 0; @@ -341,7 +341,7 @@ main(int argc, char** argv) /* Successful add geometry with merge callback and properties */ add_geom_ctx.merge_res = RES_OK; callbacks.get_properties = get_properties; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -365,7 +365,7 @@ main(int argc, char** argv) /* Add geometry without merge callback and conflicts */ callbacks.merge_triangle = NULL; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); CHK(count == nvertices); @@ -388,7 +388,7 @@ main(int argc, char** argv) /* Successful add geometry with merge callback */ add_geom_ctx.merge_res = RES_OK; callbacks.merge_triangle = merge_trg; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -411,7 +411,7 @@ main(int argc, char** argv) OK(sg3_geometry_create(dev, &geom)); /* Successful add geometry with merge callback */ - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == 0); diff --git a/src/test_sg3_many_enclosures.c b/src/test_sg3_many_enclosures.c @@ -82,7 +82,7 @@ main(int argc, char** argv) misalignment = (k % 2) ? -0.01 : +0.01; #endif d3(ctx.ctx.offset, center_x + misalignment, center_y + misalignment, 0); - OK(sg3_geometry_add(geom, cyl_trg_count, cyl_vrtx_count, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, cyl_vrtx_count, cyl_trg_count, &callbacks, &ctx)); } } } diff --git a/src/test_sg3_many_triangles.c b/src/test_sg3_many_triangles.c @@ -65,7 +65,7 @@ main(int argc, char** argv) FOR_EACH(i, 0, NB_CYL) { m1 = i; d3(ctx.ctx.offset, 0, 0, i * 10); - OK(sg3_geometry_add(geom, cyl_trg_count, cyl_vrtx_count, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, cyl_vrtx_count, cyl_trg_count, &callbacks, &ctx)); } S3DUT(mesh_ref_put(cyl)); diff --git a/src/test_sg3_some_enclosures.c b/src/test_sg3_some_enclosures.c @@ -82,7 +82,7 @@ main(int argc, char** argv) misalignment = (k % 2) ? -0.01 : +0.01; #endif d3(ctx.ctx.offset, center_x + misalignment, center_y + misalignment, 0); - OK(sg3_geometry_add(geom, cyl_trg_count, cyl_vrtx_count, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, cyl_vrtx_count, cyl_trg_count, &callbacks, &ctx)); } } } diff --git a/src/test_sg3_some_triangles.c b/src/test_sg3_some_triangles.c @@ -65,7 +65,7 @@ main(int argc, char** argv) FOR_EACH(i, 0, NB_CYL) { m1 = i; d3(ctx.ctx.offset, 0, 0, i * 10); - OK(sg3_geometry_add(geom, cyl_trg_count, cyl_vrtx_count, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, cyl_vrtx_count, cyl_trg_count, &callbacks, &ctx)); } S3DUT(mesh_ref_put(cyl)); diff --git a/src/test_sg3_unspecified_properties.c b/src/test_sg3_unspecified_properties.c @@ -51,7 +51,7 @@ main(int argc, char** argv) ctx.front_media = property; ctx.back_media = medium1; ctx.intface = property; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_unspecified_side_count(geom, &count)); CHK(count == ntriangles); OK(sg3_geometry_get_added_primitives_count(geom, &count)); @@ -59,7 +59,7 @@ main(int argc, char** argv) /* Add same geometry with no properties on front/intface */ callbacks.get_properties = get_properties; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_unspecified_side_count(geom, &count)); CHK(count == ntriangles); OK(sg3_geometry_get_added_primitives_count(geom, &count)); @@ -71,7 +71,7 @@ main(int argc, char** argv) /* Add same geometry, front/intface properties are defined for odd triangles */ FOR_EACH(i, 0, sizeof(property) / sizeof(*property)) property[i] = (i % 2) ? 0 : SG3_UNSPECIFIED_PROPERTY; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_unspecified_side_count(geom, &count)); CHK(count == ntriangles / 2); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -91,7 +91,7 @@ main(int argc, char** argv) /* Same information again, using a reversed box */ ctx.reverse_vrtx = 1; SWAP(const unsigned*, ctx.front_media, ctx.back_media); - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_unspecified_side_count(geom, &count)); CHK(count == ntriangles / 2); OK(sg3_geometry_get_added_primitives_count(geom, &count)); @@ -103,7 +103,7 @@ main(int argc, char** argv) /* Define properties for remaining triangles, using reversed box */ FOR_EACH(i, 0, sizeof(property) / sizeof(*property)) property[i] = (i % 2) ? SG3_UNSPECIFIED_PROPERTY : 0; - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_unspecified_side_count(geom, &count)); CHK(count == 0); OK(sg3_geometry_get_unique_vertices_count(geom, &count)); @@ -125,7 +125,7 @@ main(int argc, char** argv) /* Define incoherent properties for some triangles */ FOR_EACH(i, 0, sizeof(property) / sizeof(*property)) property[i] = (i % 2); - OK(sg3_geometry_add(geom, ntriangles, nvertices, &callbacks, &ctx)); + OK(sg3_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx)); OK(sg3_geometry_get_unique_primitives_with_merge_conflict_count(geom, &count)); CHK(count == ntriangles / 2); OK(sg3_geometry_get_unique_primitives_with_properties_conflict_count(geom, &count));