commit 213df7ab43c41dfafb4ea7261f3fa655ebb079e1
parent f88f1e0bcb9df8916f5b15e487d860578fe5a766
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 28 Jan 2020 15:35:14 +0100
API renames
Diffstat:
22 files changed, 497 insertions(+), 496 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -155,7 +155,7 @@ if(NOT NO_TEST)
new_test(test_senc_scene)
new_test(test_senc_some_enclosures)
new_test(test_senc_some_triangles)
- new_test(test_senc_undefined_medium)
+ new_test(test_senc_unspecified_medium)
target_link_libraries(test_senc_enclosure Star3D)
target_link_libraries(test_senc_sample_enclosure StarSP Star3D)
diff --git a/src/senc.h b/src/senc.h
@@ -42,8 +42,8 @@
* as CPU cores */
#define SENC_NTHREADS_DEFAULT (~0u)
-/* A constant to specify an undefined medium */
-#define SENC_UNDEFINED_MEDIUM UINT_MAX
+/* A constant to specify an unspecified medium */
+#define SENC_UNSPECIFIED_MEDIUM UINT_MAX
/* Forward declaration of external opaque data types */
struct logger;
@@ -71,13 +71,13 @@ struct senc_enclosure_header {
/* The ID of the enclosure; 0, 1, ... */
unsigned enclosure_id;
/* Number of triangles; a triangle can be accounted for twice, once by side */
- unsigned triangle_count;
- /* Number of triangles; a triangle cannot be accounted for twice */
- unsigned unique_triangle_count;
+ unsigned primitives_count;
+ /* Number of unique triangles; a triangle cannot be accounted for twice */
+ unsigned unique_primitives_count;
/* Number of vertices */
unsigned vertices_count;
/* The number of media inside the enclosure,
- * SENC_UNDEFINED_MEDIUM included */
+ * SENC_UNSPECIFIED_MEDIUM included */
unsigned enclosed_media_count;
/* Is the enclosure open/infinite?
* Only the outermost enclosure is infinite. */
@@ -167,7 +167,7 @@ senc_scene_create
/* User function that provides vertices ids for triangles */
void(*get_indices)(const unsigned itri, unsigned ids[3], void* context),
/* User function that provides media ids for triangles */
- void(*get_media) /* Can be NULL <=> SENC_UNDEFINED_MEDIUM medium used */
+ void(*get_media) /* Can be NULL <=> SENC_UNSPECIFIED_MEDIUM medium used */
(const unsigned itri, unsigned med[2], void* context),
/* Number of vertices */
const unsigned vertices_count,
@@ -186,20 +186,20 @@ senc_scene_get_convention
/* Returns the number of triangles in the scene. */
SENC_API res_T
-senc_scene_get_triangles_count
+senc_scene_get_primitives_count
(const struct senc_scene* scene,
unsigned* count);
/* Returns the itri_th triangle vertices' indices. */
SENC_API res_T
-senc_scene_get_triangle
+senc_scene_get_primitive
(const struct senc_scene* scene,
const unsigned itri,
unsigned indices[3]);
/* Returns the media for the itri_th triangle. */
SENC_API res_T
-senc_scene_get_triangle_media
+senc_scene_get_primitive_media
(const struct senc_scene* scene,
const unsigned itri,
unsigned media[2]);
@@ -232,7 +232,7 @@ senc_scene_get_enclosure_count
unsigned* count);
/* Returns the number of enclosures that have some geometry refering to the
- * imed_th medium or SENC_UNDEFINED_MEDIUM. */
+ * imed_th medium or SENC_UNSPECIFIED_MEDIUM. */
SENC_API res_T
senc_scene_get_enclosure_count_by_medium
(const struct senc_scene* scene,
@@ -247,7 +247,7 @@ senc_scene_get_enclosure
struct senc_enclosure** enclosure);
/* Returns the idx_th enclosure using the imed_th medium or
- * SENC_UNDEFINED_MEDIUM. */
+ * SENC_UNSPECIFIED_MEDIUM. */
SENC_API res_T
senc_scene_get_enclosure_by_medium
(struct senc_scene* scene,
@@ -258,7 +258,7 @@ senc_scene_get_enclosure_by_medium
/* Returns the enclosures the itri_th triangle front and back sides are member
* of. */
SENC_API res_T
-senc_scene_get_triangle_enclosures
+senc_scene_get_primitive_enclosures
(const struct senc_scene* scene,
const unsigned itri,
unsigned enclosures[2]);
@@ -267,14 +267,14 @@ senc_scene_get_triangle_enclosures
* - that have arity 1 (single triangle using the segment)
* - that connect 2 different media */
SENC_API res_T
-senc_scene_get_frontier_segments_count
+senc_scene_get_frontier_elements_count
(const struct senc_scene* scene,
unsigned* count);
/* Returns the iseg_th frontier segment; the returned indices are global unique
* vertex indices. */
SENC_API res_T
-senc_scene_get_frontier_segment
+senc_scene_get_frontier_element
(const struct senc_scene* scene,
const unsigned iseg,
unsigned vrtx_id[2]);
@@ -310,7 +310,7 @@ senc_enclosure_get_header
/* Returns the itri_th triangle of an enclosure.
* Indices are local to the enclosure. */
SENC_API res_T
-senc_enclosure_get_triangle
+senc_enclosure_get_primitive
(const struct senc_enclosure* enclosure,
const unsigned itri,
unsigned indices[3]);
@@ -325,7 +325,7 @@ senc_enclosure_get_vertex
/* Returns the global id of the itri_th triangle of an enclosure
* and the involved side. */
SENC_API res_T
-senc_enclosure_get_triangle_global_id
+senc_enclosure_get_primitive_global_id
(const struct senc_enclosure* enclosure,
const unsigned itri,
unsigned* gid,
diff --git a/src/senc_descriptor.c b/src/senc_descriptor.c
@@ -56,11 +56,11 @@ senc_scene_get_enclosure_count_by_medium
size_t tmp, m_idx;
const struct darray_enc_id* enc_ids;
if(!scn || !count
- || (imed != SENC_UNDEFINED_MEDIUM && imed >= scn->next_medium_idx))
+ || (imed != SENC_UNSPECIFIED_MEDIUM && imed >= scn->next_medium_idx))
return RES_BAD_ARG;
ASSERT(darray_enc_ids_array_size_get(&scn->analyze.enc_ids_array_by_medium)
== 1 + scn->next_medium_idx);
- m_idx = (imed == SENC_UNDEFINED_MEDIUM) ? 0 : imed + 1;
+ m_idx = (imed == SENC_UNSPECIFIED_MEDIUM) ? 0 : imed + 1;
enc_ids = darray_enc_ids_array_cdata_get(&scn->analyze.enc_ids_array_by_medium)
+ m_idx;
tmp = darray_enc_id_size_get(enc_ids);
@@ -96,11 +96,11 @@ senc_scene_get_enclosure_by_medium
const struct darray_enc_id* enc_ids;
unsigned index;
if(!scn || !out_enc
- || (imed != SENC_UNDEFINED_MEDIUM && imed >= scn->next_medium_idx))
+ || (imed != SENC_UNSPECIFIED_MEDIUM && imed >= scn->next_medium_idx))
return RES_BAD_ARG;
ASSERT(darray_enc_ids_array_size_get(&scn->analyze.enc_ids_array_by_medium)
== 1 + scn->next_medium_idx);
- m_idx = (imed == SENC_UNDEFINED_MEDIUM) ? 0 : imed + 1;
+ m_idx = (imed == SENC_UNSPECIFIED_MEDIUM) ? 0 : imed + 1;
enc_ids =
darray_enc_ids_array_cdata_get(&scn->analyze.enc_ids_array_by_medium) + m_idx;
if(idx >= darray_enc_id_size_get(enc_ids)) return RES_BAD_ARG;
@@ -109,7 +109,7 @@ senc_scene_get_enclosure_by_medium
}
res_T
-senc_scene_get_triangle_enclosures
+senc_scene_get_primitive_enclosures
(const struct senc_scene* scn,
const unsigned itri,
unsigned enclosures[2])
@@ -130,7 +130,7 @@ senc_scene_get_triangle_enclosures
}
res_T
-senc_scene_get_frontier_segments_count
+senc_scene_get_frontier_elements_count
(const struct senc_scene* scn,
unsigned* count)
{
@@ -144,7 +144,7 @@ senc_scene_get_frontier_segments_count
}
res_T
-senc_scene_get_frontier_segment
+senc_scene_get_frontier_element
(const struct senc_scene* scn,
const unsigned iseg,
unsigned vrtx_id[2])
diff --git a/src/senc_enclosure.c b/src/senc_enclosure.c
@@ -75,7 +75,7 @@ senc_enclosure_get_header
}
res_T
-senc_enclosure_get_triangle
+senc_enclosure_get_primitive
(const struct senc_enclosure* enclosure,
const unsigned itri,
unsigned indices[3])
@@ -83,10 +83,10 @@ senc_enclosure_get_triangle
const struct side_enc* side;
int i;
if(!enclosure || !indices
- || itri >= enclosure->data->header.triangle_count)
+ || itri >= enclosure->data->header.primitives_count)
return RES_BAD_ARG;
ASSERT(darray_sides_enc_size_get(&enclosure->data->sides)
- == enclosure->data->header.triangle_count);
+ == enclosure->data->header.primitives_count);
side = darray_sides_enc_cdata_get(&enclosure->data->sides) + itri;
FOR_EACH(i, 0, 3) {
ASSERT(side->vertice_id[i] < UINT_MAX);
@@ -117,7 +117,7 @@ senc_enclosure_get_vertex
}
res_T
-senc_enclosure_get_triangle_global_id
+senc_enclosure_get_primitive_global_id
(const struct senc_enclosure* enclosure,
const unsigned itri,
unsigned* gid,
@@ -125,10 +125,10 @@ senc_enclosure_get_triangle_global_id
{
const struct side_enc* side;
if(!enclosure || !gid || !sde
- || itri >= enclosure->data->header.triangle_count)
+ || itri >= enclosure->data->header.primitives_count)
return RES_BAD_ARG;
ASSERT(darray_sides_enc_size_get(&enclosure->data->sides)
- == enclosure->data->header.triangle_count);
+ == enclosure->data->header.primitives_count);
side = darray_sides_enc_cdata_get(&enclosure->data->sides) + itri;
*gid = (unsigned)TRGSIDE_2_TRG(side->side_id);
*sde = TRGSIDE_2_SIDE(side->side_id);
diff --git a/src/senc_enclosure_data.h b/src/senc_enclosure_data.h
@@ -62,8 +62,8 @@ init_header(struct senc_enclosure_header* header)
{
ASSERT(header);
header->enclosure_id = ENCLOSURE_NULL__;
- header->triangle_count = 0;
- header->unique_triangle_count = 0;
+ header->primitives_count = 0;
+ header->unique_primitives_count = 0;
header->vertices_count = 0;
header->enclosed_media_count = 0;
header->is_infinite = CHAR_MAX;
@@ -117,7 +117,7 @@ bool_array_of_media_to_darray_media
darray_media_clear(dst);
if(res != RES_OK) goto error;
FOR_EACH(m_idx, 0, next_medium_idx + 1) {
- medium_id_t medium = m_idx ? (medium_id_t)(m_idx - 1) : SENC_UNDEFINED_MEDIUM;
+ medium_id_t medium = m_idx ? (medium_id_t)(m_idx - 1) : SENC_UNSPECIFIED_MEDIUM;
if(!data[m_idx]) continue;
res = darray_media_push_back(dst, &medium);
if(res != RES_OK) goto error;
diff --git a/src/senc_s3d_helper.h b/src/senc_s3d_helper.h
@@ -33,7 +33,7 @@ senc_s3d_scene_get_indices__
const struct senc_scene* scene = ctx;
res_T r;
ASSERT(indices && scene);
- r = senc_scene_get_triangle(scene, itri, indices);
+ r = senc_scene_get_primitive(scene, itri, indices);
ASSERT(r == RES_OK); (void)r;
}
@@ -67,7 +67,7 @@ senc_s3d_enclosure_get_indices__
const struct senc_enclosure* enclosure = ctx;
res_T r;
ASSERT(indices && ctx);
- r = senc_enclosure_get_triangle(enclosure, itri, indices);
+ r = senc_enclosure_get_primitive(enclosure, itri, indices);
ASSERT(r == RES_OK); (void)r;
}
diff --git a/src/senc_scene.c b/src/senc_scene.c
@@ -53,7 +53,7 @@ compatible_medium
(const medium_id_t m1,
const medium_id_t m2)
{
- if(m1 == SENC_UNDEFINED_MEDIUM || m2 == SENC_UNDEFINED_MEDIUM) return 1;
+ if(m1 == SENC_UNSPECIFIED_MEDIUM || m2 == SENC_UNSPECIFIED_MEDIUM) return 1;
return (m1 == m2);
}
@@ -145,7 +145,7 @@ senc_scene_create
/* Get triangles */
FOR_EACH(i, 0, ntris) {
int j;
- unsigned med[2] = { SENC_UNDEFINED_MEDIUM, SENC_UNDEFINED_MEDIUM };
+ unsigned med[2] = { SENC_UNSPECIFIED_MEDIUM, SENC_UNSPECIFIED_MEDIUM };
unsigned ind[3];
union vrtx_id3 trg_key;
struct triangle_in tmp;
@@ -186,13 +186,13 @@ senc_scene_create
OK(htable_trg_set(&unique_triangles, &trg_key, &i));
FOR_EACH(j, 0, 2) {
struct side_range* media_use;
- unsigned m_idx = (med[j] == SENC_UNDEFINED_MEDIUM) ? 0 : med[j] + 1;
+ unsigned m_idx = (med[j] == SENC_UNSPECIFIED_MEDIUM) ? 0 : med[j] + 1;
tmp.medium[j] = (medium_id_t)med[j];
if(m_idx >= scn->next_medium_idx) {
scn->next_medium_idx = m_idx;
darray_side_range_resize(&scn->media_use, 1 + m_idx);
}
- /* media_use 0 is for SENC_UNDEFINED_MEDIUM */
+ /* media_use 0 is for SENC_UNSPECIFIED_MEDIUM */
media_use = darray_side_range_data_get(&scn->media_use) + m_idx;
media_use->first =
MMIN(media_use->first, TRGIDxSIDE_2_TRGSIDE((trg_id_t)i, j));
@@ -206,7 +206,7 @@ senc_scene_create
}
OK(darray_enc_ids_array_resize(&scn->analyze.enc_ids_array_by_medium,
- 1 + scn->next_medium_idx)); /* +1 is for undef */
+ 1 + scn->next_medium_idx)); /* +1 is for unspecified */
/* Proceed to the analyze */
OK(scene_analyze(scn));
@@ -235,7 +235,7 @@ senc_scene_get_convention
}
res_T
-senc_scene_get_triangles_count
+senc_scene_get_primitives_count
(const struct senc_scene* scn,
unsigned* count)
{
@@ -245,7 +245,7 @@ senc_scene_get_triangles_count
}
res_T
-senc_scene_get_triangle
+senc_scene_get_primitive
(const struct senc_scene* scn,
const unsigned itri,
unsigned indices[3])
@@ -265,7 +265,7 @@ senc_scene_get_triangle
}
res_T
-senc_scene_get_triangle_media
+senc_scene_get_primitive_media
(const struct senc_scene* scn,
const unsigned itri,
unsigned media[2])
diff --git a/src/senc_scene_analyze.c b/src/senc_scene_analyze.c
@@ -187,7 +187,7 @@ extract_connex_components
FOR_EACH(s, 0, 2) {
const side_id_t side = TRGIDxSIDE_2_TRGSIDE(t_, s);
medium_id_t medium = trg_in->medium[s];
- m_idx = (medium == SENC_UNDEFINED_MEDIUM) ? 0 : medium + 1;
+ m_idx = (medium == SENC_UNSPECIFIED_MEDIUM) ? 0 : medium + 1;
ASSERT(media_use[m_idx].first <= side && side
<= media_use[m_idx].last);
}
@@ -197,10 +197,11 @@ extract_connex_components
/* We loop on sides to build connex components. */
#pragma omp for schedule(dynamic) nowait
- /* Process all media, including undef */
+ /* Process all media, including unspecified */
for(m_idx = 0; m_idx < 1 + (int64_t)scn->next_medium_idx; m_idx++) {
- const medium_id_t medium = m_idx ? (medium_id_t)(m_idx - 1) : SENC_UNDEFINED_MEDIUM;
- /* media_use 0 is for SENC_UNDEFINED_MEDIUM, n+1 is for n */
+ const medium_id_t medium
+ = m_idx ? (medium_id_t)(m_idx - 1) : SENC_UNSPECIFIED_MEDIUM;
+ /* media_use 0 is for SENC_UNSPECIFIED_MEDIUM, n+1 is for n */
const struct side_range* media_use =
darray_side_range_cdata_get(&scn->media_use) + m_idx;
/* Any not-already-used side is used as a starting point */
@@ -246,7 +247,7 @@ extract_connex_components
/* Reuse array if possible, or create a new one */
if(current_media) {
- /* current_media 0 is for SENC_UNDEFINED_MEDIUM, n+1 is for n */
+ /* current_media 0 is for SENC_UNSPECIFIED_MEDIUM, n+1 is for n */
memset(current_media, 0, 1 + scn->next_medium_idx);
} else {
current_media = MEM_CALLOC(alloc, 1 + scn->next_medium_idx,
@@ -317,7 +318,7 @@ extract_connex_components
enum side_flag nbour_side_id = TRGSIDE_2_SIDEFLAG(neighbour_id);
unsigned char* nbour_used = processed + nbour_trg_id;
const struct trgside* neighbour = trgsides + neighbour_id;
- medium_id_t nbour_med_idx = (neighbour->medium == SENC_UNDEFINED_MEDIUM)
+ medium_id_t nbour_med_idx = (neighbour->medium == SENC_UNSPECIFIED_MEDIUM)
? 0 : neighbour->medium + 1;
if(neighbour->medium < medium
|| (*nbour_used & SIDE_CANCELED_FLAG(nbour_side_id)))
@@ -917,9 +918,9 @@ collect_and_link_neighbours
|| p_ccw_side->medium == triangles_in[ccw_id].medium[ccw_side]);
p_crt_side->medium = triangles_in[crt_id].medium[crt_side];
p_ccw_side->medium = triangles_in[ccw_id].medium[ccw_side];
- ASSERT(p_crt_side->medium == SENC_UNDEFINED_MEDIUM
+ ASSERT(p_crt_side->medium == SENC_UNSPECIFIED_MEDIUM
|| p_crt_side->medium < scn->next_medium_idx);
- ASSERT(p_ccw_side->medium == SENC_UNDEFINED_MEDIUM
+ ASSERT(p_ccw_side->medium == SENC_UNSPECIFIED_MEDIUM
|| p_ccw_side->medium < scn->next_medium_idx);
/* Detect triangles that could surround a hole:
* - single triangle on (one of) its edge
@@ -1047,9 +1048,9 @@ build_result
/* Add this enclosure in relevant by-medium lists */
FOR_EACH(m, 0, enc->header.enclosed_media_count) {
medium_id_t medium = darray_media_cdata_get(&enc->enclosed_media)[m];
- unsigned m_idx = (medium == SENC_UNDEFINED_MEDIUM) ? 0 : medium + 1;
+ unsigned m_idx = (medium == SENC_UNSPECIFIED_MEDIUM) ? 0 : medium + 1;
struct darray_enc_id* enc_ids_array_by_medium;
- ASSERT(medium == SENC_UNDEFINED_MEDIUM || medium < scn->next_medium_idx);
+ ASSERT(medium == SENC_UNSPECIFIED_MEDIUM || medium < scn->next_medium_idx);
ASSERT(darray_enc_ids_array_size_get(&scn->analyze.enc_ids_array_by_medium)
== 1 + scn->next_medium_idx);
enc_ids_array_by_medium =
@@ -1086,7 +1087,7 @@ build_result
if(triangles_enc[t].enclosure[SENC_FRONT] != e
&& triangles_enc[t].enclosure[SENC_BACK] != e)
continue;
- ++enc->header.unique_triangle_count;
+ ++enc->header.unique_primitives_count;
FOR_EACH(i, 0, 3) {
vrtx_id_t* p_id = htable_vrtx_id_find(&vtable, trg_in->vertice_id + i);
@@ -1110,7 +1111,7 @@ build_result
/* Front side of the original triangle is member of the enclosure */
int input_normal_in = normals_front;
int revert_triangle = (input_normal_in != output_normal_in);
- ++enc->header.triangle_count;
+ ++enc->header.primitives_count;
side_enc = darray_sides_enc_data_get(&enc->sides) + fst_idx++;
FOR_EACH(i, 0, 3) {
int ii = revert_triangle ? 2 - i : i;
@@ -1122,7 +1123,7 @@ build_result
/* Back side of the original triangle is member of the enclosure */
int input_normal_in = normals_back;
int revert_triangle = (input_normal_in != output_normal_in);
- ++enc->header.triangle_count;
+ ++enc->header.primitives_count;
/* If both sides are in the enclosure, put the second side at the end */
side_enc = darray_sides_enc_data_get(&enc->sides) +
((triangles_enc[t].enclosure[SENC_FRONT] == e) ? --sgd_idx : fst_idx++);
diff --git a/src/senc_scene_c.h b/src/senc_scene_c.h
@@ -152,7 +152,7 @@ triangle_in_init(struct mem_allocator* alloc, struct triangle_in* trg) {
(void)alloc;
ASSERT(trg);
FOR_EACH(i, 0, 3) trg->vertice_id[i] = VRTX_NULL__;
- FOR_EACH(i, 0, 2) trg->medium[i] = SENC_UNDEFINED_MEDIUM;
+ FOR_EACH(i, 0, 2) trg->medium[i] = SENC_UNSPECIFIED_MEDIUM;
}
#define DARRAY_NAME triangle_in
@@ -289,7 +289,7 @@ struct senc_scene {
trg_id_t ntris; /* Trg count */
vrtx_id_t nverts; /* Vrtx count */
medium_id_t next_medium_idx;
- /* media_use 0 is for SENC_UNDEFINED_MEDIUM, n+1 is for n */
+ /* media_use 0 is for SENC_UNSPECIFIED_MEDIUM, n+1 is for n */
struct darray_side_range media_use;
/* The descriptor of the analyze */
diff --git a/src/test_senc_cube_in_cube.c b/src/test_senc_cube_in_cube.c
@@ -261,7 +261,7 @@ main(int argc, char** argv)
ASSERT(header.enclosed_media_count == 1);
OK(senc_enclosure_get_medium(enclosure, 0, &m));
ASSERT(m <= 1);
- ASSERT((m == 0) == (header.triangle_count == cube_in_cube_2_triangles_count));
+ ASSERT((m == 0) == (header.primitives_count == cube_in_cube_2_triangles_count));
OK(senc_enclosure_ref_put(enclosure));
}
diff --git a/src/test_senc_cube_on_cube.c b/src/test_senc_cube_on_cube.c
@@ -171,7 +171,7 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == cube_on_cube_vertices_count);
- OK(senc_scene_get_triangles_count(scn, &count));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == cube_on_cube_triangles_count);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -186,7 +186,7 @@ main(int argc, char** argv)
CHK(header.enclosed_media_count == 1);
OK(senc_enclosure_get_medium(enclosure, 0, &m));
if(header.is_infinite) ASSERT(m == 2); /* External */
- else if(header.triangle_count == 12) ASSERT(m == 0); /* Internal */
+ else if(header.primitives_count == 12) ASSERT(m == 0); /* Internal */
else ASSERT(m == 1); /* In between */
OK(senc_enclosure_ref_put(enclosure));
#ifdef DUMP_ENCLOSURES
diff --git a/src/test_senc_enclosure.c b/src/test_senc_enclosure.c
@@ -71,14 +71,14 @@ test(const int convention)
BA(senc_enclosure_ref_put(NULL));
OK(senc_enclosure_ref_put(enclosure));
- BA(senc_enclosure_get_triangle(NULL, 0, indices[0]));
- BA(senc_enclosure_get_triangle(enclosure, ntriangles, indices[0]));
- BA(senc_enclosure_get_triangle(enclosure, 0, NULL));
- BA(senc_enclosure_get_triangle(NULL, ntriangles, indices[0]));
- BA(senc_enclosure_get_triangle(NULL, 0, NULL));
- BA(senc_enclosure_get_triangle(enclosure, ntriangles, NULL));
- BA(senc_enclosure_get_triangle(NULL, ntriangles, NULL));
- OK(senc_enclosure_get_triangle(enclosure, 0, indices[0]));
+ BA(senc_enclosure_get_primitive(NULL, 0, indices[0]));
+ BA(senc_enclosure_get_primitive(enclosure, ntriangles, indices[0]));
+ BA(senc_enclosure_get_primitive(enclosure, 0, NULL));
+ BA(senc_enclosure_get_primitive(NULL, ntriangles, indices[0]));
+ BA(senc_enclosure_get_primitive(NULL, 0, NULL));
+ BA(senc_enclosure_get_primitive(enclosure, ntriangles, NULL));
+ BA(senc_enclosure_get_primitive(NULL, ntriangles, NULL));
+ OK(senc_enclosure_get_primitive(enclosure, 0, indices[0]));
BA(senc_enclosure_get_vertex(NULL, 0, vrtx));
BA(senc_enclosure_get_vertex(enclosure, nvertices, vrtx));
@@ -89,22 +89,22 @@ test(const int convention)
BA(senc_enclosure_get_vertex(NULL, nvertices, NULL));
OK(senc_enclosure_get_vertex(enclosure, 0, vrtx));
- BA(senc_enclosure_get_triangle_global_id(NULL, 0, &gid, NULL));
- BA(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, &gid, NULL));
- BA(senc_enclosure_get_triangle_global_id(enclosure, 0, NULL, NULL));
- BA(senc_enclosure_get_triangle_global_id(NULL, ntriangles, &gid, NULL));
- BA(senc_enclosure_get_triangle_global_id(NULL, 0, NULL, NULL));
- BA(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, NULL, NULL));
- BA(senc_enclosure_get_triangle_global_id(NULL, ntriangles, NULL, NULL));
- BA(senc_enclosure_get_triangle_global_id(enclosure, 0, &gid, NULL));
- BA(senc_enclosure_get_triangle_global_id(NULL, 0, &gid, &side));
- BA(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, &gid, &side));
- BA(senc_enclosure_get_triangle_global_id(enclosure, 0, NULL, &side));
- BA(senc_enclosure_get_triangle_global_id(NULL, ntriangles, &gid, &side));
- BA(senc_enclosure_get_triangle_global_id(NULL, 0, NULL, &side));
- BA(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, NULL, &side));
- BA(senc_enclosure_get_triangle_global_id(NULL, ntriangles, NULL, &side));
- OK(senc_enclosure_get_triangle_global_id(enclosure, 0, &gid, &side));
+ BA(senc_enclosure_get_primitive_global_id(NULL, 0, &gid, NULL));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, ntriangles, &gid, NULL));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, 0, NULL, NULL));
+ BA(senc_enclosure_get_primitive_global_id(NULL, ntriangles, &gid, NULL));
+ BA(senc_enclosure_get_primitive_global_id(NULL, 0, NULL, NULL));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, ntriangles, NULL, NULL));
+ BA(senc_enclosure_get_primitive_global_id(NULL, ntriangles, NULL, NULL));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, 0, &gid, NULL));
+ BA(senc_enclosure_get_primitive_global_id(NULL, 0, &gid, &side));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, ntriangles, &gid, &side));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, 0, NULL, &side));
+ BA(senc_enclosure_get_primitive_global_id(NULL, ntriangles, &gid, &side));
+ BA(senc_enclosure_get_primitive_global_id(NULL, 0, NULL, &side));
+ BA(senc_enclosure_get_primitive_global_id(enclosure, ntriangles, NULL, &side));
+ BA(senc_enclosure_get_primitive_global_id(NULL, ntriangles, NULL, &side));
+ OK(senc_enclosure_get_primitive_global_id(enclosure, 0, &gid, &side));
BA(senc_enclosure_get_medium(NULL, 0, &medium));
BA(senc_enclosure_get_medium(enclosure, 2, &medium));
@@ -132,13 +132,13 @@ test(const int convention)
* if convention is front, front medium (0) is outside,
* that is medium 0's enclosure is infinite */
CHK(conv_front == ((medium == 0) == header.is_infinite));
- CHK(header.triangle_count == ntriangles);
- CHK(header.unique_triangle_count == ntriangles);
+ CHK(header.primitives_count == ntriangles);
+ CHK(header.unique_primitives_count == ntriangles);
CHK(header.vertices_count == nvertices);
CHK(header.is_infinite == (i == 0));
- FOR_EACH(t, 0, header.triangle_count) {
- OK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side));
+ FOR_EACH(t, 0, header.primitives_count) {
+ OK(senc_enclosure_get_primitive_global_id(enclosure, t, &gid, &side));
CHK(gid == t);
CHK(side == (medium == 0) ? SENC_FRONT : SENC_BACK);
}
@@ -152,7 +152,7 @@ test(const int convention)
int same, reversed;
/* Read same triangles in both enclosures */
FOR_EACH(i, 0, 2)
- OK(senc_enclosure_get_triangle(enclosures[i], n, indices[i]));
+ OK(senc_enclosure_get_primitive(enclosures[i], n, indices[i]));
/* Same triangles and opposite sides for the 2 enclosures */
FOR_EACH(i, 0, 3) CHK(indices[0][i] == indices[1][2 - i]);
/* Enclosure 0 is outside (and contains medium 0 if convention is front).
@@ -180,7 +180,7 @@ test(const int convention)
OK(senc_scene_create(dev, convention, ntriangles - 1, get_indices, get_media,
nvertices, get_position, &ctx, &scn));
- OK(senc_scene_get_frontier_segments_count(scn, &count));
+ OK(senc_scene_get_frontier_elements_count(scn, &count));
CHK(count == 3);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -199,17 +199,17 @@ test(const int convention)
CHK(header.enclosure_id == 0);
CHK(header.enclosed_media_count == 2);
- CHK(header.triangle_count == 2 * header.unique_triangle_count);
- CHK(header.unique_triangle_count == ntriangles - 1);
+ CHK(header.primitives_count == 2 * header.unique_primitives_count);
+ CHK(header.unique_primitives_count == ntriangles - 1);
CHK(header.vertices_count == nvertices);
CHK(header.is_infinite == 1);
- FOR_EACH(t, 0, header.triangle_count) {
- OK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side));
+ FOR_EACH(t, 0, header.primitives_count) {
+ OK(senc_enclosure_get_primitive_global_id(enclosure, t, &gid, &side));
/* The first unique_triangle_count triangles of an enclosure
* are unique triangles */
- if(t < header.unique_triangle_count) CHK(gid == t);
- CHK(side == (t < header.unique_triangle_count) ? SENC_FRONT : SENC_BACK);
+ if(t < header.unique_primitives_count) CHK(gid == t);
+ CHK(side == (t < header.unique_primitives_count) ? SENC_FRONT : SENC_BACK);
}
/* Put geometry in a 3D view using helper functions */
@@ -219,7 +219,7 @@ test(const int convention)
OK(s3d_device_create(NULL, &allocator, 0, &s3d));
OK(s3d_scene_create(s3d, &s3d_scn));
OK(s3d_shape_create_mesh(s3d, &s3d_shp));
- OK(s3d_mesh_setup_indexed_vertices(s3d_shp, header.triangle_count,
+ OK(s3d_mesh_setup_indexed_vertices(s3d_shp, header.primitives_count,
senc_s3d_enclosure_get_indices__, header.vertices_count, &s3d_attribs,
1, enclosure));
OK(s3d_scene_attach_shape(s3d_scn, s3d_shp));
diff --git a/src/test_senc_inconsistant_cube.c b/src/test_senc_inconsistant_cube.c
@@ -107,7 +107,7 @@ test(const int convention)
dump_enclosure(scn, e, name);
#endif
- FOR_EACH(i, 0, header.triangle_count) {
+ FOR_EACH(i, 0, header.primitives_count) {
int same, reversed, fst_reversed;
fst_reversed = ((e == 0) == conv_in);
expected_side = (inconsistant_medium_front[i] == expected_medium)
@@ -118,7 +118,7 @@ test(const int convention)
/* Should be made of the same triangles */
CHK(same);
CHK(i ? reversed != fst_reversed : reversed == fst_reversed);
- OK(senc_enclosure_get_triangle_global_id(enclosure, i, &gid, &side));
+ OK(senc_enclosure_get_primitive_global_id(enclosure, i, &gid, &side));
CHK(side == expected_side);
}
SENC(enclosure_ref_put(enclosure));
diff --git a/src/test_senc_many_enclosures.c b/src/test_senc_many_enclosures.c
@@ -60,7 +60,7 @@ main(int argc, char** argv)
cyl_vrtx_count = (unsigned)ctx.data.nvertices;
/* Create the scene with N_CYL cylinders.
- * There are NB_CYL_1 * NB_CYL_1 imbrications of NB_CYL_1 cylinders each.
+ * There are NB_CYL_X * NB_CYL_Y imbrications of NB_CYL_Z cylinders each.
* Each imbrication is located on a grid.
* The get_s3du_xxx getters have to retrieve the cylinder from the
* primitive and vertice indexes. */
@@ -76,7 +76,7 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == NB_CYL * cyl_vrtx_count);
- OK(senc_scene_get_triangles_count(scn, &count));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == NB_CYL * cyl_trg_count);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -89,7 +89,7 @@ main(int argc, char** argv)
OK(senc_enclosure_get_header(enclosure, &header));
CHK(header.enclosed_media_count == 1);
OK(senc_enclosure_get_medium(enclosure, 0, &m));
- CHK(header.triangle_count ==
+ CHK(header.primitives_count ==
(header.is_infinite /* Outermost enclosure: NB_CYL_X*NB_CYL_Y cylinders */
? NB_CYL_X * NB_CYL_Y * cyl_trg_count
: (m == 0
diff --git a/src/test_senc_many_triangles.c b/src/test_senc_many_triangles.c
@@ -76,7 +76,7 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == NB_CYL * cyl_vrtx_count);
- OK(senc_scene_get_triangles_count(scn, &count));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == NB_CYL * cyl_trg_count);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -86,7 +86,7 @@ main(int argc, char** argv)
struct senc_enclosure_header header;
OK(senc_scene_get_enclosure(scn, e, &enclosure));
OK(senc_enclosure_get_header(enclosure, &header));
- CHK(header.triangle_count ==
+ CHK(header.primitives_count ==
e ? cyl_trg_count : NB_CYL * cyl_trg_count);
OK(senc_enclosure_ref_put(enclosure));
}
diff --git a/src/test_senc_sample_enclosure.c b/src/test_senc_sample_enclosure.c
@@ -68,7 +68,7 @@ main(int argc, char** argv)
S3D(device_create(NULL, &allocator, 0, &s3d));
S3D(scene_create(s3d, &s3d_scn));
S3D(shape_create_mesh(s3d, &s3d_shp));
- S3D(mesh_setup_indexed_vertices(s3d_shp, header.triangle_count,
+ S3D(mesh_setup_indexed_vertices(s3d_shp, header.primitives_count,
senc_s3d_enclosure_get_indices__, header.vertices_count, &vrtx_get, 1,
enclosure));
S3D(scene_attach_shape(s3d_scn, s3d_shp));
diff --git a/src/test_senc_scene.c b/src/test_senc_scene.c
@@ -85,10 +85,10 @@ main(int argc, char** argv)
CHK(convention
== (SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE));
- BA(senc_scene_get_triangles_count(NULL, &count));
- BA(senc_scene_get_triangles_count(scn, NULL));
- BA(senc_scene_get_triangles_count(NULL, NULL));
- OK(senc_scene_get_triangles_count(scn, &count));
+ BA(senc_scene_get_primitives_count(NULL, &count));
+ BA(senc_scene_get_primitives_count(scn, NULL));
+ BA(senc_scene_get_primitives_count(NULL, NULL));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == ntriangles);
BA(senc_scene_get_vertices_count(NULL, &count));
@@ -97,23 +97,23 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == nvertices);
- BA(senc_scene_get_triangle(NULL, 0, ind));
- BA(senc_scene_get_triangle(scn, UINT_MAX, ind));
- BA(senc_scene_get_triangle(scn, 0, NULL));
- BA(senc_scene_get_triangle(NULL, UINT_MAX, ind));
- BA(senc_scene_get_triangle(NULL, 0, NULL));
- BA(senc_scene_get_triangle(scn, UINT_MAX, NULL));
- BA(senc_scene_get_triangle(NULL, UINT_MAX, NULL));
- OK(senc_scene_get_triangle(scn, 0, ind));
-
- BA(senc_scene_get_triangle_media(NULL, 0, ind));
- BA(senc_scene_get_triangle_media(scn, UINT_MAX, ind));
- BA(senc_scene_get_triangle_media(scn, 0, NULL));
- BA(senc_scene_get_triangle_media(NULL, UINT_MAX, ind));
- BA(senc_scene_get_triangle_media(NULL, 0, NULL));
- BA(senc_scene_get_triangle_media(scn, UINT_MAX, NULL));
- BA(senc_scene_get_triangle_media(NULL, UINT_MAX, NULL));
- OK(senc_scene_get_triangle_media(scn, 0, ind));
+ BA(senc_scene_get_primitive(NULL, 0, ind));
+ BA(senc_scene_get_primitive(scn, UINT_MAX, ind));
+ BA(senc_scene_get_primitive(scn, 0, NULL));
+ BA(senc_scene_get_primitive(NULL, UINT_MAX, ind));
+ BA(senc_scene_get_primitive(NULL, 0, NULL));
+ BA(senc_scene_get_primitive(scn, UINT_MAX, NULL));
+ BA(senc_scene_get_primitive(NULL, UINT_MAX, NULL));
+ OK(senc_scene_get_primitive(scn, 0, ind));
+
+ BA(senc_scene_get_primitive_media(NULL, 0, ind));
+ BA(senc_scene_get_primitive_media(scn, UINT_MAX, ind));
+ BA(senc_scene_get_primitive_media(scn, 0, NULL));
+ BA(senc_scene_get_primitive_media(NULL, UINT_MAX, ind));
+ BA(senc_scene_get_primitive_media(NULL, 0, NULL));
+ BA(senc_scene_get_primitive_media(scn, UINT_MAX, NULL));
+ BA(senc_scene_get_primitive_media(NULL, UINT_MAX, NULL));
+ OK(senc_scene_get_primitive_media(scn, 0, ind));
BA(senc_scene_get_vertex(NULL, 0, vrtx));
BA(senc_scene_get_vertex(scn, UINT_MAX, vrtx));
@@ -145,7 +145,7 @@ main(int argc, char** argv)
BA(senc_scene_get_enclosure_count_by_medium(NULL, 100, NULL));
OK(senc_scene_get_enclosure_count_by_medium(scn, 0, &count));
CHK(count == 1);
- OK(senc_scene_get_enclosure_count_by_medium(scn, SENC_UNDEFINED_MEDIUM,
+ OK(senc_scene_get_enclosure_count_by_medium(scn, SENC_UNSPECIFIED_MEDIUM,
&count));
CHK(count == 0);
@@ -176,31 +176,31 @@ main(int argc, char** argv)
BA(senc_scene_get_enclosure_by_medium(NULL, 100, UINT_MAX, NULL));
OK(senc_scene_get_enclosure_by_medium(scn, 0, 0, &enc));
OK(senc_enclosure_ref_put(enc));
- /* Index 0 is out of range for SENC_UNDEFINED_MEDIUM. */
- BA(senc_scene_get_enclosure_by_medium(scn, SENC_UNDEFINED_MEDIUM, 0, &enc));
-
- BA(senc_scene_get_triangle_enclosures(NULL, 0, ids));
- BA(senc_scene_get_triangle_enclosures(scn, UINT_MAX, ids));
- BA(senc_scene_get_triangle_enclosures(scn, 0, NULL));
- BA(senc_scene_get_triangle_enclosures(NULL, UINT_MAX, ids));
- BA(senc_scene_get_triangle_enclosures(NULL, 0, NULL));
- BA(senc_scene_get_triangle_enclosures(scn, UINT_MAX, NULL));
- BA(senc_scene_get_triangle_enclosures(NULL, UINT_MAX, NULL));
- OK(senc_scene_get_triangle_enclosures(scn, 0, ids));
-
- BA(senc_scene_get_frontier_segments_count(NULL, &count));
- BA(senc_scene_get_frontier_segments_count(scn, NULL));
- BA(senc_scene_get_frontier_segments_count(NULL, NULL));
- OK(senc_scene_get_frontier_segments_count(scn, &count));
+ /* Index 0 is out of range for SENC_UNSPECIFIED_MEDIUM. */
+ BA(senc_scene_get_enclosure_by_medium(scn, SENC_UNSPECIFIED_MEDIUM, 0, &enc));
+
+ BA(senc_scene_get_primitive_enclosures(NULL, 0, ids));
+ BA(senc_scene_get_primitive_enclosures(scn, UINT_MAX, ids));
+ BA(senc_scene_get_primitive_enclosures(scn, 0, NULL));
+ BA(senc_scene_get_primitive_enclosures(NULL, UINT_MAX, ids));
+ BA(senc_scene_get_primitive_enclosures(NULL, 0, NULL));
+ BA(senc_scene_get_primitive_enclosures(scn, UINT_MAX, NULL));
+ BA(senc_scene_get_primitive_enclosures(NULL, UINT_MAX, NULL));
+ OK(senc_scene_get_primitive_enclosures(scn, 0, ids));
+
+ BA(senc_scene_get_frontier_elements_count(NULL, &count));
+ BA(senc_scene_get_frontier_elements_count(scn, NULL));
+ BA(senc_scene_get_frontier_elements_count(NULL, NULL));
+ OK(senc_scene_get_frontier_elements_count(scn, &count));
CHK(count == 0);
- BA(senc_scene_get_frontier_segment(NULL, 0, ids));
- BA(senc_scene_get_frontier_segment(scn, UINT_MAX, ids));
- BA(senc_scene_get_frontier_segment(scn, 0, NULL));
- BA(senc_scene_get_frontier_segment(NULL, UINT_MAX, ids));
- BA(senc_scene_get_frontier_segment(NULL, 0, NULL));
- BA(senc_scene_get_frontier_segment(scn, UINT_MAX, NULL));
- BA(senc_scene_get_frontier_segment(NULL, UINT_MAX, NULL));
+ BA(senc_scene_get_frontier_element(NULL, 0, ids));
+ BA(senc_scene_get_frontier_element(scn, UINT_MAX, ids));
+ BA(senc_scene_get_frontier_element(scn, 0, NULL));
+ BA(senc_scene_get_frontier_element(NULL, UINT_MAX, ids));
+ BA(senc_scene_get_frontier_element(NULL, 0, NULL));
+ BA(senc_scene_get_frontier_element(scn, UINT_MAX, NULL));
+ BA(senc_scene_get_frontier_element(NULL, UINT_MAX, NULL));
BA(senc_scene_ref_get(NULL));
OK(senc_scene_ref_get(scn));
@@ -209,15 +209,15 @@ main(int argc, char** argv)
OK(senc_scene_ref_put(scn));
- /* Same geometry with SENC_UNDEFINED_MEDIUM */
+ /* Same geometry with SENC_UNSPECIFIED_MEDIUM */
OK(senc_scene_create(dev,
SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE,
ntriangles, get_indices, NULL,
nvertices, get_position, &ctx, &scn));
- OK(senc_scene_get_enclosure_by_medium(scn, SENC_UNDEFINED_MEDIUM, 0, &enc));
+ OK(senc_scene_get_enclosure_by_medium(scn, SENC_UNSPECIFIED_MEDIUM, 0, &enc));
OK(senc_enclosure_ref_put(enc));
- BA(senc_scene_get_enclosure_by_medium(scn, SENC_UNDEFINED_MEDIUM, 100, &enc));
+ BA(senc_scene_get_enclosure_by_medium(scn, SENC_UNSPECIFIED_MEDIUM, 100, &enc));
OK(senc_scene_ref_put(scn));
@@ -227,10 +227,10 @@ main(int argc, char** argv)
ntriangles - 1, get_indices, get_media,
nvertices, get_position, &ctx, &scn));
- OK(senc_scene_get_frontier_segments_count(scn, &count));
+ OK(senc_scene_get_frontier_elements_count(scn, &count));
CHK(count == 3);
- OK(senc_scene_get_frontier_segment(scn, 0, ids));
- BA(senc_scene_get_frontier_segment(scn, 3, ids));
+ OK(senc_scene_get_frontier_element(scn, 0, ids));
+ BA(senc_scene_get_frontier_element(scn, 3, ids));
OK(senc_scene_ref_put(scn));
@@ -248,7 +248,7 @@ main(int argc, char** argv)
CHK(!header.is_infinite);
OK(senc_enclosure_ref_put(enc));
- OK(senc_scene_get_triangle_media(scn, 0, medback));
+ OK(senc_scene_get_primitive_media(scn, 0, medback));
OK(senc_scene_ref_put(scn));
/* Medium mismatch between neighbour segments, but OK */
@@ -282,7 +282,7 @@ main(int argc, char** argv)
CHK(header.is_infinite);
OK(senc_enclosure_ref_put(enc));
- OK(senc_scene_get_triangle_media(scn, 0, medfront));
+ OK(senc_scene_get_primitive_media(scn, 0, medfront));
FOR_EACH(i, 0, 2) CHK(medback[i] == medfront[i]);
OK(senc_scene_ref_put(scn));
diff --git a/src/test_senc_some_enclosures.c b/src/test_senc_some_enclosures.c
@@ -3395,7 +3395,7 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == NB_CYL * CYL_VRTX_COUNT);
- OK(senc_scene_get_triangles_count(scn, &count));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == NB_CYL * CYL_TRG_COUNT);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -3408,7 +3408,7 @@ main(int argc, char** argv)
OK(senc_enclosure_get_header(enclosure, &header));
CHK(header.enclosed_media_count == 1);
OK(senc_enclosure_get_medium(enclosure, 0, &m));
- CHK(header.triangle_count ==
+ CHK(header.primitives_count ==
(header.is_infinite /* Outermost enclosure: NB_CYL_X*NB_CYL_Y cylinders */
? NB_CYL_X * NB_CYL_Y * CYL_TRG_COUNT
: (m == 0
diff --git a/src/test_senc_some_triangles.c b/src/test_senc_some_triangles.c
@@ -2712,7 +2712,7 @@ main(int argc, char** argv)
OK(senc_scene_get_vertices_count(scn, &count));
CHK(count == NB_CYL * CYL_VRTX_COUNT);
- OK(senc_scene_get_triangles_count(scn, &count));
+ OK(senc_scene_get_primitives_count(scn, &count));
CHK(count == NB_CYL * CYL_TRG_COUNT);
OK(senc_scene_get_enclosure_count(scn, &count));
@@ -2722,7 +2722,7 @@ main(int argc, char** argv)
struct senc_enclosure_header header;
OK(senc_scene_get_enclosure(scn, e, &enclosure));
OK(senc_enclosure_get_header(enclosure, &header));
- CHK(header.triangle_count ==
+ CHK(header.primitives_count ==
(e ? CYL_TRG_COUNT : NB_CYL * CYL_TRG_COUNT));
OK(senc_enclosure_ref_put(enclosure));
}
diff --git a/src/test_senc_undefined_medium.c b/src/test_senc_undefined_medium.c
@@ -1,327 +0,0 @@
-/* Copyright (C) |Meso|Star> 2016-2020 (contact@meso-star.com)
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* This test has been created using the sg3_geometry_dump_as_C_code feature
- * of star-geometry. It uses output from test_sg3_undefined_properties.
- * This test is similar to test_senc_many_enclosures that creates a huge
- * geometry by program. */
-
-#include "senc.h"
-#include "senc_s3d_helper.h"
-#include "test_senc_utils.h"
-
-#include <rsys/double3.h>
-
-#define SG3_UNDEFINED_PROPERTY UINT_MAX
-
-/* Dump of star-geometry 'front_undefined'. */
-static const unsigned front_undefined_vertices_count = 8;
-static const double front_undefined_vertices[24] =
-{
- 0.1, 0, 0,
- 1, 0, 0,
- 0, 1, 0,
- 1, 1, 0,
- 0, 0, 1.1,
- 1, 0, 1,
- 0, 1, 1,
- 1, 1.1, 1
-};
-static const unsigned front_undefined_triangles_count = 12;
-static const unsigned front_undefined_triangles[36] =
-{
- 0, 2, 1,
- 1, 2, 3,
- 0, 4, 2,
- 2, 4, 6,
- 4, 5, 6,
- 6, 5, 7,
- 3, 7, 1,
- 1, 7, 5,
- 2, 6, 3,
- 3, 6, 7,
- 0, 1, 4,
- 4, 1, 5
-};
-static const unsigned front_undefined_properties[36] =
-{
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY
-};
-/* Dump of star-geometry 'front_half_undefined'. */
-static const unsigned front_half_undefined_vertices_count = 8;
-static const double front_half_undefined_vertices[24] =
-{
- 0.1, 0, 0,
- 1, 0, 0,
- 0, 1, 0,
- 1, 1, 0,
- 0, 0, 1.1,
- 1, 0, 1,
- 0, 1, 1,
- 1, 1.1, 1
-};
-static const unsigned front_half_undefined_triangles_count = 12;
-static const unsigned front_half_undefined_triangles[36] =
-{
- 0, 2, 1,
- 1, 2, 3,
- 0, 4, 2,
- 2, 4, 6,
- 4, 5, 6,
- 6, 5, 7,
- 3, 7, 1,
- 1, 7, 5,
- 2, 6, 3,
- 3, 6, 7,
- 0, 1, 4,
- 4, 1, 5
-};
-static const unsigned front_half_undefined_properties[36] =
-{
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0,
- SG3_UNDEFINED_PROPERTY, 1, SG3_UNDEFINED_PROPERTY,
- 0, 1, 0
-};
-/* Dump of star-geometry 'all_defined'. */
-static const unsigned all_defined_vertices_count = 8;
-static const double all_defined_vertices[24] =
-{
- 0.1, 0, 0,
- 1, 0, 0,
- 0, 1, 0,
- 1, 1, 0,
- 0, 0, 1.1,
- 1, 0, 1,
- 0, 1, 1,
- 1, 1.1, 1
-};
-static const unsigned all_defined_triangles_count = 12;
-static const unsigned all_defined_triangles[36] =
-{
- 0, 2, 1,
- 1, 2, 3,
- 0, 4, 2,
- 2, 4, 6,
- 4, 5, 6,
- 6, 5, 7,
- 3, 7, 1,
- 1, 7, 5,
- 2, 6, 3,
- 3, 6, 7,
- 0, 1, 4,
- 4, 1, 5
-};
-static const unsigned all_defined_properties[36] =
-{
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0,
- 0, 1, 0
-};
-
-static void
-test(const int convention)
-{
- struct mem_allocator allocator;
- struct senc_device* dev = NULL;
- struct senc_scene* scn = NULL;
- struct senc_enclosure* enclosure;
- struct senc_enclosure_header header;
- unsigned medium, expected_external_medium, expected_internal_medium;
- unsigned gid;
- enum senc_side side;
- struct context ctx = CONTEXT_NULL__;
- unsigned i, t, ecount;
- const int conv_front = (convention & SENC_CONVENTION_NORMAL_FRONT) != 0;
-
- OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev));
-
- /* Geometry with no media information on both sides */
- ctx.positions = front_undefined_vertices;
- ctx.indices = front_undefined_triangles;
- ctx.properties = front_undefined_properties;
- OK(senc_scene_create(dev, convention, front_undefined_triangles_count,
- get_indices, get_media_from_properties, front_undefined_vertices_count,
- get_position, &ctx, &scn));
-
- OK(senc_scene_get_enclosure_count(scn, &ecount));
- CHK(ecount == 2);
-
- FOR_EACH(i, 0, ecount) {
- struct senc_enclosure* ee;
- struct senc_enclosure_header hh;
- unsigned cc;
- OK(senc_scene_get_enclosure(scn, i, &enclosure));
- OK(senc_enclosure_get_header(enclosure, &header));
-
- CHK(header.enclosure_id == i);
- CHK(header.enclosed_media_count == 1);
-
- OK(senc_enclosure_get_medium(enclosure, 0, &medium));
- /* Geometrical normals point outside the cube in input triangles:
- * if convention is front, front medium (undef) is outside,
- * that is medium 0's enclosure is infinite */
- expected_external_medium = conv_front ? SENC_UNDEFINED_MEDIUM : 1;
- expected_internal_medium = conv_front ? 1 :SENC_UNDEFINED_MEDIUM;
-
- CHK(medium == (header.is_infinite
- ? expected_external_medium : expected_internal_medium));
- CHK(header.triangle_count == ntriangles);
- CHK(header.unique_triangle_count == ntriangles);
- CHK(header.vertices_count == nvertices);
- CHK(header.is_infinite == (i == 0));
-
- OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc));
- CHK(cc == 1);
- OK(senc_scene_get_enclosure_by_medium(scn, medium, 0, &ee));
- OK(senc_enclosure_get_header(ee, &hh));
- CHK(header.enclosure_id == hh.enclosure_id);
- OK(senc_enclosure_ref_put(ee));
-
- FOR_EACH(t, 0, header.triangle_count) {
- unsigned ind[3];
- OK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side));
- CHK(gid == t);
- CHK(side == (medium == 1) ? SENC_BACK : SENC_FRONT);
- OK(senc_enclosure_get_triangle(enclosure, t, ind));
- }
- OK(senc_enclosure_ref_put(enclosure));
- }
- OK(senc_scene_ref_put(scn));
-
- /* Same geometry, front media are defined for odd triangles */
- ctx.positions = front_half_undefined_vertices;
- ctx.indices = front_half_undefined_triangles;
- ctx.properties = front_half_undefined_properties;
- OK(senc_scene_create(dev, convention, front_half_undefined_triangles_count,
- get_indices, get_media_from_properties, front_half_undefined_vertices_count,
- get_position, &ctx, &scn));
-
- OK(senc_scene_get_enclosure_count(scn, &ecount));
- CHK(ecount == 2);
-
- FOR_EACH(i, 0, ecount) {
- unsigned expected_external_media_count, expected_internal_media_count,
- expected_media_count;
- OK(senc_scene_get_enclosure(scn, i, &enclosure));
- OK(senc_enclosure_get_header(enclosure, &header));
-
- CHK(header.enclosure_id == i);
-
- OK(senc_enclosure_get_medium(enclosure, 0, &medium));
- /* Geometrical normals point outside the cube in input triangles:
- * if convention is front, front medium is outside and the enclosure
- * contains 2 media */
- expected_external_media_count = conv_front ? 2 : 1;
- expected_internal_media_count = conv_front ? 1 : 2;
- expected_media_count = header.is_infinite
- ? expected_external_media_count : expected_internal_media_count;
- CHK(header.enclosed_media_count == expected_media_count);
- OK(senc_enclosure_ref_put(enclosure));
- }
- OK(senc_scene_ref_put(scn));
-
- /* Same geometry, all media are defined */
- ctx.positions = all_defined_vertices;
- ctx.indices = all_defined_triangles;
- ctx.properties = all_defined_properties;
- OK(senc_scene_create(dev, convention, all_defined_triangles_count,
- get_indices, get_media_from_properties, all_defined_vertices_count,
- get_position, &ctx, &scn));
-
- OK(senc_scene_get_enclosure_count(scn, &ecount));
- CHK(ecount == 2);
-
- FOR_EACH(i, 0, ecount) {
- struct senc_enclosure* ee;
- struct senc_enclosure_header hh;
- unsigned cc;
- OK(senc_scene_get_enclosure(scn, i, &enclosure));
- OK(senc_enclosure_get_header(enclosure, &header));
-
- CHK(header.enclosure_id == i);
- CHK(header.enclosed_media_count == 1);
- OK(senc_enclosure_get_medium(enclosure, 0, &medium));
- /* Geometrical normals point outside the cube in input triangles:
- * if convention is front, front medium (0) is outside,
- * that is medium 0's enclosure is infinite */
- CHK(conv_front == ((medium == 0) == header.is_infinite));
- CHK(header.triangle_count == ntriangles);
- CHK(header.unique_triangle_count == ntriangles);
- CHK(header.vertices_count == nvertices);
- CHK(header.is_infinite == (i == 0));
-
- OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc));
- CHK(cc == 1);
- OK(senc_scene_get_enclosure_by_medium(scn, medium, 0, &ee));
- OK(senc_enclosure_get_header(ee, &hh));
- CHK(header.enclosure_id == hh.enclosure_id);
- OK(senc_enclosure_ref_put(ee));
-
- FOR_EACH(t, 0, header.triangle_count) {
- OK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side));
- CHK(gid == t);
- CHK(side == (medium == 1) ? SENC_BACK : SENC_FRONT);
- }
- OK(senc_enclosure_ref_put(enclosure));
- }
-
- SENC(scene_ref_put(scn));
- SENC(device_ref_put(dev));
-
- check_memory_allocator(&allocator);
- mem_shutdown_proxy_allocator(&allocator);
- CHK(mem_allocated_size() == 0);
-}
-
-int
-main(int argc, char** argv)
-{
- (void) argc, (void) argv;
- test(SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE);
- test(SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE);
- test(SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_OUTSIDE);
- test(SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_OUTSIDE);
- return 0;
-}
diff --git a/src/test_senc_unspecified_medium.c b/src/test_senc_unspecified_medium.c
@@ -0,0 +1,327 @@
+/* Copyright (C) |Meso|Star> 2016-2020 (contact@meso-star.com)
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This test has been created using the sg3_geometry_dump_as_C_code feature
+ * of star-geometry. It uses output from test_sg3_unspecified_properties.
+ * This test is similar to test_senc_many_enclosures that creates a huge
+ * geometry by program. */
+
+#include "senc.h"
+#include "senc_s3d_helper.h"
+#include "test_senc_utils.h"
+
+#include <rsys/double3.h>
+
+#define SG3_UNSPECIFED_PROPERTY UINT_MAX
+
+/* Dump of star-geometry 'front_unspecified'. */
+static const unsigned front_unspecified_vertices_count = 8;
+static const double front_unspecified_vertices[24] =
+{
+ 0.1, 0, 0,
+ 1, 0, 0,
+ 0, 1, 0,
+ 1, 1, 0,
+ 0, 0, 1.1,
+ 1, 0, 1,
+ 0, 1, 1,
+ 1, 1.1, 1
+};
+static const unsigned front_unspecified_triangles_count = 12;
+static const unsigned front_unspecified_triangles[36] =
+{
+ 0, 2, 1,
+ 1, 2, 3,
+ 0, 4, 2,
+ 2, 4, 6,
+ 4, 5, 6,
+ 6, 5, 7,
+ 3, 7, 1,
+ 1, 7, 5,
+ 2, 6, 3,
+ 3, 6, 7,
+ 0, 1, 4,
+ 4, 1, 5
+};
+static const unsigned front_unspecified_properties[36] =
+{
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY
+};
+/* Dump of star-geometry 'front_half_unspecified'. */
+static const unsigned front_half_unspecified_vertices_count = 8;
+static const double front_half_unspecified_vertices[24] =
+{
+ 0.1, 0, 0,
+ 1, 0, 0,
+ 0, 1, 0,
+ 1, 1, 0,
+ 0, 0, 1.1,
+ 1, 0, 1,
+ 0, 1, 1,
+ 1, 1.1, 1
+};
+static const unsigned front_half_unspecified_triangles_count = 12;
+static const unsigned front_half_unspecified_triangles[36] =
+{
+ 0, 2, 1,
+ 1, 2, 3,
+ 0, 4, 2,
+ 2, 4, 6,
+ 4, 5, 6,
+ 6, 5, 7,
+ 3, 7, 1,
+ 1, 7, 5,
+ 2, 6, 3,
+ 3, 6, 7,
+ 0, 1, 4,
+ 4, 1, 5
+};
+static const unsigned front_half_unspecified_properties[36] =
+{
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0,
+ SG3_UNSPECIFED_PROPERTY, 1, SG3_UNSPECIFED_PROPERTY,
+ 0, 1, 0
+};
+/* Dump of star-geometry 'all_defined'. */
+static const unsigned all_defined_vertices_count = 8;
+static const double all_defined_vertices[24] =
+{
+ 0.1, 0, 0,
+ 1, 0, 0,
+ 0, 1, 0,
+ 1, 1, 0,
+ 0, 0, 1.1,
+ 1, 0, 1,
+ 0, 1, 1,
+ 1, 1.1, 1
+};
+static const unsigned all_defined_triangles_count = 12;
+static const unsigned all_defined_triangles[36] =
+{
+ 0, 2, 1,
+ 1, 2, 3,
+ 0, 4, 2,
+ 2, 4, 6,
+ 4, 5, 6,
+ 6, 5, 7,
+ 3, 7, 1,
+ 1, 7, 5,
+ 2, 6, 3,
+ 3, 6, 7,
+ 0, 1, 4,
+ 4, 1, 5
+};
+static const unsigned all_defined_properties[36] =
+{
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0,
+ 0, 1, 0
+};
+
+static void
+test(const int convention)
+{
+ struct mem_allocator allocator;
+ struct senc_device* dev = NULL;
+ struct senc_scene* scn = NULL;
+ struct senc_enclosure* enclosure;
+ struct senc_enclosure_header header;
+ unsigned medium, expected_external_medium, expected_internal_medium;
+ unsigned gid;
+ enum senc_side side;
+ struct context ctx = CONTEXT_NULL__;
+ unsigned i, t, ecount;
+ const int conv_front = (convention & SENC_CONVENTION_NORMAL_FRONT) != 0;
+
+ OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
+ OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev));
+
+ /* Geometry with no media information on both sides */
+ ctx.positions = front_unspecified_vertices;
+ ctx.indices = front_unspecified_triangles;
+ ctx.properties = front_unspecified_properties;
+ OK(senc_scene_create(dev, convention, front_unspecified_triangles_count,
+ get_indices, get_media_from_properties, front_unspecified_vertices_count,
+ get_position, &ctx, &scn));
+
+ OK(senc_scene_get_enclosure_count(scn, &ecount));
+ CHK(ecount == 2);
+
+ FOR_EACH(i, 0, ecount) {
+ struct senc_enclosure* ee;
+ struct senc_enclosure_header hh;
+ unsigned cc;
+ OK(senc_scene_get_enclosure(scn, i, &enclosure));
+ OK(senc_enclosure_get_header(enclosure, &header));
+
+ CHK(header.enclosure_id == i);
+ CHK(header.enclosed_media_count == 1);
+
+ OK(senc_enclosure_get_medium(enclosure, 0, &medium));
+ /* Geometrical normals point outside the cube in input triangles:
+ * if convention is front, front medium (unspecified) is outside,
+ * that is medium 0's enclosure is infinite */
+ expected_external_medium = conv_front ? SENC_UNSPECIFIED_MEDIUM : 1;
+ expected_internal_medium = conv_front ? 1 : SENC_UNSPECIFIED_MEDIUM;
+
+ CHK(medium == (header.is_infinite
+ ? expected_external_medium : expected_internal_medium));
+ CHK(header.primitives_count == ntriangles);
+ CHK(header.unique_primitives_count == ntriangles);
+ CHK(header.vertices_count == nvertices);
+ CHK(header.is_infinite == (i == 0));
+
+ OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc));
+ CHK(cc == 1);
+ OK(senc_scene_get_enclosure_by_medium(scn, medium, 0, &ee));
+ OK(senc_enclosure_get_header(ee, &hh));
+ CHK(header.enclosure_id == hh.enclosure_id);
+ OK(senc_enclosure_ref_put(ee));
+
+ FOR_EACH(t, 0, header.primitives_count) {
+ unsigned ind[3];
+ OK(senc_enclosure_get_primitive_global_id(enclosure, t, &gid, &side));
+ CHK(gid == t);
+ CHK(side == (medium == 1) ? SENC_BACK : SENC_FRONT);
+ OK(senc_enclosure_get_primitive(enclosure, t, ind));
+ }
+ OK(senc_enclosure_ref_put(enclosure));
+ }
+ OK(senc_scene_ref_put(scn));
+
+ /* Same geometry, front media are defined for odd triangles */
+ ctx.positions = front_half_unspecified_vertices;
+ ctx.indices = front_half_unspecified_triangles;
+ ctx.properties = front_half_unspecified_properties;
+ OK(senc_scene_create(dev, convention, front_half_unspecified_triangles_count,
+ get_indices, get_media_from_properties, front_half_unspecified_vertices_count,
+ get_position, &ctx, &scn));
+
+ OK(senc_scene_get_enclosure_count(scn, &ecount));
+ CHK(ecount == 2);
+
+ FOR_EACH(i, 0, ecount) {
+ unsigned expected_external_media_count, expected_internal_media_count,
+ expected_media_count;
+ OK(senc_scene_get_enclosure(scn, i, &enclosure));
+ OK(senc_enclosure_get_header(enclosure, &header));
+
+ CHK(header.enclosure_id == i);
+
+ OK(senc_enclosure_get_medium(enclosure, 0, &medium));
+ /* Geometrical normals point outside the cube in input triangles:
+ * if convention is front, front medium is outside and the enclosure
+ * contains 2 media */
+ expected_external_media_count = conv_front ? 2 : 1;
+ expected_internal_media_count = conv_front ? 1 : 2;
+ expected_media_count = header.is_infinite
+ ? expected_external_media_count : expected_internal_media_count;
+ CHK(header.enclosed_media_count == expected_media_count);
+ OK(senc_enclosure_ref_put(enclosure));
+ }
+ OK(senc_scene_ref_put(scn));
+
+ /* Same geometry, all media are defined */
+ ctx.positions = all_defined_vertices;
+ ctx.indices = all_defined_triangles;
+ ctx.properties = all_defined_properties;
+ OK(senc_scene_create(dev, convention, all_defined_triangles_count,
+ get_indices, get_media_from_properties, all_defined_vertices_count,
+ get_position, &ctx, &scn));
+
+ OK(senc_scene_get_enclosure_count(scn, &ecount));
+ CHK(ecount == 2);
+
+ FOR_EACH(i, 0, ecount) {
+ struct senc_enclosure* ee;
+ struct senc_enclosure_header hh;
+ unsigned cc;
+ OK(senc_scene_get_enclosure(scn, i, &enclosure));
+ OK(senc_enclosure_get_header(enclosure, &header));
+
+ CHK(header.enclosure_id == i);
+ CHK(header.enclosed_media_count == 1);
+ OK(senc_enclosure_get_medium(enclosure, 0, &medium));
+ /* Geometrical normals point outside the cube in input triangles:
+ * if convention is front, front medium (0) is outside,
+ * that is medium 0's enclosure is infinite */
+ CHK(conv_front == ((medium == 0) == header.is_infinite));
+ CHK(header.primitives_count == ntriangles);
+ CHK(header.unique_primitives_count == ntriangles);
+ CHK(header.vertices_count == nvertices);
+ CHK(header.is_infinite == (i == 0));
+
+ OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc));
+ CHK(cc == 1);
+ OK(senc_scene_get_enclosure_by_medium(scn, medium, 0, &ee));
+ OK(senc_enclosure_get_header(ee, &hh));
+ CHK(header.enclosure_id == hh.enclosure_id);
+ OK(senc_enclosure_ref_put(ee));
+
+ FOR_EACH(t, 0, header.primitives_count) {
+ OK(senc_enclosure_get_primitive_global_id(enclosure, t, &gid, &side));
+ CHK(gid == t);
+ CHK(side == (medium == 1) ? SENC_BACK : SENC_FRONT);
+ }
+ OK(senc_enclosure_ref_put(enclosure));
+ }
+
+ SENC(scene_ref_put(scn));
+ SENC(device_ref_put(dev));
+
+ check_memory_allocator(&allocator);
+ mem_shutdown_proxy_allocator(&allocator);
+ CHK(mem_allocated_size() == 0);
+}
+
+int
+main(int argc, char** argv)
+{
+ (void) argc, (void) argv;
+ test(SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE);
+ test(SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE);
+ test(SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_OUTSIDE);
+ test(SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_OUTSIDE);
+ return 0;
+}
diff --git a/src/test_senc_utils.h b/src/test_senc_utils.h
@@ -150,7 +150,7 @@ dump_global
ASSERT(scn && name);
OK(senc_scene_get_vertices_count(scn, &vertices_count));
- OK(senc_scene_get_triangles_count(scn, &triangles_count));
+ OK(senc_scene_get_primitives_count(scn, &triangles_count));
stream = fopen(name, "w");
CHK(stream);
@@ -161,7 +161,7 @@ dump_global
}
FOR_EACH(i, 0, triangles_count) {
unsigned indices[3];
- OK(senc_scene_get_triangle(scn, i, indices));
+ OK(senc_scene_get_primitive(scn, i, indices));
fprintf(stream, "f %lu %lu %lu\n", (unsigned long)(1 + indices[0]),
(unsigned long)(1 + indices[1]), (unsigned long)(1 + indices[2]));
}
@@ -193,9 +193,9 @@ dump_enclosure
OK(senc_enclosure_get_vertex(enclosure, i, tmp));
fprintf(stream, "v %g %g %g\n", SPLIT3(tmp));
}
- FOR_EACH(i, 0, header.triangle_count) {
+ FOR_EACH(i, 0, header.primitives_count) {
unsigned indices[3];
- OK(senc_enclosure_get_triangle(enclosure, i, indices));
+ OK(senc_enclosure_get_primitive(enclosure, i, indices));
fprintf(stream, "f %lu %lu %lu\n", (unsigned long)(1+indices[0]),
(unsigned long)(1+indices[1]), (unsigned long)(1+indices[2]));
}
@@ -235,7 +235,7 @@ cmp_trg
ASSERT(enclosure && trg2 && vertices2 && trg_eq && trg_reversed);
- OK(senc_enclosure_get_triangle(enclosure, itri, trg1));
+ OK(senc_enclosure_get_primitive(enclosure, itri, trg1));
FOR_EACH(i, 0, 3) {
OK(senc_enclosure_get_vertex(enclosure, trg1[i], t1[i]));
d3_set(t2[i], vertices2 + (3 * trg2[i]));