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 d4335701e93d77c2b08b7df801b19ab91655d33b
parent 6cc8507774de52ddb32fc37829829ff5d078d56a
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Fri,  6 Dec 2019 15:54:25 +0100

Improve tests and fix bugs

Diffstat:
Msrc/sg3_geometry.c | 47++++++++++++++++++++++++++++++++++++-----------
Msrc/sg3_report.c | 30++++++++++++------------------
Msrc/sg3_report.h | 24++++++++++++++++++++++--
Msrc/star-geometry.h | 54+++++++++++++++++++++++++++++++++---------------------
Msrc/test_sg3_report.c | 35++++++++++++++++++++++++++---------
Msrc/test_sg3_report_2.c | 54++++++++++++++++++++++++++----------------------------
Msrc/test_sg3_utils.h | 19++++++-------------
7 files changed, 161 insertions(+), 102 deletions(-)

diff --git a/src/sg3_geometry.c b/src/sg3_geometry.c @@ -180,8 +180,7 @@ sg3_geometry_add (struct sg3_geometry* geom, const unsigned ntris, void(*indices)(const unsigned, unsigned*, void*), - void(*media)(const unsigned, unsigned*, void*), /* Can be NULL */ - void(*intface)(const unsigned, unsigned*, void*), /* Can be NULL */ + void(*properties)(const unsigned, unsigned*, void*), /* Can be NULL */ const unsigned nverts, void(*position)(const unsigned, double*, void*), res_T(*add_trg)(const unsigned, const unsigned, void*), /* Can be NULL */ @@ -250,11 +249,12 @@ sg3_geometry_add trg = darray_triangle_data_get(&geom->v_n_t->unique_triangles); FOR_EACH(i, 0, ntris) { int j, reversed; - int merge_conflict = 0; struct unsigned3 trg_key; struct triangle tmp = TRG_UNDEF__; unsigned* p_trg; unsigned unique_id; + struct trg_descriptions trgd; + struct trg_descriptions* p_trgd; /* Triangle index in user world regardless of deduplication. */ tmp.global_id = (geom->triangle_count_including_duplicates + i); @@ -278,9 +278,7 @@ sg3_geometry_add goto error; } /* Get media and interface */ - ASSERT(SG3_FRONT + 1 == SG3_BACK); - if(media) media(i, tmp.properties + SG3_FRONT, ctx); - if(intface) intface(i, tmp.properties + SG3_INTFACE, ctx); + if(properties) properties(i, tmp.properties + SG3_FRONT, ctx); /* Find duplicate triangles */ reversed = trg_make_key(&trg_key, tmp.vertex_ids); p_trg = htable_trg_find(&geom->unique_triangles_ids, &trg_key); @@ -293,23 +291,39 @@ sg3_geometry_add unsigned* uprop; ASSERT(trg_key_eq(&trg_key, &utrg_key)); unique_id = *p_trg; + /* Use report or tmp storage for merge_conflict status */ + if(geom->report) { + struct trg_descriptions* trg_descriptions; + ERR(report_enlarge_trg_descriptions(geom->report, 1 + unique_id)); + trg_descriptions + = darray_trg_descriptions_data_get(&geom->report->trg_descriptions); + p_trgd = trg_descriptions + i; + } + else p_trgd = &trgd; if(!same) SWAP(unsigned, tmp.properties[SG3_FRONT], tmp.properties[SG3_BACK]); uprop = trg[*p_trg].properties; if(merge_trg) { /* Let the client app rule. */ ERR(merge_trg(trg[*p_trg].global_id, i, same, uprop, tmp.properties, - ctx, &merge_conflict)); - /* If merge_triangle returns OK its OK even if media are incompatible */ + ctx, &p_trgd->merge_conflict)); + /* If merge_triangle returns OK add_geometry will continue regardless + * of conflicts */ } else { FOR_EACH(j, 0, SG3_PROP_TYPES_COUNT__) { if(!compatible_property(j, uprop[j], tmp.properties[j])) { res = RES_BAD_ARG; - merge_conflict = 1; - goto error; + p_trgd->merge_conflict = 1; + break; } } } + if(geom->report && p_trgd->merge_conflict) { + geom->report->merge_conflict_count++; + /* If merge_trg and we reached this line, merge_trg ruled no error */ + if(!merge_trg) goto error; + } + if(res != RES_OK) goto error; /* Legit duplicate (or accepted by merge_triangle): replace undef media */ upd_ptr = darray_triangle_data_get(&geom->v_n_t->unique_triangles) + *p_trg; @@ -328,6 +342,14 @@ sg3_geometry_add unique_id = (unsigned)(nutris + actual_nutris); if(add_trg) ERR(add_trg(tmp.global_id, i, ctx)); + /* Use report or tmp storage for merge_conflict status */ + if(geom->report) { + struct trg_descriptions* trg_descriptions; + ERR(report_enlarge_trg_descriptions(geom->report, 1 + unique_id)); + trg_descriptions + = darray_trg_descriptions_data_get(&geom->report->trg_descriptions); + p_trgd = trg_descriptions + i; + } else p_trgd = &trgd; ERR(darray_triangle_push_back(&geom->v_n_t->unique_triangles, &tmp)); FOR_EACH(j, 0, SG3_PROP_TYPES_COUNT__) { if((j == SG3_FRONT || j == SG3_BACK) @@ -342,7 +364,10 @@ sg3_geometry_add /* Register triangle in report */ if(geom->report) { ERR(report_record_triangle(geom->report, &tmp, unique_id, geom->set_id, - merge_conflict)); + p_trgd->properties_conflict)); + if(p_trgd->properties_conflict) { + geom->report->merge_conflict_count++; + } } } diff --git a/src/sg3_report.c b/src/sg3_report.c @@ -56,13 +56,7 @@ report_record_triangle ASSERT(report && triangle); sz = darray_trg_descriptions_size_get(&report->trg_descriptions); - if(triangle_unique_id >= sz) { - ERR(darray_trg_descriptions_resize(&report->trg_descriptions, - 1 + triangle_unique_id)); - ASSERT(1 + triangle_unique_id - sz < UINT_MAX); - report->undef_side_count += (unsigned)(1 + triangle_unique_id - sz); - report->undef_intface_count += (unsigned)(1 + triangle_unique_id - sz); - } + ERR(report_enlarge_trg_descriptions(report, triangle_unique_id + 1)); trg_d = (darray_trg_descriptions_data_get(&report->trg_descriptions) + triangle_unique_id); /* Record information */ @@ -118,14 +112,14 @@ report_record_triangle && trg_d->property_defined[SG3_FRONT] && trg_d->property_defined[SG3_BACK]) { /* Both sides are now defined */ - ASSERT(report->undef_side_count > 0); - report->undef_side_count--; + ASSERT(report->trg_with_undef_sides_count > 0); + report->trg_with_undef_sides_count--; } if(!keep_prop_def[SG3_INTFACE] && trg_d->property_defined[SG3_INTFACE]) { /* Interface is now defined */ - ASSERT(report->undef_intface_count > 0); - report->undef_intface_count--; + ASSERT(report->trg_with_undef_intface_count > 0); + report->trg_with_undef_intface_count--; } exit: @@ -197,8 +191,8 @@ sg3_report_create goto error; } report->dev = dev; - report->undef_side_count = 0; - report->undef_intface_count = 0; + report->trg_with_undef_sides_count = 0; + report->trg_with_undef_intface_count = 0; report->merge_conflict_count = 0; report->properties_conflict_count = 0; report->associated = 0; @@ -328,7 +322,7 @@ sg3_report_get_triangle_with_undefined_side_count res = RES_BAD_ARG; goto error; } - *count = report->undef_side_count; + *count = report->trg_with_undef_sides_count; exit: return res; error: @@ -349,7 +343,7 @@ sg3_report_get_triangle_with_undefined_interface_count res = RES_BAD_ARG; goto error; } - *count = report->undef_intface_count; + *count = report->trg_with_undef_intface_count; exit: return res; error: @@ -449,9 +443,9 @@ error: res_T sg3_report_dump_as_C_code -(const struct sg3_report* report, - FILE* stream, - const char* name_prefix) + (const struct sg3_report* report, + FILE* stream, + const char* name_prefix) { res_T res = RES_OK; const struct vertex* vertices; diff --git a/src/sg3_report.h b/src/sg3_report.h @@ -222,8 +222,8 @@ struct sg3_report { /* Record unique (i.e. deduplicated) vertices and triangles */ struct v_n_t* v_n_t; /* Counts */ - unsigned undef_side_count; - unsigned undef_intface_count; + unsigned trg_with_undef_sides_count; + unsigned trg_with_undef_intface_count; unsigned merge_conflict_count; unsigned properties_conflict_count; int associated; @@ -232,6 +232,26 @@ struct sg3_report { struct sg3_device* dev; }; +/* Add new undefined triangle descriptions to a report */ +static res_T +report_enlarge_trg_descriptions + (struct sg3_report* report, + const size_t sz) +{ + res_T res = RES_OK; + size_t old_sz = + darray_trg_descriptions_size_get(&report->trg_descriptions); + if(sz <= old_sz) return RES_OK; + ASSERT(sz - old_sz < UINT_MAX); + ERR(darray_trg_descriptions_resize(&report->trg_descriptions, sz)); + report->trg_with_undef_sides_count += (unsigned)(sz - old_sz); + report->trg_with_undef_intface_count += (unsigned)(sz - old_sz); +exit: + return res; +error: + goto exit; +} + /******************************************************************************* * Local functions ******************************************************************************/ diff --git a/src/star-geometry.h b/src/star-geometry.h @@ -214,31 +214,45 @@ sg3_geometry_create struct sg3_geometry** geometry); /* Add a new set of 3D vertices and triangles to the geometry; triangles can - * possibly be decorated with media and interface. - * Vertices can be duplicates and are silently deduplicated. - * Triangles can be duplicates. Duplicate triangles validity is either ruled by - * the user-provided merge_triangle callback, or is just a matter of media - * consistency if no callback is provided. + * be decorated with 3 properties (front and back media and interface) that can + * be let undefined using the SG3_UNDEFINED_PROPERTY special value. + * Vertices can be duplicates and are silently deduplicated, always valid. + * Triangles can be duplicates, but this can be ruled invalid. 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, the property consistency question is to be + * understood as the consistency of the different values for the same property + * across calls of sg3_geometry_add, and 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 sg3_report_validate_properties API call). * Valid triangle duplicates are silently deduplicated, the first invalid - * duplicate triggers an error (sg3_geometry_add returns RES_BAD_ARG). - * The special value SG3_UNDEFINED_PROPERTY can be used to denote either an - * undefined medium or an undefined interface. - * Media on duplicate triangles are consider compatible if: - * - the merge_triangle callback is provided and returns RES_OK, - * - or media are identical or SG3_UNDEFINED_PROPERTY. + * duplicate triggers an error (sg3_geometry_add stops and returns non-RES_OK). + * The value SG3_UNDEFINED_PROPERTY that can be used to denote undefined + * properties cannot create a conflict. + * The way properties consistency is decided depends of the merge_triangle + * callback being provided or not: + * - if provided, the callback must return the consistency status using the + * merge_conflict int* paramater (0 for consistent; any other value for + * inconsistent, this value being recorded in the report) and the value + * returned by the callback decides if sg3_geometry_add continue processing + * other triangles (RES_OK for continue; any other value for stop, this value + * being returned by sg3_geometry_add); + * - if not, 2 different not-SG3_UNDEFINED_PROPERTY are inconsistent; the first + * occuring inconsistency makes sg3_geometry_add stop and return RES_BAD_ARG + * and the report record the merge_conflict value of 1. * When deduplicating triangles, the first occurence remains (with its * original index in user world, regardless of deduplication); the only - * way deduplication can change a triangle is to change a property (i.e. a - * medium or an interface) from SG3_UNDEFINED_PROPERTY to any defined value. + * way deduplication can change a triangle is to change a property from + * SG3_UNDEFINED_PROPERTY to any defined value. * The add_triangle and merge_triangle callbacks can be used for external * attribute and app-data management. If a call to a callback returns any * non-RES_OK value, sg3_geometry_add stops and returns the same error value. * In this case the geometry is partially added without any possible undo, but * is in a state that allows further calls to sg3_geometry_add. - * By returning RES_OK even though an incompatibility exists, these callbacks + * By returning RES_OK even though an inconsistency exists, these callbacks * can let sg3_geometry_add process through the end and build a full report; - * in this scenario, the client code has to record the error status and proceed - * accordingly. */ + * in this scenario, the client code has to proceed according to the + * inconsistency despite sg3_geometry_add returning RES_OK. */ SG3_API res_T sg3_geometry_add (struct sg3_geometry* geometry, @@ -247,11 +261,9 @@ sg3_geometry_add const unsigned triangles_count, /* User function that provides vertices ids for added triangles */ void(*indices)(const unsigned itri, unsigned ids[3], void* context), - /* User function that provides media ids for added triangles */ - void(*media) /* Can be NULL <=> SG3_UNDEFINED_MEDIUM used */ - (const unsigned itri, unsigned med[2], void* context), - void(*intface) /* Can be NULL <=> SG3_UNDEFINED_INTERFACE used */ - (const unsigned itri, unsigned* intface, void* context), + /* User function that provides properties for added triangles */ + void(*properties) /* Can be NULL <=> SG3_UNDEFINED_PROPERTY used */ + (const unsigned itri, unsigned med[3], void* context), /* Number of added vertices */ const unsigned vertices_count, /* User function that provides coordinates for added vertices */ diff --git a/src/test_sg3_report.c b/src/test_sg3_report.c @@ -48,6 +48,7 @@ merge_trg *merge_conflict = (int)itri; return RES_OK; } + int main(int argc, char** argv) { @@ -149,27 +150,43 @@ main(int argc, char** argv) ctx.positions = cube_vertices; ctx.indices = cube_indices; ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; d3(ctx.offset, 0, 0, 0); ctx.front_media = medium0; ctx.back_media = medium1; ctx.intface = intface0; ctx.custom = NULL; - OK(sg3_geometry_add(geometry, 2, get_indices, get_media, - get_intface, 6, get_position, NULL, NULL, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, NULL, NULL, &ctx)); OK(sg3_report_dump_as_C_code(report, stdout, "test")); - /* Conflicts */ - ctx.front_media = medium1; - OK(sg3_geometry_add(geometry, 2, get_indices, get_media, - get_intface, 6, get_position, NULL, merge_trg, &ctx)); + /* Conflicts with merge_trg callback */ + /* OK because merge_trg returns RES_OK */ + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, NULL, merge_trg, &ctx)); + OK(sg3_report_get_merge_conflict_count(report, &count)); + /* Due to merge_trg internals, all but the first triangle report conflict */ + CHK(count == ntriangles - 1); BA(sg3_report_dump_as_C_code(report, stdout, "test")); + OK(sg3_geometry_ref_put(geometry)); + OK(sg3_report_ref_put(report)); + /* Conflicts without merge_trg callback */ + OK(sg3_report_create(dev, &report)); + OK(sg3_geometry_create(dev, report, &geometry)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, NULL, NULL, &ctx)); + ctx.front_media = medium1_front0; + /* BA because there are conflicts and no merge_trg callback to overrule */ + BA(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, NULL, NULL, &ctx)); + OK(sg3_report_get_merge_conflict_count(report, &count)); + /* Without merge_trg add stops at the first conflict */ + CHK(count == 1); + BA(sg3_report_dump_as_C_code(report, stdout, "test")); OK(sg3_geometry_ref_put(geometry)); OK(sg3_report_ref_put(report)); - + OK(sg3_device_ref_put(dev)); check_memory_allocator(&allocator); diff --git a/src/test_sg3_report_2.c b/src/test_sg3_report_2.c @@ -98,8 +98,6 @@ main(int argc, char** argv) ctx.positions = cube_vertices; ctx.indices = cube_indices; ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; d3(ctx.offset, 0, 0, 0); ctx.custom = &add_geom_ctx; @@ -114,16 +112,16 @@ 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(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + BA(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == 0); OK(sg3_report_get_unique_vertices_count(report, &count)); CHK(count == nvertices); OK(sg3_report_get_unique_triangles_count(report, &count)); CHK(count == 0); add_geom_ctx.add_res = RES_MEM_ERR; - ME(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + ME(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == 0); CHK(count == 0); OK(sg3_report_get_unique_triangles_count(report, &count)); @@ -131,8 +129,8 @@ main(int argc, char** argv) /* Successful add geometry with add callback */ add_geom_ctx.add_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_report_get_unique_vertices_count(report, &count)); @@ -155,8 +153,8 @@ main(int argc, char** argv) /* Successful add geometry without add callback */ add_geom_ctx.add_cpt = 0; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, NULL, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, NULL, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == 0); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_report_get_unique_vertices_count(report, &count)); @@ -166,12 +164,12 @@ main(int argc, char** argv) /* If merge fails, add geometry fails the same way */ add_geom_ctx.merge_res = RES_BAD_ARG; - BA(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + BA(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); add_geom_ctx.merge_res = RES_MEM_ERR; - ME(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + ME(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_report_get_unique_vertices_count(report, &count)); CHK(count == nvertices); @@ -179,8 +177,8 @@ main(int argc, char** argv) CHK(count == ntriangles); /* Successful add geometry without merge callback */ - OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, NULL, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, NULL, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); OK(sg3_report_get_unique_vertices_count(report, &count)); CHK(count == nvertices); @@ -189,8 +187,8 @@ main(int argc, char** argv) /* Successful add geometry with merge callback */ add_geom_ctx.merge_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_media, - get_intface, nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, get_properties, + nvertices, get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; OK(sg3_report_get_unique_vertices_count(report, &count)); @@ -210,8 +208,8 @@ main(int argc, char** argv) /* Successful add geometry with add callback */ add_geom_ctx.add_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, nvertices, + get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == 0); add_geom_ctx.add_cpt = 0; @@ -224,16 +222,16 @@ main(int argc, char** argv) /* Successful add geometry with add callback */ add_geom_ctx.add_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, nvertices, + get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.add_cpt == ntriangles); CHK(add_geom_ctx.merge_cpt == 0); add_geom_ctx.add_cpt = 0; /* Successful add geometry with merge callback */ add_geom_ctx.merge_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, nvertices, + get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; @@ -242,14 +240,14 @@ main(int argc, char** argv) ctx.back_media = medium0; /* Unsuccessful add geometry without merge callback */ - OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, NULL, - nvertices, get_position, add_trg, NULL, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, nvertices, + get_position, add_trg, NULL, &ctx)); CHK(add_geom_ctx.merge_cpt == 0); /* Successful add geometry with merge callback */ add_geom_ctx.merge_res = RES_OK; - OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); + OK(sg3_geometry_add(geometry, ntriangles, get_indices, NULL, nvertices, + get_position, add_trg, merge_trg, &ctx)); CHK(add_geom_ctx.merge_cpt == ntriangles); add_geom_ctx.merge_cpt = 0; diff --git a/src/test_sg3_utils.h b/src/test_sg3_utils.h @@ -85,7 +85,6 @@ struct context { void* custom; double offset[3]; double scale; - char reverse_vrtx, reverse_med; }; static const unsigned medium0[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -103,8 +102,8 @@ get_indices(const unsigned itri, unsigned ids[3], void* context) const struct context* ctx = context; ASSERT(ids && ctx); ids[0] = ctx->indices[itri * 3 + 0]; - ids[ctx->reverse_vrtx ? 2 : 1] = ctx->indices[itri * 3 + 1]; - ids[ctx->reverse_vrtx ? 1 : 2] = ctx->indices[itri * 3 + 2]; + ids[1] = ctx->indices[itri * 3 + 1]; + ids[2] = ctx->indices[itri * 3 + 2]; } static INLINE void @@ -118,20 +117,14 @@ get_position(const unsigned ivert, double pos[3], void* context) } static INLINE void -get_media(const unsigned itri, unsigned medium[2], void* context) +get_properties(const unsigned itri, unsigned medium[3], void* context) { const struct context* ctx = context; ASSERT(medium && ctx); - medium[ctx->reverse_med ? 1 : 0] = ctx->front_media[itri]; - medium[ctx->reverse_med ? 0 : 1] = ctx->back_media[itri]; + medium[SG3_FRONT] = ctx->front_media[itri]; + medium[SG3_BACK] = ctx->back_media[itri]; + medium[SG3_INTFACE] = ctx->intface[itri]; } -static INLINE void -get_intface(const unsigned itri, unsigned* intface, void* context) -{ - const struct context* ctx = context; - ASSERT(intface && ctx); - *intface = ctx->intface[itri]; -} #endif /* TEST_SG3_UTILS_H */