star-enclosures-3d

Extract enclosures from 3D geometry
git clone git://git.meso-star.fr/star-enclosures-3d.git
Log | Files | Refs | README | LICENSE

commit b958cab12b9f92fc19dec632d7bc2d3cbf530f74
parent 89ecb45a6e8ce09b855a14125911db46a467c7f6
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Fri, 10 Jan 2020 18:08:22 +0100

Change most test according to new API

Diffstat:
Mcmake/CMakeLists.txt | 16++++++++++------
Msrc/senc.h | 5+++--
Msrc/senc_internal_types.h | 1+
Msrc/senc_scene_c.h | 5++---
Msrc/test_senc_cube_behind_cube.c | 169++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
Msrc/test_senc_cube_in_cube.c | 336++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Msrc/test_senc_cube_on_cube.c | 236+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Msrc/test_senc_device.c | 46+++++++++++++++++++++++-----------------------
Msrc/test_senc_enclosure.c | 247++++++++++++++++++++++++++++++++-----------------------------------------------
Msrc/test_senc_inconsistant_cube.c | 1-
Msrc/test_senc_many_enclosures.c | 174++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/test_senc_many_triangles.c | 131+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/test_senc_sample_enclosure.c | 6+++---
Msrc/test_senc_scene.c | 438++++++++++++++++++++++++++++++++++++++++---------------------------------------
Asrc/test_senc_some_enclosures.c | 3427+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/test_senc_some_triangles.c | 2737+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/test_senc_undefined_medium.c | 336+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Dsrc/test_senc_undefined_medium_attr.c | 376-------------------------------------------------------------------------------
Msrc/test_senc_utils.h | 23+++++++++++------------
19 files changed, 7419 insertions(+), 1291 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -39,8 +39,10 @@ include(rcmake_runtime) if(NO_TEST) rcmake_append_runtime_dirs(_runtime_dirs RSys Star3D) -else() -rcmake_append_runtime_dirs(_runtime_dirs RSys StarSP Star3DUT Star3D) + + if(ADDITIONAL_TESTS) + rcmake_append_runtime_dirs(_runtime_dirs RSys StarSP Star3DUT Star3D) + endif() endif() ################################################################################ @@ -120,11 +122,9 @@ if(NOT NO_TEST) register_test(${_name} ${_name}) endfunction() - new_test(test_senc_add_n_merge) new_test(test_senc_cube_behind_cube) new_test(test_senc_cube_in_cube) new_test(test_senc_cube_on_cube) - new_test(test_senc_descriptor) new_test(test_senc_device) new_test(test_senc_enclosure) new_test(test_senc_inconsistant_cube) @@ -132,13 +132,17 @@ if(NOT NO_TEST) new_test(test_senc_many_triangles) new_test(test_senc_sample_enclosure) 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_undefined_medium_attr) - target_link_libraries(test_senc_sample_enclosure StarSP) + target_link_libraries(test_senc_enclosure Star3D) + target_link_libraries(test_senc_sample_enclosure StarSP Star3D) target_link_libraries(test_senc_many_enclosures Star3DUT) target_link_libraries(test_senc_many_triangles Star3DUT) + rcmake_copy_runtime_libraries(test_senc_sample_enclosure) + rcmake_copy_runtime_libraries(test_senc_many_enclosures) rcmake_copy_runtime_libraries(test_senc_many_triangles) endif() diff --git a/src/senc.h b/src/senc.h @@ -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. */ + * imed_th medium or SENC_UNDEFINED_MEDIUM. */ SENC_API res_T senc_scene_get_enclosure_count_by_medium (const struct senc_scene* scene, @@ -246,7 +246,8 @@ senc_scene_get_enclosure const unsigned idx, struct senc_enclosure** enclosure); -/* Returns the idx_th enclosure using the imed_th medium. */ +/* Returns the idx_th enclosure using the imed_th medium or + * SENC_UNDEFINED_MEDIUM. */ SENC_API res_T senc_scene_get_enclosure_by_medium (struct senc_scene* scene, diff --git a/src/senc_internal_types.h b/src/senc_internal_types.h @@ -20,6 +20,7 @@ #include <rsys/math.h> +#include <stdio.h> #include <stdint.h> /* Utility macros */ diff --git a/src/senc_scene_c.h b/src/senc_scene_c.h @@ -88,12 +88,11 @@ set_edge { ASSERT(edge && reversed && vrtx0 != vrtx1); ASSERT(*reversed == UCHAR_MAX); /* Should not be already set. */ - if (vrtx0 < vrtx1) { + if(vrtx0 < vrtx1) { edge->vrtx0 = vrtx0; edge->vrtx1 = vrtx1; *reversed = 0; /* Non reversed edge */ - } - else { + } else { edge->vrtx0 = vrtx1; edge->vrtx1 = vrtx0; *reversed = 1; /* Reversed edge */ diff --git a/src/test_senc_cube_behind_cube.c b/src/test_senc_cube_behind_cube.c @@ -13,32 +13,36 @@ * 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_cube_behind_cube. */ + #include "senc.h" #include "test_senc_utils.h" #include <rsys/double3.h> - /* Dump of star-geometry 'cube_behind_cube_2'. */ +/* Dump of star-geometry 'cube_behind_cube_2'. */ +static const unsigned cube_behind_cube_2_vertices_count = 16; static const double cube_behind_cube_2_vertices[48] = { - 0.100000, 0.000000, 0.000000, - 1.000000, 0.000000, 0.000000, - 0.000000, 1.000000, 0.000000, - 1.000000, 1.000000, 0.000000, - 0.000000, 0.000000, 1.100000, - 1.000000, 0.000000, 1.000000, - 0.000000, 1.000000, 1.000000, - 1.000000, 1.100000, 1.000000, - -1.500000, -2.000000, 20.000000, - 3.000000, -2.000000, 20.000000, - -2.000000, 3.000000, 20.000000, - 3.000000, 3.000000, 20.000000, - -2.000000, -2.000000, 25.500000, - 3.000000, -2.000000, 25.000000, - -2.000000, 3.000000, 25.000000, - 3.000000, 3.500000, 25.000000 + 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, + -1.5, -2, 20, + 3, -2, 20, + -2, 3, 20, + 3, 3, 20, + -2, -2, 25.5, + 3, -2, 25, + -2, 3, 25, + 3, 3.5, 25 }; -static const unsigned cube_behind_cube_2_vertices_count = 16; +static const unsigned cube_behind_cube_2_triangles_count = 24; static const unsigned cube_behind_cube_2_triangles[72] = { 0, 2, 1, @@ -66,7 +70,6 @@ static const unsigned cube_behind_cube_2_triangles[72] = 8, 9, 12, 12, 9, 13 }; -static const unsigned cube_behind_cube_2_triangles_count = 24; static const unsigned cube_behind_cube_2_properties[72] = { 0, 1, 0, @@ -95,34 +98,35 @@ static const unsigned cube_behind_cube_2_properties[72] = 0, 1, 0 }; /* Dump of star-geometry 'cube_behind_cube_3'. */ +static const unsigned cube_behind_cube_3_vertices_count = 24; static const double cube_behind_cube_3_vertices[72] = { - 0.100000, 0.000000, 0.000000, - 1.000000, 0.000000, 0.000000, - 0.000000, 1.000000, 0.000000, - 1.000000, 1.000000, 0.000000, - 0.000000, 0.000000, 1.100000, - 1.000000, 0.000000, 1.000000, - 0.000000, 1.000000, 1.000000, - 1.000000, 1.100000, 1.000000, - -1.500000, -2.000000, 20.000000, - 3.000000, -2.000000, 20.000000, - -2.000000, 3.000000, 20.000000, - 3.000000, 3.000000, 20.000000, - -2.000000, -2.000000, 25.500000, - 3.000000, -2.000000, 25.000000, - -2.000000, 3.000000, 25.000000, - 3.000000, 3.500000, 25.000000, - -2.300000, -3.000000, 30.000000, - 4.000000, -3.000000, 30.000000, - -3.000000, 4.000000, 30.000000, - 4.000000, 4.000000, 30.000000, - -3.000000, -3.000000, 37.700000, - 4.000000, -3.000000, 37.000000, - -3.000000, 4.000000, 37.000000, - 4.000000, 4.700000, 37.000000 + 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, + -1.5, -2, 20, + 3, -2, 20, + -2, 3, 20, + 3, 3, 20, + -2, -2, 25.5, + 3, -2, 25, + -2, 3, 25, + 3, 3.5, 25, + -2.3, -3, 30, + 4, -3, 30, + -3, 4, 30, + 4, 4, 30, + -3, -3, 37.7, + 4, -3, 37, + -3, 4, 37, + 4, 4.7, 37 }; -static const unsigned cube_behind_cube_3_vertices_count = 24; +static const unsigned cube_behind_cube_3_triangles_count = 36; static const unsigned cube_behind_cube_3_triangles[108] = { 0, 2, 1, @@ -162,7 +166,6 @@ static const unsigned cube_behind_cube_3_triangles[108] = 16, 17, 20, 20, 17, 21 }; -static const unsigned cube_behind_cube_3_triangles_count = 36; static const unsigned cube_behind_cube_3_properties[108] = { 0, 1, 0, @@ -203,6 +206,33 @@ static const unsigned cube_behind_cube_3_properties[108] = 1, 0, 0 }; +/* + cube_2 cube_3 + + +-----------------------+ + | 3 + | | + m1 | m0 | + | | + | | + | | + | |--> N + | | + | | + +-----------------------+ + +------------+ +------------+ + | 2 | 2 + m0 | m1 | m0 | m1 | + | | | | + | |--> N | |--> N + | | | | + +------------+ +------------+ + +-----+ +-----+ + m0 | m1 1 m0 | m1 1 + | |--> N | |--> N + +-----+ +-----+ + */ + int main(int argc, char** argv) { @@ -213,61 +243,66 @@ main(int argc, char** argv) unsigned i, ecount, maxm; (void)argc, (void)argv; - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); - CHK(senc_device_create - (NULL, &allocator, 1, 1, &dev) == RES_OK); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, 1, 1, &dev)); - /* Create a scene with the first and second cubes */ + /* Create a scene with the first and second cubes. + * Both cubes have medium 1 inside and medium 0 outside, + * the second cube is +Z from the first cube and is big enough + * to prevent rays from the first cube to miss it. */ ctx.positions = cube_behind_cube_2_vertices; ctx.indices = cube_behind_cube_2_triangles; ctx.properties = cube_behind_cube_2_properties; - CHK(senc_scene_create(dev, + OK(senc_scene_create(dev, SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, cube_behind_cube_2_triangles_count, get_indices, get_media_from_properties, - cube_behind_cube_2_vertices_count, get_position, &ctx, &scn) == RES_OK); + cube_behind_cube_2_vertices_count, get_position, &ctx, &scn)); - CHK(senc_scene_get_enclosure_count(scn, &ecount) == RES_OK); + OK(senc_scene_get_enclosure_count(scn, &ecount)); CHK(ecount == 3); FOR_EACH(i, 0, ecount) { struct senc_enclosure* enclosure; struct senc_enclosure_header header; - CHK(senc_scene_get_enclosure(scn, i, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, i, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); ASSERT(header.enclosed_media_count == 1); - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_ref_put(enclosure)); } - CHK(senc_scene_get_max_medium(scn, &maxm) == RES_OK); + OK(senc_scene_get_max_medium(scn, &maxm)); CHK(maxm == 1); - CHK(senc_scene_ref_put(scn) == RES_OK); + OK(senc_scene_ref_put(scn)); - /* Create a scene with the 3 cubes */ + /* Create a scene with the 3 cubes, same 2 first cubes as above + * The third cube has medium 0 inside and medium 1 outside and is further + * in +Z and bigger */ ctx.positions = cube_behind_cube_3_vertices; ctx.indices = cube_behind_cube_3_triangles; ctx.properties = cube_behind_cube_3_properties; - CHK(senc_scene_create(dev, + OK(senc_scene_create(dev, SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, cube_behind_cube_3_triangles_count, get_indices, get_media_from_properties, - cube_behind_cube_3_vertices_count, get_position, &ctx, &scn) == RES_OK); + cube_behind_cube_3_vertices_count, get_position, &ctx, &scn)); - CHK(senc_scene_get_enclosure_count(scn, &ecount) == RES_OK); + OK(senc_scene_get_enclosure_count(scn, &ecount)); CHK(ecount == 4); FOR_EACH(i, 0, ecount) { struct senc_enclosure* enclosure; struct senc_enclosure_header header; - CHK(senc_scene_get_enclosure(scn, i, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, i, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); + /* Inside enclosures contain 1 single media */ ASSERT(header.enclosed_media_count == (header.is_infinite ? 2u : 1u)); - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_ref_put(enclosure)); } - CHK(senc_scene_get_max_medium(scn, &maxm) == RES_OK); + OK(senc_scene_get_max_medium(scn, &maxm)); CHK(maxm == 1); - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); diff --git a/src/test_senc_cube_in_cube.c b/src/test_senc_cube_in_cube.c @@ -13,101 +13,299 @@ * 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_cube_in_cube. */ + #include "senc.h" #include "test_senc_utils.h" #include <rsys/double3.h> +/* + cube_2 cube_3 + + +-------------------------+ + | B + +-------------+ | +-------------+ | + m1 | m0 M m1 | m1 | m0 M | + | +------+ | | m0 | +------+ | | + | | m1 S | | | | m1 S | | + | | N <--| | | | | N <--| | | + | +------+ | | | +------+ | | + | N <--| | | N <--| | + +-------------+ | +-------------+ | + | N <--| + +-------------------------+ + */ + + +/* Dump of star-geometry 'cube_in_cube_2'. */ +static const unsigned cube_in_cube_2_vertices_count = 16; +static const double cube_in_cube_2_vertices[48] = +{ + 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, + -0.7, -1, -1, + 2, -1, -1, + -1, 2, -1, + 2, 2, -1, + -1, -1, 2.3, + 2, -1, 2, + -1, 2, 2, + 2, 2.3, 2 +}; +static const unsigned cube_in_cube_2_triangles_count = 24; +static const unsigned cube_in_cube_2_triangles[72] = +{ + 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, + 8, 9, 10, + 9, 11, 10, + 8, 10, 12, + 10, 14, 12, + 12, 14, 13, + 14, 15, 13, + 11, 9, 15, + 9, 13, 15, + 10, 11, 14, + 11, 15, 14, + 8, 12, 9, + 12, 13, 9 +}; +static const unsigned cube_in_cube_2_properties[72] = +{ + 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, + 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 +}; +/* Dump of star-geometry 'cube_in_cube_3'. */ +static const unsigned cube_in_cube_3_vertices_count = 24; +static const double cube_in_cube_3_vertices[72] = +{ + 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, + -0.7, -1, -1, + 2, -1, -1, + -1, 2, -1, + 2, 2, -1, + -1, -1, 2.3, + 2, -1, 2, + -1, 2, 2, + 2, 2.3, 2, + -3, -4, -4, + 6, -4, -4, + -4, 6, -4, + 6, 6, -4, + -4, -4, 7, + 6, -4, 6, + -4, 6, 6, + 6, 7, 6 +}; +static const unsigned cube_in_cube_3_triangles_count = 36; +static const unsigned cube_in_cube_3_triangles[108] = +{ + 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, + 8, 9, 10, + 9, 11, 10, + 8, 10, 12, + 10, 14, 12, + 12, 14, 13, + 14, 15, 13, + 11, 9, 15, + 9, 13, 15, + 10, 11, 14, + 11, 15, 14, + 8, 12, 9, + 12, 13, 9, + 16, 17, 18, + 17, 19, 18, + 16, 18, 20, + 18, 22, 20, + 20, 22, 21, + 22, 23, 21, + 19, 17, 23, + 17, 21, 23, + 18, 19, 22, + 19, 23, 22, + 16, 20, 17, + 20, 21, 17 +}; +static const unsigned cube_in_cube_3_properties[108] = +{ + 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, + 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, + 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 +}; + int main(int argc, char** argv) { struct mem_allocator allocator; - struct descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct context ctx = CONTEXT_NULL__; - unsigned i, ecount, maxm; + unsigned e, ecount, maxm, e2; (void)argc, (void)argv; - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); - CHK(senc_device_create - (NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) == RES_OK); - - /* Create the scene */ - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - - ctx.positions = box_vertices; - ctx.indices = box_indices; - ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; - d3(ctx.offset, 0, 0, 0); - /* Smallest cube exterior is medium 0 */ - ctx.front_media = medium0; - /* Smallest cube interior is medium 1 */ - ctx.back_media = medium1; - - /* First cube */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - d3(ctx.offset, -1, -1, -1); - ctx.scale = 3; - /* Bigger cube exterior is medium 1 */ - /* Bigger cube interior is medium 0 */ - ctx.reverse_vrtx = 1; - - /* Second cube */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - CHK(senc_scene_analyze(scn, &desc) == RES_OK); - - CHK(senc_descriptor_get_enclosure_count(desc, &ecount) == RES_OK); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); + + /* Create a scene with the first and second cubes. + * The enclosure in the small contains medium 1, the external enclosure + * contains medium 1, the enclosure between the small and medium cubes + * contains medium 0. */ + ctx.positions = cube_in_cube_2_vertices; + ctx.indices = cube_in_cube_2_triangles; + ctx.properties = cube_in_cube_2_properties; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + cube_in_cube_2_triangles_count, get_indices, get_media_from_properties, + cube_in_cube_2_vertices_count, get_position, &ctx, &scn)); + + OK(senc_scene_get_enclosure_count(scn, &ecount)); CHK(ecount == 3); - FOR_EACH(i, 0, ecount) { + FOR_EACH(e, 0, ecount) { struct senc_enclosure* enclosure; struct senc_enclosure_header header; - CHK(senc_descriptor_get_enclosure(desc, i, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + unsigned m; + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); ASSERT(header.enclosed_media_count == 1); - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_get_medium(enclosure, 0, &m)); + ASSERT(m <= 1); + ASSERT((m == 0) == (header.triangle_count == cube_in_cube_2_triangles_count)); + OK(senc_enclosure_ref_put(enclosure)); } - CHK(senc_descriptor_get_max_medium(desc, &maxm) == RES_OK); + OK(senc_scene_get_max_medium(scn, &maxm)); CHK(maxm == 1); - check_desc(desc); - - d3(ctx.offset, -4, -4, -4); - ctx.scale = 10; - ctx.reverse_vrtx = 1; - ctx.reverse_med = 1; - /* Biggest cube exterior is medium 1 */ - ctx.front_media = medium1; - /* Biggest cube interior is medium 0 - * interior/exterior media have been exchanged: external enclosure shows 2 media */ - ctx.back_media = medium0; - - /* Third cube */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - if(desc) CHK(senc_descriptor_ref_put(desc) == RES_OK); - desc = NULL; - CHK(senc_scene_analyze(scn, &desc) == RES_OK); - - CHK(senc_descriptor_get_enclosure_count(desc, &ecount) == RES_OK); + OK(senc_scene_ref_put(scn)); + + /* Create a scene with the 3 cubes, same 2 first cubes as above. + * The enclosure in the small cube contains medium 1, the external enclosure + * contains medium 1, the enclosure between the small and medium cubes + * contains medium 0 and the enclosure between the medium and big cubes + * contains both media 0 and 1. */ + ctx.positions = cube_in_cube_3_vertices; + ctx.indices = cube_in_cube_3_triangles; + ctx.properties = cube_in_cube_3_properties; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + cube_in_cube_3_triangles_count, get_indices, get_media_from_properties, + cube_in_cube_3_vertices_count, get_position, &ctx, &scn)); + + OK(senc_scene_get_enclosure_count(scn, &ecount)); CHK(ecount == 4); - CHK(senc_descriptor_get_max_medium(desc, &maxm) == RES_OK); + e2 = ecount; + FOR_EACH(e, 0, ecount) { + struct senc_enclosure* enclosure; + struct senc_enclosure_header header; + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); + ASSERT(header.enclosed_media_count <= 2); + if(header.enclosed_media_count == 2) { + /* A single internal enclosure has 2 media */ + ASSERT(!header.is_infinite); + ASSERT(e2 == ecount); + e2 = e; + } + OK(senc_enclosure_ref_put(enclosure)); + } + + OK(senc_scene_get_max_medium(scn, &maxm)); CHK(maxm == 1); - check_desc(desc); - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); - if(desc) CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); diff --git a/src/test_senc_cube_on_cube.c b/src/test_senc_cube_on_cube.c @@ -13,6 +13,9 @@ * 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_cube_on_cube. */ + #define _POSIX_C_SOURCE 200112L /* snprintf */ #include "senc.h" @@ -22,107 +25,176 @@ #include <stdio.h> -/* - Z - ^ -4 | +-----------------------+ - | | 3 -3 | | +-----+ | - | m2 | m1 | m0 2 | - | | | | | -2 | | +-----+ | - | | | m0 1 | - | | | | | -1 | | +-----+ | - | | | -0 - +-----------------------+ - - |--------------------------> X / Y - 0 1 2 3 4 -*/ +/* + +-----------------------+ + | 3 + | +------+ | + m2 | m1 | m0 2 | + | | |--> N | + | +------+ | + | | m0 1 | + | | |--> N | + | +------+ | + |--> N | + +-----------------------+ + */ + +/* Dump of star-geometry 'cube_on_cube'. */ +static const unsigned cube_on_cube_vertices_count = 20; +static const double cube_on_cube_vertices[60] = +{ + 1, 1, 2, + 2, 1, 2, + 1, 2, 2, + 2, 2, 2, + 1, 1, 3, + 2, 1, 3, + 1, 2, 3, + 2, 2, 3, + 1, 1, 1, + 2, 1, 1, + 1, 2, 1, + 2, 2, 1, + 0.4, 0, 0, + 4, 0, 0, + 0, 4, 0, + 4, 4, 0, + 0, 0, 4.4, + 4, 0, 4, + 0, 4, 4, + 4, 4.4, 4 +}; +static const unsigned cube_on_cube_triangles_count = 34; +static const unsigned cube_on_cube_triangles[102] = +{ + 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, + 8, 10, 9, + 9, 10, 11, + 8, 0, 10, + 10, 0, 2, + 11, 3, 9, + 9, 3, 1, + 10, 2, 11, + 11, 2, 3, + 8, 9, 0, + 0, 9, 1, + 12, 13, 14, + 13, 15, 14, + 12, 14, 16, + 14, 18, 16, + 16, 18, 17, + 18, 19, 17, + 15, 13, 19, + 13, 17, 19, + 14, 15, 18, + 15, 19, 18, + 12, 16, 13, + 16, 17, 13 +}; +static const unsigned cube_on_cube_properties[102] = +{ + 0, 0, 0, + 0, 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, 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, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0 +}; int main(int argc, char** argv) { struct mem_allocator allocator; - struct descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct context ctx = CONTEXT_NULL__; - unsigned count, i; + unsigned count, e; (void)argc, (void)argv; - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); - CHK(senc_device_create - (NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) == RES_OK); - - /* Create the scene */ - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - - ctx.positions = cube_vertices; /* Need true cubes for cubes #1 and #2 */ - ctx.indices = box_indices; - ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; - d3(ctx.offset, 1, 1, 2); - /* Small cube #1 exterior is medium 1, - * except for the top face where it is 0 */ - ctx.front_media = medium1_front0; - /* Smallest cube interior is medium 0 */ - ctx.back_media = medium0; - - /* Add cube #1 */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - d3(ctx.offset, 1, 1, 1); - ctx.scale = 1; - /* Small cube #2 exterior is medium 1, - * except for the bottom face where it is 0 */ - ctx.front_media = medium1_back0; - /* Smallest cube interior is medium 0 */ - ctx.back_media = medium0; - - /* Add cube #2 (has a duplicate face with cube #1) */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - ctx.positions = box_vertices; /* Can use distorded cube for cube #3 */ - d3(ctx.offset, 0, 0, 0); - ctx.scale = 4; - ctx.reverse_vrtx = 1; - ctx.reverse_med = 1; - /* Big cube #3 exterior is medium 2 */ - ctx.front_media = medium2; - /* Big cube #3 interior is medium 1 */ - ctx.back_media = medium1; - - /* Add cube #3 */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - CHK(senc_scene_analyze(scn, &desc) == RES_OK); - - CHK(senc_descriptor_get_enclosure_count(desc, &count) == RES_OK); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); + + /* Create a scene with the cubes. + * The enclosures in the small cubes contain medium 0, the external enclosure + * contains medium 2, the enclosure between the small and big cubes + * contains medium 1. */ + ctx.positions = cube_on_cube_vertices; + ctx.indices = cube_on_cube_triangles; + ctx.properties = cube_on_cube_properties; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + cube_on_cube_triangles_count, get_indices, get_media_from_properties, + cube_on_cube_vertices_count, get_position, &ctx, &scn)); + + OK(senc_scene_get_enclosure_count(scn, &count)); CHK(count == 4); - CHK(senc_descriptor_get_vertices_count(desc, &count) == RES_OK); + OK(senc_scene_get_vertices_count(scn, &count)); CHK(count == 20); - CHK(senc_descriptor_get_triangles_count(desc, &count) == RES_OK); + OK(senc_scene_get_triangles_count(scn, &count)); CHK(count == 34); - CHK(senc_descriptor_get_enclosure_count(desc, &count) == RES_OK); - FOR_EACH(i, 0, count) { + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 4); + FOR_EACH(e, 0, count) { + struct senc_enclosure* enclosure; + struct senc_enclosure_header header; + unsigned m; char name[128]; - snprintf(name, sizeof(name), "test_cube_on_cube_%u.obj", i); - dump_enclosure(desc, i, name); + snprintf(name, sizeof(name), "test_cube_on_cube_%u.obj", e); + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); + 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 ASSERT(m == 1); /* In between */ + OK(senc_enclosure_ref_put(enclosure)); + dump_enclosure(scn, e, name); } - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); - if(desc) CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); diff --git a/src/test_senc_device.c b/src/test_senc_device.c @@ -18,6 +18,8 @@ #include <rsys/logger.h> +#include <stdio.h> + static INLINE void log_stream(const char* msg, void* ctx) { @@ -34,40 +36,38 @@ main(int argc, char** argv) struct senc_device* dev; (void)argc, (void)argv; - CHK(senc_device_create(NULL, NULL, 0, 0, NULL) == RES_BAD_ARG); - CHK(senc_device_create(NULL, NULL, 0, 0, &dev) == RES_BAD_ARG); - CHK(senc_device_create(NULL, NULL, 1, 0, &dev) == RES_OK); - CHK(senc_device_ref_get(NULL) == RES_BAD_ARG); - CHK(senc_device_ref_get(dev) == RES_OK); - CHK(senc_device_ref_put(NULL) == RES_BAD_ARG); - CHK(senc_device_ref_put(dev) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + BA(senc_device_create(NULL, NULL, 0, 0, NULL)); + BA(senc_device_create(NULL, NULL, 0, 0, &dev)); + OK(senc_device_create(NULL, NULL, 1, 0, &dev)); + BA(senc_device_ref_get(NULL)); + OK(senc_device_ref_get(dev)); + BA(senc_device_ref_put(NULL)); + OK(senc_device_ref_put(dev)); + OK(senc_device_ref_put(dev)); - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) - == RES_OK); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); CHK(MEM_ALLOCATED_SIZE(&allocator) == 0); - CHK(senc_device_create(NULL, &allocator, 1, 0, NULL) == RES_BAD_ARG); - CHK(senc_device_create(NULL, &allocator, 1, 0, &dev) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + BA(senc_device_create(NULL, &allocator, 1, 0, NULL)); + OK(senc_device_create(NULL, &allocator, 1, 0, &dev)); + OK(senc_device_ref_put(dev)); CHK(MEM_ALLOCATED_SIZE(&allocator) == 0); - CHK(logger_init(&allocator, &logger) == RES_OK); + OK(logger_init(&allocator, &logger)); logger_set_stream(&logger, LOG_OUTPUT, log_stream, NULL); logger_set_stream(&logger, LOG_ERROR, log_stream, NULL); logger_set_stream(&logger, LOG_WARNING, log_stream, NULL); - CHK(senc_device_create(&logger, NULL, 1, 0, NULL) == RES_BAD_ARG); - CHK(senc_device_create(&logger, NULL, 1, 0, &dev) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + BA(senc_device_create(&logger, NULL, 1, 0, NULL)); + OK(senc_device_create(&logger, NULL, 1, 0, &dev)); + OK(senc_device_ref_put(dev)); - CHK(senc_device_create(&logger, &allocator, 1, 0, NULL) == RES_BAD_ARG); - CHK(senc_device_create(&logger, &allocator, 1, 0, &dev) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + BA(senc_device_create(&logger, &allocator, 1, 0, NULL)); + OK(senc_device_create(&logger, &allocator, 1, 0, &dev)); + OK(senc_device_ref_put(dev)); - CHK(senc_device_create - (&logger, &allocator, SENC_NTHREADS_DEFAULT, 0, &dev) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); + OK(senc_device_create(&logger, &allocator, SENC_NTHREADS_DEFAULT, 0, &dev)); + OK(senc_device_ref_put(dev)); logger_release(&logger); check_memory_allocator(&allocator); diff --git a/src/test_senc_enclosure.c b/src/test_senc_enclosure.c @@ -14,7 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "senc.h" -#include "senc_s3d_wrapper.h" +#include "senc_s3d_helper.h" #include "test_senc_utils.h" #include <rsys/double3.h> @@ -25,7 +25,6 @@ static void test(const int convention) { struct mem_allocator allocator; - struct descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct senc_enclosure* enclosures[2] = { NULL, NULL }; @@ -41,132 +40,94 @@ test(const int convention) enum senc_side side; double vrtx[3]; struct context ctx = CONTEXT_NULL__; - unsigned i, n, t, ecount; + unsigned i, n, t, count; int conv; const int conv_front = (convention & SENC_CONVENTION_NORMAL_FRONT) != 0; const int conv_in = (convention & SENC_CONVENTION_NORMAL_INSIDE) != 0; - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); - CHK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) - == RES_OK); - - CHK(senc_scene_create(dev, convention, &scn) == RES_OK); - - CHK(senc_scene_get_convention(scn, &conv) == RES_OK); - CHK(conv == convention); - - s3d_attribs.type = S3D_FLOAT3; - s3d_attribs.usage = S3D_POSITION; - s3d_attribs.get = senc_enclosure_get_vertex__; - - CHK(s3d_device_create(NULL, &allocator, 0, &s3d) == RES_OK); - - CHK(s3d_scene_create(s3d, &s3d_scn) == RES_OK); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); /* A 3D cube. * 2 enclosures (inside, outside) sharing the same triangles, * but opposite sides */ ctx.positions = box_vertices; ctx.indices = box_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; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); + OK(senc_scene_create(dev, convention, ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + OK(senc_scene_get_convention(scn, &conv)); + CHK(conv == convention); - CHK(senc_descriptor_get_enclosure_count(desc, &ecount) == RES_OK); - CHK(ecount == 2); + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 2); - CHK(senc_descriptor_get_enclosure(desc, 0, &enclosure) == RES_OK); - CHK(senc_enclosure_ref_get(NULL) == RES_BAD_ARG); - CHK(senc_enclosure_ref_get(enclosure) == RES_OK); - CHK(senc_enclosure_ref_put(NULL) == RES_BAD_ARG); - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); - - CHK(senc_enclosure_get_triangle(NULL, 0, indices[0]) == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(enclosure, ntriangles, indices[0]) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(enclosure, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(NULL, ntriangles, indices[0]) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(enclosure, ntriangles, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(NULL, ntriangles, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle(enclosure, 0, indices[0]) == RES_OK); - - CHK(senc_enclosure_get_vertex(NULL, 0, vrtx) == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(enclosure, nvertices, vrtx) - == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(enclosure, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(NULL, nvertices, vrtx) == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(enclosure, nvertices, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(NULL, nvertices, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_vertex(enclosure, 0, vrtx) == RES_OK); - - CHK(senc_enclosure_get_triangle_global_id(NULL, 0, &gid, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, &gid, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, 0, NULL, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, ntriangles, &gid, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, 0, NULL, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, NULL, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, ntriangles, NULL, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, 0, &gid, NULL) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, 0, &gid, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, &gid, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, 0, NULL, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, ntriangles, &gid, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, 0, NULL, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, ntriangles, NULL, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(NULL, ntriangles, NULL, &side) - == RES_BAD_ARG); - CHK(senc_enclosure_get_triangle_global_id(enclosure, 0, &gid, &side) - == RES_OK); - - CHK(senc_enclosure_get_medium(NULL, 0, &medium) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(enclosure, 2, &medium) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(enclosure, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(NULL, 2, &medium) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(enclosure, 2, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(NULL, 2, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_medium(enclosure, 0, &medium) == RES_OK); - - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); - - FOR_EACH(i, 0, ecount) { - CHK(senc_descriptor_get_enclosure(desc, i, &enclosure) == RES_OK); - - CHK(senc_enclosure_get_header(NULL, &header) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(enclosure, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(NULL, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, 0, &enclosure)); + BA(senc_enclosure_ref_get(NULL)); + OK(senc_enclosure_ref_get(enclosure)); + 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_vertex(NULL, 0, vrtx)); + BA(senc_enclosure_get_vertex(enclosure, nvertices, vrtx)); + BA(senc_enclosure_get_vertex(enclosure, 0, NULL)); + BA(senc_enclosure_get_vertex(NULL, nvertices, vrtx)); + BA(senc_enclosure_get_vertex(NULL, 0, NULL)); + BA(senc_enclosure_get_vertex(enclosure, nvertices, NULL)); + 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_medium(NULL, 0, &medium)); + BA(senc_enclosure_get_medium(enclosure, 2, &medium)); + BA(senc_enclosure_get_medium(enclosure, 0, NULL)); + BA(senc_enclosure_get_medium(NULL, 2, &medium)); + BA(senc_enclosure_get_medium(NULL, 0, NULL)); + BA(senc_enclosure_get_medium(enclosure, 2, NULL)); + BA(senc_enclosure_get_medium(NULL, 2, NULL)); + OK(senc_enclosure_get_medium(enclosure, 0, &medium)); + + OK(senc_enclosure_ref_put(enclosure)); + + FOR_EACH(i, 0, count) { + OK(senc_scene_get_enclosure(scn, i, &enclosure)); + + BA(senc_enclosure_get_header(NULL, &header)); + BA(senc_enclosure_get_header(enclosure, NULL)); + BA(senc_enclosure_get_header(NULL, NULL)); + OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.enclosure_id == i); CHK(header.enclosed_media_count == 1); - CHK(senc_enclosure_get_medium(enclosure, 0, &medium) == RES_OK); + 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 */ @@ -177,21 +138,21 @@ test(const int convention) CHK(header.is_infinite == (i == 0)); FOR_EACH(t, 0, header.triangle_count) { - CHK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side) == RES_OK); + OK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side)); CHK(gid == t); CHK(side == (medium == 0) ? SENC_FRONT : SENC_BACK); } - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_ref_put(enclosure)); } FOR_EACH(i, 0, 2) - CHK(senc_descriptor_get_enclosure(desc, i, enclosures + i) == RES_OK); + OK(senc_scene_get_enclosure(scn, i, enclosures + i)); FOR_EACH(n, 0, ntriangles) { int same, reversed; /* Read same triangles in both enclosures */ FOR_EACH(i, 0, 2) - CHK(senc_enclosure_get_triangle(enclosures[i], n, indices[i]) == RES_OK); + OK(senc_enclosure_get_triangle(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). @@ -204,39 +165,35 @@ test(const int convention) CHK(same && reversed == conv_in); } FOR_EACH(i, 0, 2) - CHK(senc_enclosure_ref_put(enclosures[i]) == RES_OK); + OK(senc_enclosure_ref_put(enclosures[i])); - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); /* Same 3D cube, but with a hole (incomplete). * 1 single enclosure including both sides of triangles */ - CHK(senc_scene_create(dev, convention, &scn) == RES_OK); - ctx.positions = box_vertices; ctx.indices = box_indices; - ctx.scale = 1; - d3(ctx.offset, 0, 0, 0); ctx.front_media = medium0; ctx.back_media = medium1; - CHK(senc_scene_add_geometry(scn, ntriangles - 1, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); + OK(senc_scene_create(dev, convention, ntriangles - 1, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + OK(senc_scene_get_frontier_segments_count(scn, &count)); + CHK(count == 3); - CHK(senc_descriptor_get_enclosure_count(desc, &ecount) == RES_OK); - CHK(ecount == 1); + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 1); - dump_enclosure(desc, 0, "test_enclosure_hole.obj"); + dump_enclosure(scn, 0, "test_enclosure_hole.obj"); - CHK(senc_descriptor_get_enclosure(desc, 0, &enclosure) == RES_OK); + OK(senc_scene_get_enclosure(scn, 0, &enclosure)); - CHK(senc_enclosure_get_header(NULL, &header) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(enclosure, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(NULL, NULL) == RES_BAD_ARG); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + BA(senc_enclosure_get_header(NULL, &header)); + BA(senc_enclosure_get_header(enclosure, NULL)); + BA(senc_enclosure_get_header(NULL, NULL)); + OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.enclosure_id == 0); CHK(header.enclosed_media_count == 2); @@ -246,32 +203,30 @@ test(const int convention) CHK(header.is_infinite == 1); FOR_EACH(t, 0, header.triangle_count) { - CHK(senc_enclosure_get_triangle_global_id(enclosure, t, &gid, &side) == RES_OK); + OK(senc_enclosure_get_triangle_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); } - FOR_EACH(n, 0, header.unique_triangle_count) { - /* Put geometry in a 3D view */ - CHK(s3d_shape_create_mesh(s3d, &s3d_shp) == RES_OK); - - CHK(s3d_mesh_setup_indexed_vertices(s3d_shp, header.triangle_count, - senc_enclosure_get_triangle__, header.vertices_count, &s3d_attribs, - 1, enclosure) - == RES_OK); - - CHK(s3d_scene_attach_shape(s3d_scn, s3d_shp) == RES_OK); - S3D(shape_ref_put(s3d_shp)); - } - + /* Put geometry in a 3D view using helper functions */ + s3d_attribs.type = S3D_FLOAT3; + s3d_attribs.usage = S3D_POSITION; + s3d_attribs.get = senc_s3d_enclosure_get_position__; + 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, + senc_s3d_enclosure_get_indices__, header.vertices_count, &s3d_attribs, + 1, enclosure)); + OK(s3d_scene_attach_shape(s3d_scn, s3d_shp)); + S3D(shape_ref_put(s3d_shp)); S3D(device_ref_put(s3d)); S3D(scene_ref_put(s3d_scn)); SENC(scene_ref_put(scn)); SENC(device_ref_put(dev)); - SENC(descriptor_ref_put(desc)); SENC(enclosure_ref_put(enclosure)); check_memory_allocator(&allocator); diff --git a/src/test_senc_inconsistant_cube.c b/src/test_senc_inconsistant_cube.c @@ -14,7 +14,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "senc.h" -#include "senc_s3d_wrapper.h" #include "test_senc_utils.h" #include <rsys/double3.h> diff --git a/src/test_senc_many_enclosures.c b/src/test_senc_many_enclosures.c @@ -13,159 +13,171 @@ * 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 is similar to test_senc_some_enclosures, but involves 64*64*64 + * cylinders instead of 4*4*4, thus making it impossible to define the geometry + * through static arrays. */ + #include "senc.h" #include "test_senc_utils.h" #include <star/s3dut.h> -#include <rsys/double3.h> #include <rsys/clock_time.h> +#include <rsys/double3.h> +#include <stdio.h> #include <limits.h> +#define NB_CYL_X 64 +#define NB_CYL_Y 64 +#define NB_CYL_Z 64 +#define NB_CYL (NB_CYL_X * NB_CYL_Y * NB_CYL_Z) + struct s3dut_context { struct s3dut_mesh_data data; - struct context ctx = CONTEXT_NULL__; + struct context ctx; }; static void get_s3dut_indices(const unsigned itri, unsigned ids[3], void* context) { struct s3dut_context* ctx = context; + unsigned s3dut_itri, cyl_idx, v_offset; ASSERT(ids && ctx); - ASSERT(itri < ctx->data.nprimitives); - ASSERT(ctx->data.indices[itri * 3 + 0] < UINT_MAX - && ctx->data.indices[itri * 3 + 1] < UINT_MAX - && ctx->data.indices[itri * 3 + 2] < UINT_MAX); - ids[0] = (unsigned)ctx->data.indices[itri * 3 + 0]; - ids[ctx->ctx.reverse_vrtx ? 2 : 1] = (unsigned)ctx->data.indices[itri * 3 + 1]; - ids[ctx->ctx.reverse_vrtx ? 1 : 2] = (unsigned)ctx->data.indices[itri * 3 + 2]; + ASSERT(itri < NB_CYL * ctx->data.nprimitives); + /* Get cyl_idx along with the s3dut vertice index */ + s3dut_itri = itri % (unsigned)ctx->data.nprimitives; + cyl_idx = itri / (unsigned)ctx->data.nprimitives; + ASSERT(ctx->data.indices[s3dut_itri * 3 + 0] <= UINT_MAX + && ctx->data.indices[s3dut_itri * 3 + 1] <= UINT_MAX + && ctx->data.indices[s3dut_itri * 3 + 2] <= UINT_MAX); + /* Compute the vertex index in the user numbering + * from cyl_idx and s3dut data; vertex related getters + * will have to get the s3dut index back */ + v_offset = cyl_idx * (unsigned)ctx->data.nvertices; + ids[0] = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 0]; + ids[ctx->ctx.reverse_vrtx ? 2 : 1] + = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 1]; + ids[ctx->ctx.reverse_vrtx ? 1 : 2] + = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 2]; } static void get_s3dut_position(const unsigned ivert, double pos[3], void* context) { struct s3dut_context* ctx = context; + unsigned s3dut_ivert, cyl_idx; + int i, j, k; + double offset[3], tmp[3]; + double center_x, center_y, scale, misalignment = 0; ASSERT(pos && ctx); - ASSERT(ivert < ctx->data.nvertices); - pos[0] - = ctx->data.positions[ivert * 3 + 0] * ctx->ctx.scale + ctx->ctx.offset[0]; - pos[1] - = ctx->data.positions[ivert * 3 + 1] * ctx->ctx.scale + ctx->ctx.offset[1]; - pos[2] - = ctx->data.positions[ivert * 3 + 2] * ctx->ctx.scale + ctx->ctx.offset[2]; + ASSERT(ivert < NB_CYL * ctx->data.nvertices); + /* Get cyl_idx and cylinder imbrication along with the s3dut vertice index */ + s3dut_ivert = ivert % (unsigned)ctx->data.nvertices; + cyl_idx = ivert / (unsigned)ctx->data.nvertices; + /* k th cylinder of the imbrication at grid position i,j */ + i = cyl_idx / (NB_CYL_Y * NB_CYL_Z); + j = (cyl_idx / NB_CYL_Z ) % NB_CYL_Y; + k = cyl_idx % NB_CYL_Z; + ASSERT(i < NB_CYL_X && j < NB_CYL_Y && k < NB_CYL_Z); + ASSERT((i * NB_CYL_Y * NB_CYL_Z + j * NB_CYL_Z + k) * ctx->data.nvertices + + s3dut_ivert == ivert); + center_x = 2 * (1 + NB_CYL_X) * (i - NB_CYL_X / 2); + center_y = 2 * (1 + NB_CYL_Y) * (j - NB_CYL_Y / 2); + /* Compute scale and offset from imbrication */ + scale = k + 1; +#ifdef MITIGATE_EMBREE_181 + /* Mitigate Embree issue #181 + * We cannot keep perfect alignment of cylinders + * or some hits are missed */ + misalignment = (k % 2) ? -0.01 : +0.01; +#endif + d3(offset, center_x + misalignment, center_y + misalignment, 0); + d3_add(pos, d3_muld(tmp, ctx->data.positions + s3dut_ivert * 3, scale), + offset); } static void get_s3dut_media(const unsigned itri, unsigned medium[2], void* context) { struct s3dut_context* ctx = context; - (void)itri; + unsigned cyl_idx; + int k; ASSERT(medium && ctx); - medium[ctx->ctx.reverse_med ? 1 : 0] = *ctx->ctx.front_media; - medium[ctx->ctx.reverse_med ? 0 : 1] = *ctx->ctx.back_media; + ASSERT(itri < NB_CYL * ctx->data.nprimitives); + /* Get cyl_idx */ + cyl_idx = itri / (unsigned)ctx->data.nprimitives; + /* k th cylinder of the imbrication at some grid position */ + k = cyl_idx % NB_CYL_Z; + medium[ctx->ctx.reverse_med ? SENC_BACK : SENC_FRONT] = (unsigned)k; + medium[ctx->ctx.reverse_med ? SENC_FRONT : SENC_BACK] = (unsigned)(k + 1); } int main(int argc, char** argv) { struct mem_allocator allocator; - struct descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct s3dut_mesh* cyl = NULL; - struct s3dut_context ctx; - unsigned m_in, m_out; + struct s3dut_context ctx = { {NULL,NULL,0,0}, CONTEXT_NULL__ }; unsigned count; unsigned cyl_trg_count, cyl_vrtx_count, e; - int i, j, k; char dump[64]; struct time t0, t1; (void)argc, (void)argv; - CHK(mem_init_regular_allocator(&allocator) == RES_OK); - CHK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) - == RES_OK); - -#define NB_CYL_1 64 - /* 64^3 = 262144 cylinders */ -#define NB_CYL (NB_CYL_1 * NB_CYL_1 * NB_CYL_1) - /* Create the scene */ - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - - ctx.ctx.positions = NULL; - ctx.ctx.indices = NULL; - ctx.ctx.reverse_vrtx = 0; - ctx.ctx.reverse_med = 0; - ctx.ctx.front_media = &m_in; - ctx.ctx.back_media = &m_out; + OK(mem_init_regular_allocator(&allocator)); + OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); + /* A 20 triangles 12 vertices cylinder template */ - S3DUT(create_cylinder(&allocator, 1, 1, 5, 1, &cyl)); + S3DUT(create_cylinder(&allocator, 1, 1, 3, 1, &cyl)); S3DUT(mesh_get_data(cyl, &ctx.data)); ASSERT(ctx.data.nprimitives < UINT_MAX); ASSERT(ctx.data.nvertices < UINT_MAX); cyl_trg_count = (unsigned)ctx.data.nprimitives; cyl_vrtx_count = (unsigned)ctx.data.nvertices; - CHK(senc_scene_reserve(scn, NB_CYL * cyl_vrtx_count, NB_CYL * cyl_trg_count, 0) - == RES_OK); - FOR_EACH(i, 0, NB_CYL_1) { - double center_x = 2 * (1 + NB_CYL_1) * (i - NB_CYL_1 / 2); - FOR_EACH(j, 0, NB_CYL_1) { - double misalignment = 0.01; - FOR_EACH(k, 0, NB_CYL_1) { - double center_y = 2 * (1 + NB_CYL_1) * (j - NB_CYL_1 / 2); - m_in = (unsigned)k; - m_out = (unsigned)(k + 1); - ctx.ctx.scale = k + 1; - /* Mitigate Embree issue #181 - * We cannot keep perfect alignment of cylinders - * or some hits are missed */ - misalignment *= -1; - d3(ctx.ctx.offset, center_x + misalignment, center_y + misalignment, 0); - CHK(senc_scene_add_geometry(scn, cyl_trg_count, get_s3dut_indices, - get_s3dut_media, cyl_vrtx_count, get_s3dut_position, NULL, NULL, &ctx) - == RES_OK); - } - } - } - S3DUT(mesh_ref_put(cyl)); + /* Create the scene with N_CYL cylinders. + * There are NB_CYL_1 * NB_CYL_1 imbrications of NB_CYL_1 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. */ time_current(&t0); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + NB_CYL * cyl_trg_count, get_s3dut_indices, get_s3dut_media, + NB_CYL * cyl_vrtx_count, get_s3dut_position, &ctx, &scn)); time_sub(&t0, time_current(&t1), &t0); time_dump(&t0, TIME_MSEC | TIME_SEC | TIME_MIN, NULL, dump, sizeof(dump)); - printf("Scene analyzed in: %s\n", dump); - - /* dump_global(desc, "test_many_enclosures.obj"); */ + printf("Scene created in: %s\n", dump); + S3DUT(mesh_ref_put(cyl)); - CHK(senc_descriptor_get_vertices_count(desc, &count) == RES_OK); + OK(senc_scene_get_vertices_count(scn, &count)); CHK(count == NB_CYL * cyl_vrtx_count); - CHK(senc_descriptor_get_triangles_count(desc, &count) == RES_OK); + OK(senc_scene_get_triangles_count(scn, &count)); CHK(count == NB_CYL * cyl_trg_count); - CHK(senc_descriptor_get_enclosure_count(desc, &count) == RES_OK); + OK(senc_scene_get_enclosure_count(scn, &count)); CHK(count == 1 + NB_CYL); - FOR_EACH(e, 0, count) { struct senc_enclosure* enclosure; struct senc_enclosure_header header; unsigned m; - CHK(senc_descriptor_get_enclosure(desc, e, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.enclosed_media_count == 1); - CHK(senc_enclosure_get_medium(enclosure, 0, &m) == RES_OK); + OK(senc_enclosure_get_medium(enclosure, 0, &m)); CHK(header.triangle_count == - (header.is_infinite /* Outermost enclosure: NB_CYL_1*NB_CYL_1 cylinders */ - ? NB_CYL_1 * NB_CYL_1 * cyl_trg_count + (header.is_infinite /* Outermost enclosure: NB_CYL_X*NB_CYL_Y cylinders */ + ? NB_CYL_X * NB_CYL_Y * cyl_trg_count : (m == 0 ? cyl_trg_count /* Innermost enclosures: 1 cylinder */ : 2 * cyl_trg_count))); /* Other enclosures: 2 cylinders */ - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_ref_put(enclosure)); } - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_regular_allocator(&allocator); diff --git a/src/test_senc_many_triangles.c b/src/test_senc_many_triangles.c @@ -13,90 +13,100 @@ * 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 is similar to test_senc_some_triangles, but involves 4*2562560 + * triangles instead of 4*1054, thus making it impossible to define the geometry + * through static arrays. */ + #include "senc.h" #include "test_senc_utils.h" #include <star/s3dut.h> -#include <rsys/double3.h> #include <rsys/clock_time.h> +#include <rsys/double3.h> +#include <stdio.h> #include <limits.h> +#define NB_CYL 4 + struct s3dut_context { struct s3dut_mesh_data data; - struct context ctx = CONTEXT_NULL__; + struct context ctx; }; static void get_s3dut_indices(const unsigned itri, unsigned ids[3], void* context) { struct s3dut_context* ctx = context; + unsigned s3dut_itri, cyl_idx, v_offset; ASSERT(ids && ctx); - ASSERT(itri < ctx->data.nprimitives); - ASSERT(ctx->data.indices[itri * 3 + 0] < UINT_MAX - && ctx->data.indices[itri * 3 + 1] < UINT_MAX - && ctx->data.indices[itri * 3 + 2] < UINT_MAX); - ids[0] = (unsigned)ctx->data.indices[itri * 3 + 0]; - ids[ctx->ctx.reverse_vrtx ? 2 : 1] = (unsigned)ctx->data.indices[itri * 3 + 1]; - ids[ctx->ctx.reverse_vrtx ? 1 : 2] = (unsigned)ctx->data.indices[itri * 3 + 2]; + ASSERT(itri < NB_CYL * ctx->data.nprimitives); + /* Get cyl_idx along with the s3dut vertice index */ + s3dut_itri = itri % (unsigned)ctx->data.nprimitives; + cyl_idx = itri / (unsigned)ctx->data.nprimitives; + ASSERT(ctx->data.indices[s3dut_itri * 3 + 0] <= UINT_MAX + && ctx->data.indices[s3dut_itri * 3 + 1] <= UINT_MAX + && ctx->data.indices[s3dut_itri * 3 + 2] <= UINT_MAX); + /* Compute the vertex index in the user numbering + * from cyl_idx and s3dut data; vertex related getters + * will have to get the s3dut index back */ + v_offset = cyl_idx * (unsigned)ctx->data.nvertices; + ids[0] = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 0]; + ids[ctx->ctx.reverse_vrtx ? 2 : 1] + = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 1]; + ids[ctx->ctx.reverse_vrtx ? 1 : 2] + = v_offset + (unsigned)ctx->data.indices[s3dut_itri * 3 + 2]; } static void get_s3dut_position(const unsigned ivert, double pos[3], void* context) { struct s3dut_context* ctx = context; + unsigned s3dut_ivert, cyl_idx; + double offset[3], tmp[3]; ASSERT(pos && ctx); - ASSERT(ivert < ctx->data.nvertices); - pos[0] - = ctx->data.positions[ivert * 3 + 0] * ctx->ctx.scale + ctx->ctx.offset[0]; - pos[1] - = ctx->data.positions[ivert * 3 + 1] * ctx->ctx.scale + ctx->ctx.offset[1]; - pos[2] - = ctx->data.positions[ivert * 3 + 2] * ctx->ctx.scale + ctx->ctx.offset[2]; + ASSERT(ivert < NB_CYL * ctx->data.nvertices); + /* Get cyl_idx along with the s3dut vertice index */ + s3dut_ivert = ivert % (unsigned)ctx->data.nvertices; + cyl_idx = ivert / (unsigned)ctx->data.nvertices; + /* Compute offset from cyl_idx */ + d3(offset, 0, 0, cyl_idx * 10); + d3_add(pos, d3_muld(tmp, ctx->data.positions + s3dut_ivert * 3, ctx->ctx.scale), + offset); } static void get_s3dut_media(const unsigned itri, unsigned medium[2], void* context) { struct s3dut_context* ctx = context; - (void)itri; + unsigned cyl_idx; ASSERT(medium && ctx); - medium[ctx->ctx.reverse_med ? 1 : 0] = *ctx->ctx.front_media; - medium[ctx->ctx.reverse_med ? 0 : 1] = *ctx->ctx.back_media; + ASSERT(itri < NB_CYL * ctx->data.nprimitives); + /* Get cyl_idx from itri */ + cyl_idx = itri / (unsigned)ctx->data.nprimitives; + /* Compute front medium from cyl_idx */ + medium[ctx->ctx.reverse_med ? SENC_BACK : SENC_FRONT] = cyl_idx; + medium[ctx->ctx.reverse_med ? SENC_FRONT : SENC_BACK] = *ctx->ctx.back_media; } int main(int argc, char** argv) { struct mem_allocator allocator; - struct descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct s3dut_mesh* cyl = NULL; - struct s3dut_context ctx; - unsigned m0 = 0, m1; + struct s3dut_context ctx = { {NULL,NULL,0,0}, CONTEXT_NULL__ }; + unsigned m0 = 0; unsigned count; - unsigned cyl_trg_count, cyl_vrtx_count, i; + unsigned cyl_trg_count, cyl_vrtx_count, e; char dump[64]; struct time t0, t1; (void)argc, (void)argv; - CHK(mem_init_regular_allocator(&allocator) == RES_OK); - CHK(senc_device_create (NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) - == RES_OK); + OK(mem_init_regular_allocator(&allocator)); + OK(senc_device_create (NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); -#define NB_CYL 4 - /* Create the scene */ - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - - ctx.ctx.positions = NULL; - ctx.ctx.indices = NULL; - ctx.ctx.scale = 1; - ctx.ctx.reverse_vrtx = 0; - ctx.ctx.reverse_med = 0; - ctx.ctx.back_media = &m0; - ctx.ctx.front_media = &m1; /* A 2,562,560 triangles 1,281,282 vertices cylinder template */ S3DUT(create_cylinder(&allocator, 1, 2, 1280, 1000, &cyl)); S3DUT(mesh_get_data(cyl, &ctx.data)); @@ -104,45 +114,40 @@ main(int argc, char** argv) ASSERT(ctx.data.nvertices < UINT_MAX); cyl_trg_count = (unsigned)ctx.data.nprimitives; cyl_vrtx_count = (unsigned)ctx.data.nvertices; - CHK(senc_scene_reserve(scn, NB_CYL * cyl_vrtx_count, NB_CYL * cyl_trg_count, 0) - == RES_OK); - FOR_EACH(i, 0, NB_CYL) { - m1 = i; - d3(ctx.ctx.offset, 0, 0, i * 10); - CHK(senc_scene_add_geometry(scn, cyl_trg_count, get_s3dut_indices, - get_s3dut_media, cyl_vrtx_count, get_s3dut_position, NULL, NULL, &ctx) - == RES_OK); - } - S3DUT(mesh_ref_put(cyl)); + /* Create the scene with 4 cylinders. + * The get_s3du_xxx getters have to retrieve the cylinder from the + * primitive and vertice indexes. */ + ctx.ctx.back_media = &m0; time_current(&t0); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + NB_CYL* cyl_trg_count, get_s3dut_indices, get_s3dut_media, + NB_CYL* cyl_vrtx_count, get_s3dut_position, &ctx, &scn)); time_sub(&t0, time_current(&t1), &t0); time_dump(&t0, TIME_MSEC | TIME_SEC | TIME_MIN, NULL, dump, sizeof(dump)); - printf("Scene analyzed in: %s\n", dump); - - /* dump_global(desc, "test_many_triangles.obj"); */ + printf("Scene created in: %s\n", dump); + S3DUT(mesh_ref_put(cyl)); - CHK(senc_descriptor_get_vertices_count(desc, &count) == RES_OK); + OK(senc_scene_get_vertices_count(scn, &count)); CHK(count == NB_CYL * cyl_vrtx_count); - CHK(senc_descriptor_get_triangles_count(desc, &count) == RES_OK); + OK(senc_scene_get_triangles_count(scn, &count)); CHK(count == NB_CYL * cyl_trg_count); - CHK(senc_descriptor_get_enclosure_count(desc, &count) == RES_OK); + OK(senc_scene_get_enclosure_count(scn, &count)); CHK(count == 1 + NB_CYL); - FOR_EACH(i, 0, count) { + FOR_EACH(e, 0, count) { struct senc_enclosure* enclosure; struct senc_enclosure_header header; - CHK(senc_descriptor_get_enclosure(desc, i, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.triangle_count == - i ? cyl_trg_count : NB_CYL * cyl_trg_count); - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + e ? cyl_trg_count : NB_CYL * cyl_trg_count); + OK(senc_enclosure_ref_put(enclosure)); } - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_regular_allocator(&allocator); diff --git a/src/test_senc_sample_enclosure.c b/src/test_senc_sample_enclosure.c @@ -14,7 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "senc.h" -#include "senc_s3d_wrapper.h" +#include "senc_s3d_helper.h" #include "test_senc_utils.h" #include <rsys/float3.h> @@ -53,7 +53,7 @@ main(int argc, char** argv) vrtx_get.type = S3D_FLOAT3; vrtx_get.usage = S3D_POSITION; - vrtx_get.get = senc_enclosure_get_vertex__; + vrtx_get.get = senc_s3d_enclosure_get_position__; S3D(device_create(NULL, &allocator, 0, &s3d)); @@ -82,7 +82,7 @@ main(int argc, char** argv) /* Put enclosure in a 3D view... */ S3D(shape_create_mesh(s3d, &s3d_shp)); S3D(mesh_setup_indexed_vertices(s3d_shp, header.triangle_count, - senc_enclosure_get_triangle__, header.vertices_count, &vrtx_get, 1, + 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 @@ -25,258 +25,268 @@ main(int argc, char** argv) struct mem_allocator allocator; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; - struct descriptor* desc = NULL; struct senc_enclosure* enc = NULL; struct senc_enclosure_header header; struct context ctx = CONTEXT_NULL__; - unsigned medfront[2], medback[2], ind[3]; + unsigned medfront[2], medback[2], ind[3], ids[2]; double vrtx[3]; unsigned count, i, maxm; int convention; (void)argc, (void)argv; - CHK(mem_init_proxy_allocator(&allocator, &mem_default_allocator) == RES_OK); - CHK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev) - == RES_OK); - - CHK(senc_scene_create(NULL, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_BAD_ARG); - CHK(senc_scene_create(dev, 0, &scn) == RES_BAD_ARG); - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, NULL) == RES_BAD_ARG); - CHK(senc_scene_create(NULL, 0, &scn) == RES_BAD_ARG); - CHK(senc_scene_create(NULL, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, NULL) == RES_BAD_ARG); - CHK(senc_scene_create(dev, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_create(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - - CHK(senc_scene_reserve(NULL, 0, 0, 0) == RES_BAD_ARG); - CHK(senc_scene_reserve(scn, 0, 0, 0) == RES_OK); - - CHK(senc_scene_get_convention(NULL, &convention) == RES_BAD_ARG); - CHK(senc_scene_get_convention(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_convention(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_convention(scn, &convention) == RES_OK); - CHK(convention == (SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE)); - - CHK(senc_scene_get_triangles_count(NULL, &count) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(scn, &count) == RES_OK); - CHK(count == 0); - - CHK(senc_scene_get_triangles_count(NULL, &count) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangles_count(scn, &count) == RES_OK); - CHK(count == 0); - - CHK(senc_scene_get_vertices_count(NULL, &count) == RES_BAD_ARG); - CHK(senc_scene_get_vertices_count(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertices_count(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertices_count(scn, &count) == RES_OK); - CHK(count == 0); - - CHK(senc_scene_get_unique_vertices_count(NULL, &count) == RES_BAD_ARG); - CHK(senc_scene_get_unique_vertices_count(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_unique_vertices_count(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_unique_vertices_count(scn, &count) == RES_OK); - CHK(count == 0); - - CHK(senc_scene_get_unique_sides_without_medium_count(NULL, &count) - == RES_BAD_ARG); - CHK(senc_scene_get_unique_sides_without_medium_count(scn, NULL) - == RES_BAD_ARG); - CHK(senc_scene_get_unique_sides_without_medium_count(NULL, NULL) - == RES_BAD_ARG); - CHK(senc_scene_get_unique_sides_without_medium_count(scn, &count) - == RES_OK); - CHK(count == 0); + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); /* A 3D cube. * With this geometry front is inside with NORMAL_BACK convention, * outside with NORMAL_FRONT convention */ ctx.positions = box_vertices; ctx.indices = box_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; - CHK(senc_scene_add_geometry(NULL, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - CHK(senc_scene_add_geometry(scn, 0, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - CHK(senc_scene_add_geometry(scn, ntriangles, NULL, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - 0, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, NULL, NULL, NULL, &ctx) == RES_BAD_ARG); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - CHK(senc_scene_get_triangles_count(scn, &count) == RES_OK); + BA(senc_scene_create(NULL, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + BA(senc_scene_create(dev, + 0, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + BA(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + 0, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + BA(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, NULL, get_media, + nvertices, get_position, &ctx, &scn)); + BA(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + 0, get_position, &ctx, &scn)); + BA(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, NULL, &ctx, &scn)); + BA(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, NULL)); + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + + BA(senc_scene_get_convention(NULL, &convention)); + BA(senc_scene_get_convention(scn, NULL)); + BA(senc_scene_get_convention(NULL, NULL)); + OK(senc_scene_get_convention(scn, &convention)); + 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)); CHK(count == ntriangles); - CHK(senc_scene_get_triangles_count(scn, &count) == RES_OK); - CHK(count == ntriangles); - CHK(senc_scene_get_vertices_count(scn, &count) == RES_OK); - CHK(count == nvertices); - CHK(senc_scene_get_unique_vertices_count(scn, &count) == RES_OK); + + BA(senc_scene_get_vertices_count(NULL, &count)); + BA(senc_scene_get_vertices_count(scn, NULL)); + BA(senc_scene_get_vertices_count(NULL, NULL)); + OK(senc_scene_get_vertices_count(scn, &count)); CHK(count == nvertices); - CHK(senc_scene_get_triangle(NULL, 0, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(scn, UINT_MAX, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(scn, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(NULL, UINT_MAX, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(scn, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(NULL, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle(scn, 0, ind) == RES_OK); - - CHK(senc_scene_get_triangle_media(NULL, 0, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(scn, UINT_MAX, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(scn, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(NULL, UINT_MAX, ind) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(scn, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(NULL, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_triangle_media(scn, 0, ind) == RES_OK); - - CHK(senc_scene_get_vertex(NULL, 0, vrtx) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(scn, UINT_MAX, vrtx) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(scn, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(NULL, UINT_MAX, vrtx) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(NULL, 0, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(scn, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(NULL, UINT_MAX, NULL) == RES_BAD_ARG); - CHK(senc_scene_get_vertex(scn, 0, vrtx) == RES_OK); - - CHK(senc_scene_analyze(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_analyze(scn, NULL) == RES_BAD_ARG); - CHK(senc_scene_analyze(NULL, &desc) == RES_BAD_ARG); - CHK(senc_scene_analyze(NULL, NULL) == RES_BAD_ARG); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); - - CHK(senc_scene_ref_get(NULL) == RES_BAD_ARG); - CHK(senc_scene_ref_get(scn) == RES_OK); - CHK(senc_scene_ref_put(NULL) == RES_BAD_ARG); - CHK(senc_scene_ref_put(scn) == RES_OK); - - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - CHK(senc_scene_get_convention(scn, &convention) == RES_OK); - CHK(convention == (SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE)); - /* Add the first triangle twice to create a shift in numbering */ - CHK(senc_scene_add_geometry(scn, 1, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + 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_vertex(NULL, 0, vrtx)); + BA(senc_scene_get_vertex(scn, UINT_MAX, vrtx)); + BA(senc_scene_get_vertex(scn, 0, NULL)); + BA(senc_scene_get_vertex(NULL, UINT_MAX, vrtx)); + BA(senc_scene_get_vertex(NULL, 0, NULL)); + BA(senc_scene_get_vertex(scn, UINT_MAX, NULL)); + BA(senc_scene_get_vertex(NULL, UINT_MAX, NULL)); + OK(senc_scene_get_vertex(scn, 0, vrtx)); + + BA(senc_scene_get_max_medium(NULL, &maxm)); + BA(senc_scene_get_max_medium(scn, NULL)); + BA(senc_scene_get_max_medium(NULL, NULL)); + OK(senc_scene_get_max_medium(scn, &maxm)); + CHK(maxm == 1); + + BA(senc_scene_get_enclosure_count(NULL, &count)); + BA(senc_scene_get_enclosure_count(scn, NULL)); + BA(senc_scene_get_enclosure_count(NULL, NULL)); + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 2); + + BA(senc_scene_get_enclosure_count_by_medium(NULL, 0, &count)); + BA(senc_scene_get_enclosure_count_by_medium(scn, 100, &count)); + BA(senc_scene_get_enclosure_count_by_medium(scn, 0, NULL)); + BA(senc_scene_get_enclosure_count_by_medium(NULL, 100, &count)); + BA(senc_scene_get_enclosure_count_by_medium(NULL, 0, NULL)); + BA(senc_scene_get_enclosure_count_by_medium(scn, 100, NULL)); + 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, + &count)); + CHK(count == 0); + + BA(senc_scene_get_enclosure(NULL, 0, &enc)); + BA(senc_scene_get_enclosure(scn, UINT_MAX, &enc)); + BA(senc_scene_get_enclosure(scn, 0, NULL)); + BA(senc_scene_get_enclosure(NULL, UINT_MAX, &enc)); + BA(senc_scene_get_enclosure(NULL, 0, NULL)); + BA(senc_scene_get_enclosure(scn, UINT_MAX, NULL)); + BA(senc_scene_get_enclosure(NULL, UINT_MAX, NULL)); + OK(senc_scene_get_enclosure(scn, 0, &enc)); + OK(senc_enclosure_ref_put(enc)); + + BA(senc_scene_get_enclosure_by_medium(NULL, 0, 0, &enc)); + BA(senc_scene_get_enclosure_by_medium(scn, 100, 0, &enc)); + BA(senc_scene_get_enclosure_by_medium(scn, 0, UINT_MAX, &enc)); + BA(senc_scene_get_enclosure_by_medium(scn, 0, 0, NULL)); + BA(senc_scene_get_enclosure_by_medium(NULL, 100, 0, &enc)); + BA(senc_scene_get_enclosure_by_medium(NULL, 0, UINT_MAX, &enc)); + BA(senc_scene_get_enclosure_by_medium(NULL, 0, 0, NULL)); + BA(senc_scene_get_enclosure_by_medium(scn, 100, UINT_MAX, &enc)); + BA(senc_scene_get_enclosure_by_medium(scn, 100, 0, NULL)); + BA(senc_scene_get_enclosure_by_medium(scn, 0, UINT_MAX, NULL)); + BA(senc_scene_get_enclosure_by_medium(scn, 100, UINT_MAX, NULL)); + BA(senc_scene_get_enclosure_by_medium(NULL, 0, UINT_MAX, NULL)); + BA(senc_scene_get_enclosure_by_medium(NULL, 100, 0, NULL)); + BA(senc_scene_get_enclosure_by_medium(NULL, 100, UINT_MAX, &enc)); + 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)); + 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_ref_get(NULL)); + OK(senc_scene_ref_get(scn)); + BA(senc_scene_ref_put(NULL)); + OK(senc_scene_ref_put(scn)); + + OK(senc_scene_ref_put(scn)); + + /* Same geometry with SENC_UNDEFINED_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_enclosure_ref_put(enc)); + BA(senc_scene_get_enclosure_by_medium(scn, SENC_UNDEFINED_MEDIUM, 100, &enc)); + + OK(senc_scene_ref_put(scn)); + + /* Same geometry with a hole (1 missing triangle) */ + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles - 1, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + + OK(senc_scene_get_frontier_segments_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_ref_put(scn)); + + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); + + OK(senc_scene_get_convention(scn, &convention)); + CHK(convention + == (SENC_CONVENTION_NORMAL_BACK | SENC_CONVENTION_NORMAL_INSIDE)); /* Check that medium 0 is inside */ - CHK(senc_descriptor_get_enclosure_by_medium(desc, 0, 0, &enc) == RES_OK); - CHK(senc_enclosure_get_header(enc, &header) == RES_OK); + OK(senc_scene_get_enclosure_by_medium(scn, 0, 0, &enc)); + OK(senc_enclosure_get_header(enc, &header)); CHK(!header.is_infinite); - CHK(senc_enclosure_ref_put(enc) == RES_OK); + OK(senc_enclosure_ref_put(enc)); - FOR_EACH(i, 0, ntriangles) { - unsigned gid; - CHK(senc_descriptor_get_triangle_global_id(desc, i, &gid) == RES_OK); - /* Check numbering shift */ - CHK(gid == (i ? i + 1 : 0)); - } + OK(senc_scene_get_triangle_media(scn, 0, medback)); + OK(senc_scene_ref_put(scn)); - CHK(senc_descriptor_get_triangle_media(desc, 0, medback) == RES_OK); - ctx.front_media = medium1_3; - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); /* Medium mismatch between neighbour segments, but OK */ - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + ctx.front_media = medium1_3; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); - CHK(senc_descriptor_get_max_medium(desc, &maxm) == RES_OK); + OK(senc_scene_get_max_medium(scn, &maxm)); CHK(maxm == 3); - CHK(senc_descriptor_get_enclosure_count_by_medium(desc, 0, &count) == RES_OK); + OK(senc_scene_get_enclosure_count_by_medium(scn, 0, &count)); CHK(count == 0); /* Medium 0 unused */ - CHK(senc_descriptor_get_enclosure_count_by_medium(desc, 1, &count) == RES_OK); + OK(senc_scene_get_enclosure_count_by_medium(scn, 1, &count)); CHK(count == 2); /* Medium 1 used twice */ - CHK(senc_descriptor_get_enclosure_count_by_medium(desc, 2, &count) == RES_OK); + OK(senc_scene_get_enclosure_count_by_medium(scn, 2, &count)); CHK(count == 0); /* Medium 2 unused */ - CHK(senc_descriptor_get_enclosure_count_by_medium(desc, 3, &count) == RES_OK); + OK(senc_scene_get_enclosure_count_by_medium(scn, 3, &count)); CHK(count == 1); /* Medium 3 used */ - check_desc(desc); + + OK(senc_scene_ref_put(scn)); ctx.front_media = medium0; - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); - CHK(senc_scene_create(dev, - SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, &scn) == RES_OK); - /* Add the first triangle twice to create a shift in numbering */ - CHK(senc_scene_add_geometry(scn, 1, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - CHK(senc_scene_analyze(scn, &desc) == RES_OK); + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + ntriangles, get_indices, get_media, + nvertices, get_position, &ctx, &scn)); /* Check that medium 0 is outside */ - CHK(senc_descriptor_get_enclosure_by_medium(desc, 0, 0, &enc) == RES_OK); - CHK(senc_enclosure_get_header(enc, &header) == RES_OK); + OK(senc_scene_get_enclosure_by_medium(scn, 0, 0, &enc)); + OK(senc_enclosure_get_header(enc, &header)); CHK(header.is_infinite); - CHK(senc_enclosure_ref_put(enc) == RES_OK); + OK(senc_enclosure_ref_put(enc)); - FOR_EACH(i, 0, ntriangles) { - unsigned gid; - CHK(senc_descriptor_get_triangle_global_id(desc, i, &gid) == RES_OK); - /* Check numbering shift */ - CHK(gid == (i ? i + 1 : 0)); - } - - CHK(senc_descriptor_get_triangle_media(desc, 0, medfront) == RES_OK); + OK(senc_scene_get_triangle_media(scn, 0, medfront)); FOR_EACH(i, 0, 2) CHK(medback[i] == medfront[i]); - /* Invalid vertex ID */ - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices - 1, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - - /* Incoherent medium on a duplicate triangle */ - ctx.back_media = medium1_3; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_BAD_ARG); - - /* It is OK add geometry after a failed add */ - ctx.back_media = medium1; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - /* Coherent medium on duplicate triangle */ - ctx.back_media = medium1; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - /* Coherent medium on duplicate triangle V2 */ - ctx.reverse_med = 1; - ctx.front_media = medium1; - ctx.back_media = medium0; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - /* Coherent medium on duplicate triangle V3 */ - ctx.reverse_med = 0; - ctx.reverse_vrtx = 1; - CHK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx) == RES_OK); - - CHK(senc_scene_ref_put(scn) == RES_OK); - CHK(senc_device_ref_put(dev) == RES_OK); - CHK(senc_descriptor_ref_put(desc) == RES_OK); + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); diff --git a/src/test_senc_some_enclosures.c b/src/test_senc_some_enclosures.c @@ -0,0 +1,3427 @@ +/* Copyright (C) |Meso|Star> 2016-2018 (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_some_enclosures. + * This test is similar to test_senc_many_enclosures that creates a huge + * geometry by program. */ + +#include "senc.h" +#include "test_senc_utils.h" + +#include <rsys/double3.h> + +/* Dump of star-geometry 'some_enclosures'. */ +static const unsigned some_enclosures_vertices_count = 768; +static const double some_enclosures_vertices[2304] = +{ + -19, -20, -0.5, + -19, -20, 0.5, + -19.691, -19.0489, -0.5, + -19.691, -19.0489, 0.5, + -20.809, -19.4122, -0.5, + -20.809, -19.4122, 0.5, + -20.809, -20.5878, -0.5, + -20.809, -20.5878, 0.5, + -19.691, -20.9511, -0.5, + -19.691, -20.9511, 0.5, + -20, -20, -0.5, + -20, -20, 0.5, + -18, -20, -1, + -18, -20, 1, + -19.382, -18.0979, -1, + -19.382, -18.0979, 1, + -21.618, -18.8244, -1, + -21.618, -18.8244, 1, + -21.618, -21.1756, -1, + -21.618, -21.1756, 1, + -19.382, -21.9021, -1, + -19.382, -21.9021, 1, + -20, -20, -1, + -20, -20, 1, + -17, -20, -1.5, + -17, -20, 1.5, + -19.0729, -17.1468, -1.5, + -19.0729, -17.1468, 1.5, + -22.4271, -18.2366, -1.5, + -22.4271, -18.2366, 1.5, + -22.4271, -21.7634, -1.5, + -22.4271, -21.7634, 1.5, + -19.0729, -22.8532, -1.5, + -19.0729, -22.8532, 1.5, + -20, -20, -1.5, + -20, -20, 1.5, + -16, -20, -2, + -16, -20, 2, + -18.7639, -16.1958, -2, + -18.7639, -16.1958, 2, + -23.2361, -17.6489, -2, + -23.2361, -17.6489, 2, + -23.2361, -22.3511, -2, + -23.2361, -22.3511, 2, + -18.7639, -23.8042, -2, + -18.7639, -23.8042, 2, + -20, -20, -2, + -20, -20, 2, + -19, -10, -0.5, + -19, -10, 0.5, + -19.691, -9.04894, -0.5, + -19.691, -9.04894, 0.5, + -20.809, -9.41221, -0.5, + -20.809, -9.41221, 0.5, + -20.809, -10.5878, -0.5, + -20.809, -10.5878, 0.5, + -19.691, -10.9511, -0.5, + -19.691, -10.9511, 0.5, + -20, -10, -0.5, + -20, -10, 0.5, + -18, -10, -1, + -18, -10, 1, + -19.382, -8.09789, -1, + -19.382, -8.09789, 1, + -21.618, -8.82443, -1, + -21.618, -8.82443, 1, + -21.618, -11.1756, -1, + -21.618, -11.1756, 1, + -19.382, -11.9021, -1, + -19.382, -11.9021, 1, + -20, -10, -1, + -20, -10, 1, + -17, -10, -1.5, + -17, -10, 1.5, + -19.0729, -7.14683, -1.5, + -19.0729, -7.14683, 1.5, + -22.4271, -8.23664, -1.5, + -22.4271, -8.23664, 1.5, + -22.4271, -11.7634, -1.5, + -22.4271, -11.7634, 1.5, + -19.0729, -12.8532, -1.5, + -19.0729, -12.8532, 1.5, + -20, -10, -1.5, + -20, -10, 1.5, + -16, -10, -2, + -16, -10, 2, + -18.7639, -6.19577, -2, + -18.7639, -6.19577, 2, + -23.2361, -7.64886, -2, + -23.2361, -7.64886, 2, + -23.2361, -12.3511, -2, + -23.2361, -12.3511, 2, + -18.7639, -13.8042, -2, + -18.7639, -13.8042, 2, + -20, -10, -2, + -20, -10, 2, + -19, 0, -0.5, + -19, 0, 0.5, + -19.691, 0.951057, -0.5, + -19.691, 0.951057, 0.5, + -20.809, 0.587785, -0.5, + -20.809, 0.587785, 0.5, + -20.809, -0.587785, -0.5, + -20.809, -0.587785, 0.5, + -19.691, -0.951057, -0.5, + -19.691, -0.951057, 0.5, + -20, 0, -0.5, + -20, 0, 0.5, + -18, 0, -1, + -18, 0, 1, + -19.382, 1.90211, -1, + -19.382, 1.90211, 1, + -21.618, 1.17557, -1, + -21.618, 1.17557, 1, + -21.618, -1.17557, -1, + -21.618, -1.17557, 1, + -19.382, -1.90211, -1, + -19.382, -1.90211, 1, + -20, 0, -1, + -20, 0, 1, + -17, 0, -1.5, + -17, 0, 1.5, + -19.0729, 2.85317, -1.5, + -19.0729, 2.85317, 1.5, + -22.4271, 1.76336, -1.5, + -22.4271, 1.76336, 1.5, + -22.4271, -1.76336, -1.5, + -22.4271, -1.76336, 1.5, + -19.0729, -2.85317, -1.5, + -19.0729, -2.85317, 1.5, + -20, 0, -1.5, + -20, 0, 1.5, + -16, 0, -2, + -16, 0, 2, + -18.7639, 3.80423, -2, + -18.7639, 3.80423, 2, + -23.2361, 2.35114, -2, + -23.2361, 2.35114, 2, + -23.2361, -2.35114, -2, + -23.2361, -2.35114, 2, + -18.7639, -3.80423, -2, + -18.7639, -3.80423, 2, + -20, 0, -2, + -20, 0, 2, + -19, 10, -0.5, + -19, 10, 0.5, + -19.691, 10.9511, -0.5, + -19.691, 10.9511, 0.5, + -20.809, 10.5878, -0.5, + -20.809, 10.5878, 0.5, + -20.809, 9.41221, -0.5, + -20.809, 9.41221, 0.5, + -19.691, 9.04894, -0.5, + -19.691, 9.04894, 0.5, + -20, 10, -0.5, + -20, 10, 0.5, + -18, 10, -1, + -18, 10, 1, + -19.382, 11.9021, -1, + -19.382, 11.9021, 1, + -21.618, 11.1756, -1, + -21.618, 11.1756, 1, + -21.618, 8.82443, -1, + -21.618, 8.82443, 1, + -19.382, 8.09789, -1, + -19.382, 8.09789, 1, + -20, 10, -1, + -20, 10, 1, + -17, 10, -1.5, + -17, 10, 1.5, + -19.0729, 12.8532, -1.5, + -19.0729, 12.8532, 1.5, + -22.4271, 11.7634, -1.5, + -22.4271, 11.7634, 1.5, + -22.4271, 8.23664, -1.5, + -22.4271, 8.23664, 1.5, + -19.0729, 7.14683, -1.5, + -19.0729, 7.14683, 1.5, + -20, 10, -1.5, + -20, 10, 1.5, + -16, 10, -2, + -16, 10, 2, + -18.7639, 13.8042, -2, + -18.7639, 13.8042, 2, + -23.2361, 12.3511, -2, + -23.2361, 12.3511, 2, + -23.2361, 7.64886, -2, + -23.2361, 7.64886, 2, + -18.7639, 6.19577, -2, + -18.7639, 6.19577, 2, + -20, 10, -2, + -20, 10, 2, + -9, -20, -0.5, + -9, -20, 0.5, + -9.69098, -19.0489, -0.5, + -9.69098, -19.0489, 0.5, + -10.809, -19.4122, -0.5, + -10.809, -19.4122, 0.5, + -10.809, -20.5878, -0.5, + -10.809, -20.5878, 0.5, + -9.69098, -20.9511, -0.5, + -9.69098, -20.9511, 0.5, + -10, -20, -0.5, + -10, -20, 0.5, + -8, -20, -1, + -8, -20, 1, + -9.38197, -18.0979, -1, + -9.38197, -18.0979, 1, + -11.618, -18.8244, -1, + -11.618, -18.8244, 1, + -11.618, -21.1756, -1, + -11.618, -21.1756, 1, + -9.38197, -21.9021, -1, + -9.38197, -21.9021, 1, + -10, -20, -1, + -10, -20, 1, + -7, -20, -1.5, + -7, -20, 1.5, + -9.07295, -17.1468, -1.5, + -9.07295, -17.1468, 1.5, + -12.4271, -18.2366, -1.5, + -12.4271, -18.2366, 1.5, + -12.4271, -21.7634, -1.5, + -12.4271, -21.7634, 1.5, + -9.07295, -22.8532, -1.5, + -9.07295, -22.8532, 1.5, + -10, -20, -1.5, + -10, -20, 1.5, + -6, -20, -2, + -6, -20, 2, + -8.76393, -16.1958, -2, + -8.76393, -16.1958, 2, + -13.2361, -17.6489, -2, + -13.2361, -17.6489, 2, + -13.2361, -22.3511, -2, + -13.2361, -22.3511, 2, + -8.76393, -23.8042, -2, + -8.76393, -23.8042, 2, + -10, -20, -2, + -10, -20, 2, + -9, -10, -0.5, + -9, -10, 0.5, + -9.69098, -9.04894, -0.5, + -9.69098, -9.04894, 0.5, + -10.809, -9.41221, -0.5, + -10.809, -9.41221, 0.5, + -10.809, -10.5878, -0.5, + -10.809, -10.5878, 0.5, + -9.69098, -10.9511, -0.5, + -9.69098, -10.9511, 0.5, + -10, -10, -0.5, + -10, -10, 0.5, + -8, -10, -1, + -8, -10, 1, + -9.38197, -8.09789, -1, + -9.38197, -8.09789, 1, + -11.618, -8.82443, -1, + -11.618, -8.82443, 1, + -11.618, -11.1756, -1, + -11.618, -11.1756, 1, + -9.38197, -11.9021, -1, + -9.38197, -11.9021, 1, + -10, -10, -1, + -10, -10, 1, + -7, -10, -1.5, + -7, -10, 1.5, + -9.07295, -7.14683, -1.5, + -9.07295, -7.14683, 1.5, + -12.4271, -8.23664, -1.5, + -12.4271, -8.23664, 1.5, + -12.4271, -11.7634, -1.5, + -12.4271, -11.7634, 1.5, + -9.07295, -12.8532, -1.5, + -9.07295, -12.8532, 1.5, + -10, -10, -1.5, + -10, -10, 1.5, + -6, -10, -2, + -6, -10, 2, + -8.76393, -6.19577, -2, + -8.76393, -6.19577, 2, + -13.2361, -7.64886, -2, + -13.2361, -7.64886, 2, + -13.2361, -12.3511, -2, + -13.2361, -12.3511, 2, + -8.76393, -13.8042, -2, + -8.76393, -13.8042, 2, + -10, -10, -2, + -10, -10, 2, + -9, 0, -0.5, + -9, 0, 0.5, + -9.69098, 0.951057, -0.5, + -9.69098, 0.951057, 0.5, + -10.809, 0.587785, -0.5, + -10.809, 0.587785, 0.5, + -10.809, -0.587785, -0.5, + -10.809, -0.587785, 0.5, + -9.69098, -0.951057, -0.5, + -9.69098, -0.951057, 0.5, + -10, 0, -0.5, + -10, 0, 0.5, + -8, 0, -1, + -8, 0, 1, + -9.38197, 1.90211, -1, + -9.38197, 1.90211, 1, + -11.618, 1.17557, -1, + -11.618, 1.17557, 1, + -11.618, -1.17557, -1, + -11.618, -1.17557, 1, + -9.38197, -1.90211, -1, + -9.38197, -1.90211, 1, + -10, 0, -1, + -10, 0, 1, + -7, 0, -1.5, + -7, 0, 1.5, + -9.07295, 2.85317, -1.5, + -9.07295, 2.85317, 1.5, + -12.4271, 1.76336, -1.5, + -12.4271, 1.76336, 1.5, + -12.4271, -1.76336, -1.5, + -12.4271, -1.76336, 1.5, + -9.07295, -2.85317, -1.5, + -9.07295, -2.85317, 1.5, + -10, 0, -1.5, + -10, 0, 1.5, + -6, 0, -2, + -6, 0, 2, + -8.76393, 3.80423, -2, + -8.76393, 3.80423, 2, + -13.2361, 2.35114, -2, + -13.2361, 2.35114, 2, + -13.2361, -2.35114, -2, + -13.2361, -2.35114, 2, + -8.76393, -3.80423, -2, + -8.76393, -3.80423, 2, + -10, 0, -2, + -10, 0, 2, + -9, 10, -0.5, + -9, 10, 0.5, + -9.69098, 10.9511, -0.5, + -9.69098, 10.9511, 0.5, + -10.809, 10.5878, -0.5, + -10.809, 10.5878, 0.5, + -10.809, 9.41221, -0.5, + -10.809, 9.41221, 0.5, + -9.69098, 9.04894, -0.5, + -9.69098, 9.04894, 0.5, + -10, 10, -0.5, + -10, 10, 0.5, + -8, 10, -1, + -8, 10, 1, + -9.38197, 11.9021, -1, + -9.38197, 11.9021, 1, + -11.618, 11.1756, -1, + -11.618, 11.1756, 1, + -11.618, 8.82443, -1, + -11.618, 8.82443, 1, + -9.38197, 8.09789, -1, + -9.38197, 8.09789, 1, + -10, 10, -1, + -10, 10, 1, + -7, 10, -1.5, + -7, 10, 1.5, + -9.07295, 12.8532, -1.5, + -9.07295, 12.8532, 1.5, + -12.4271, 11.7634, -1.5, + -12.4271, 11.7634, 1.5, + -12.4271, 8.23664, -1.5, + -12.4271, 8.23664, 1.5, + -9.07295, 7.14683, -1.5, + -9.07295, 7.14683, 1.5, + -10, 10, -1.5, + -10, 10, 1.5, + -6, 10, -2, + -6, 10, 2, + -8.76393, 13.8042, -2, + -8.76393, 13.8042, 2, + -13.2361, 12.3511, -2, + -13.2361, 12.3511, 2, + -13.2361, 7.64886, -2, + -13.2361, 7.64886, 2, + -8.76393, 6.19577, -2, + -8.76393, 6.19577, 2, + -10, 10, -2, + -10, 10, 2, + 1, -20, -0.5, + 1, -20, 0.5, + 0.309017, -19.0489, -0.5, + 0.309017, -19.0489, 0.5, + -0.809017, -19.4122, -0.5, + -0.809017, -19.4122, 0.5, + -0.809017, -20.5878, -0.5, + -0.809017, -20.5878, 0.5, + 0.309017, -20.9511, -0.5, + 0.309017, -20.9511, 0.5, + 0, -20, -0.5, + 0, -20, 0.5, + 2, -20, -1, + 2, -20, 1, + 0.618034, -18.0979, -1, + 0.618034, -18.0979, 1, + -1.61803, -18.8244, -1, + -1.61803, -18.8244, 1, + -1.61803, -21.1756, -1, + -1.61803, -21.1756, 1, + 0.618034, -21.9021, -1, + 0.618034, -21.9021, 1, + 0, -20, -1, + 0, -20, 1, + 3, -20, -1.5, + 3, -20, 1.5, + 0.927051, -17.1468, -1.5, + 0.927051, -17.1468, 1.5, + -2.42705, -18.2366, -1.5, + -2.42705, -18.2366, 1.5, + -2.42705, -21.7634, -1.5, + -2.42705, -21.7634, 1.5, + 0.927051, -22.8532, -1.5, + 0.927051, -22.8532, 1.5, + 0, -20, -1.5, + 0, -20, 1.5, + 4, -20, -2, + 4, -20, 2, + 1.23607, -16.1958, -2, + 1.23607, -16.1958, 2, + -3.23607, -17.6489, -2, + -3.23607, -17.6489, 2, + -3.23607, -22.3511, -2, + -3.23607, -22.3511, 2, + 1.23607, -23.8042, -2, + 1.23607, -23.8042, 2, + 0, -20, -2, + 0, -20, 2, + 1, -10, -0.5, + 1, -10, 0.5, + 0.309017, -9.04894, -0.5, + 0.309017, -9.04894, 0.5, + -0.809017, -9.41221, -0.5, + -0.809017, -9.41221, 0.5, + -0.809017, -10.5878, -0.5, + -0.809017, -10.5878, 0.5, + 0.309017, -10.9511, -0.5, + 0.309017, -10.9511, 0.5, + 0, -10, -0.5, + 0, -10, 0.5, + 2, -10, -1, + 2, -10, 1, + 0.618034, -8.09789, -1, + 0.618034, -8.09789, 1, + -1.61803, -8.82443, -1, + -1.61803, -8.82443, 1, + -1.61803, -11.1756, -1, + -1.61803, -11.1756, 1, + 0.618034, -11.9021, -1, + 0.618034, -11.9021, 1, + 0, -10, -1, + 0, -10, 1, + 3, -10, -1.5, + 3, -10, 1.5, + 0.927051, -7.14683, -1.5, + 0.927051, -7.14683, 1.5, + -2.42705, -8.23664, -1.5, + -2.42705, -8.23664, 1.5, + -2.42705, -11.7634, -1.5, + -2.42705, -11.7634, 1.5, + 0.927051, -12.8532, -1.5, + 0.927051, -12.8532, 1.5, + 0, -10, -1.5, + 0, -10, 1.5, + 4, -10, -2, + 4, -10, 2, + 1.23607, -6.19577, -2, + 1.23607, -6.19577, 2, + -3.23607, -7.64886, -2, + -3.23607, -7.64886, 2, + -3.23607, -12.3511, -2, + -3.23607, -12.3511, 2, + 1.23607, -13.8042, -2, + 1.23607, -13.8042, 2, + 0, -10, -2, + 0, -10, 2, + 1, 0, -0.5, + 1, 0, 0.5, + 0.309017, 0.951057, -0.5, + 0.309017, 0.951057, 0.5, + -0.809017, 0.587785, -0.5, + -0.809017, 0.587785, 0.5, + -0.809017, -0.587785, -0.5, + -0.809017, -0.587785, 0.5, + 0.309017, -0.951057, -0.5, + 0.309017, -0.951057, 0.5, + 0, 0, -0.5, + 0, 0, 0.5, + 2, 0, -1, + 2, 0, 1, + 0.618034, 1.90211, -1, + 0.618034, 1.90211, 1, + -1.61803, 1.17557, -1, + -1.61803, 1.17557, 1, + -1.61803, -1.17557, -1, + -1.61803, -1.17557, 1, + 0.618034, -1.90211, -1, + 0.618034, -1.90211, 1, + 0, 0, -1, + 0, 0, 1, + 3, 0, -1.5, + 3, 0, 1.5, + 0.927051, 2.85317, -1.5, + 0.927051, 2.85317, 1.5, + -2.42705, 1.76336, -1.5, + -2.42705, 1.76336, 1.5, + -2.42705, -1.76336, -1.5, + -2.42705, -1.76336, 1.5, + 0.927051, -2.85317, -1.5, + 0.927051, -2.85317, 1.5, + 0, 0, -1.5, + 0, 0, 1.5, + 4, 0, -2, + 4, 0, 2, + 1.23607, 3.80423, -2, + 1.23607, 3.80423, 2, + -3.23607, 2.35114, -2, + -3.23607, 2.35114, 2, + -3.23607, -2.35114, -2, + -3.23607, -2.35114, 2, + 1.23607, -3.80423, -2, + 1.23607, -3.80423, 2, + 0, 0, -2, + 0, 0, 2, + 1, 10, -0.5, + 1, 10, 0.5, + 0.309017, 10.9511, -0.5, + 0.309017, 10.9511, 0.5, + -0.809017, 10.5878, -0.5, + -0.809017, 10.5878, 0.5, + -0.809017, 9.41221, -0.5, + -0.809017, 9.41221, 0.5, + 0.309017, 9.04894, -0.5, + 0.309017, 9.04894, 0.5, + 0, 10, -0.5, + 0, 10, 0.5, + 2, 10, -1, + 2, 10, 1, + 0.618034, 11.9021, -1, + 0.618034, 11.9021, 1, + -1.61803, 11.1756, -1, + -1.61803, 11.1756, 1, + -1.61803, 8.82443, -1, + -1.61803, 8.82443, 1, + 0.618034, 8.09789, -1, + 0.618034, 8.09789, 1, + 0, 10, -1, + 0, 10, 1, + 3, 10, -1.5, + 3, 10, 1.5, + 0.927051, 12.8532, -1.5, + 0.927051, 12.8532, 1.5, + -2.42705, 11.7634, -1.5, + -2.42705, 11.7634, 1.5, + -2.42705, 8.23664, -1.5, + -2.42705, 8.23664, 1.5, + 0.927051, 7.14683, -1.5, + 0.927051, 7.14683, 1.5, + 0, 10, -1.5, + 0, 10, 1.5, + 4, 10, -2, + 4, 10, 2, + 1.23607, 13.8042, -2, + 1.23607, 13.8042, 2, + -3.23607, 12.3511, -2, + -3.23607, 12.3511, 2, + -3.23607, 7.64886, -2, + -3.23607, 7.64886, 2, + 1.23607, 6.19577, -2, + 1.23607, 6.19577, 2, + 0, 10, -2, + 0, 10, 2, + 11, -20, -0.5, + 11, -20, 0.5, + 10.309, -19.0489, -0.5, + 10.309, -19.0489, 0.5, + 9.19098, -19.4122, -0.5, + 9.19098, -19.4122, 0.5, + 9.19098, -20.5878, -0.5, + 9.19098, -20.5878, 0.5, + 10.309, -20.9511, -0.5, + 10.309, -20.9511, 0.5, + 10, -20, -0.5, + 10, -20, 0.5, + 12, -20, -1, + 12, -20, 1, + 10.618, -18.0979, -1, + 10.618, -18.0979, 1, + 8.38197, -18.8244, -1, + 8.38197, -18.8244, 1, + 8.38197, -21.1756, -1, + 8.38197, -21.1756, 1, + 10.618, -21.9021, -1, + 10.618, -21.9021, 1, + 10, -20, -1, + 10, -20, 1, + 13, -20, -1.5, + 13, -20, 1.5, + 10.9271, -17.1468, -1.5, + 10.9271, -17.1468, 1.5, + 7.57295, -18.2366, -1.5, + 7.57295, -18.2366, 1.5, + 7.57295, -21.7634, -1.5, + 7.57295, -21.7634, 1.5, + 10.9271, -22.8532, -1.5, + 10.9271, -22.8532, 1.5, + 10, -20, -1.5, + 10, -20, 1.5, + 14, -20, -2, + 14, -20, 2, + 11.2361, -16.1958, -2, + 11.2361, -16.1958, 2, + 6.76393, -17.6489, -2, + 6.76393, -17.6489, 2, + 6.76393, -22.3511, -2, + 6.76393, -22.3511, 2, + 11.2361, -23.8042, -2, + 11.2361, -23.8042, 2, + 10, -20, -2, + 10, -20, 2, + 11, -10, -0.5, + 11, -10, 0.5, + 10.309, -9.04894, -0.5, + 10.309, -9.04894, 0.5, + 9.19098, -9.41221, -0.5, + 9.19098, -9.41221, 0.5, + 9.19098, -10.5878, -0.5, + 9.19098, -10.5878, 0.5, + 10.309, -10.9511, -0.5, + 10.309, -10.9511, 0.5, + 10, -10, -0.5, + 10, -10, 0.5, + 12, -10, -1, + 12, -10, 1, + 10.618, -8.09789, -1, + 10.618, -8.09789, 1, + 8.38197, -8.82443, -1, + 8.38197, -8.82443, 1, + 8.38197, -11.1756, -1, + 8.38197, -11.1756, 1, + 10.618, -11.9021, -1, + 10.618, -11.9021, 1, + 10, -10, -1, + 10, -10, 1, + 13, -10, -1.5, + 13, -10, 1.5, + 10.9271, -7.14683, -1.5, + 10.9271, -7.14683, 1.5, + 7.57295, -8.23664, -1.5, + 7.57295, -8.23664, 1.5, + 7.57295, -11.7634, -1.5, + 7.57295, -11.7634, 1.5, + 10.9271, -12.8532, -1.5, + 10.9271, -12.8532, 1.5, + 10, -10, -1.5, + 10, -10, 1.5, + 14, -10, -2, + 14, -10, 2, + 11.2361, -6.19577, -2, + 11.2361, -6.19577, 2, + 6.76393, -7.64886, -2, + 6.76393, -7.64886, 2, + 6.76393, -12.3511, -2, + 6.76393, -12.3511, 2, + 11.2361, -13.8042, -2, + 11.2361, -13.8042, 2, + 10, -10, -2, + 10, -10, 2, + 11, 0, -0.5, + 11, 0, 0.5, + 10.309, 0.951057, -0.5, + 10.309, 0.951057, 0.5, + 9.19098, 0.587785, -0.5, + 9.19098, 0.587785, 0.5, + 9.19098, -0.587785, -0.5, + 9.19098, -0.587785, 0.5, + 10.309, -0.951057, -0.5, + 10.309, -0.951057, 0.5, + 10, 0, -0.5, + 10, 0, 0.5, + 12, 0, -1, + 12, 0, 1, + 10.618, 1.90211, -1, + 10.618, 1.90211, 1, + 8.38197, 1.17557, -1, + 8.38197, 1.17557, 1, + 8.38197, -1.17557, -1, + 8.38197, -1.17557, 1, + 10.618, -1.90211, -1, + 10.618, -1.90211, 1, + 10, 0, -1, + 10, 0, 1, + 13, 0, -1.5, + 13, 0, 1.5, + 10.9271, 2.85317, -1.5, + 10.9271, 2.85317, 1.5, + 7.57295, 1.76336, -1.5, + 7.57295, 1.76336, 1.5, + 7.57295, -1.76336, -1.5, + 7.57295, -1.76336, 1.5, + 10.9271, -2.85317, -1.5, + 10.9271, -2.85317, 1.5, + 10, 0, -1.5, + 10, 0, 1.5, + 14, 0, -2, + 14, 0, 2, + 11.2361, 3.80423, -2, + 11.2361, 3.80423, 2, + 6.76393, 2.35114, -2, + 6.76393, 2.35114, 2, + 6.76393, -2.35114, -2, + 6.76393, -2.35114, 2, + 11.2361, -3.80423, -2, + 11.2361, -3.80423, 2, + 10, 0, -2, + 10, 0, 2, + 11, 10, -0.5, + 11, 10, 0.5, + 10.309, 10.9511, -0.5, + 10.309, 10.9511, 0.5, + 9.19098, 10.5878, -0.5, + 9.19098, 10.5878, 0.5, + 9.19098, 9.41221, -0.5, + 9.19098, 9.41221, 0.5, + 10.309, 9.04894, -0.5, + 10.309, 9.04894, 0.5, + 10, 10, -0.5, + 10, 10, 0.5, + 12, 10, -1, + 12, 10, 1, + 10.618, 11.9021, -1, + 10.618, 11.9021, 1, + 8.38197, 11.1756, -1, + 8.38197, 11.1756, 1, + 8.38197, 8.82443, -1, + 8.38197, 8.82443, 1, + 10.618, 8.09789, -1, + 10.618, 8.09789, 1, + 10, 10, -1, + 10, 10, 1, + 13, 10, -1.5, + 13, 10, 1.5, + 10.9271, 12.8532, -1.5, + 10.9271, 12.8532, 1.5, + 7.57295, 11.7634, -1.5, + 7.57295, 11.7634, 1.5, + 7.57295, 8.23664, -1.5, + 7.57295, 8.23664, 1.5, + 10.9271, 7.14683, -1.5, + 10.9271, 7.14683, 1.5, + 10, 10, -1.5, + 10, 10, 1.5, + 14, 10, -2, + 14, 10, 2, + 11.2361, 13.8042, -2, + 11.2361, 13.8042, 2, + 6.76393, 12.3511, -2, + 6.76393, 12.3511, 2, + 6.76393, 7.64886, -2, + 6.76393, 7.64886, 2, + 11.2361, 6.19577, -2, + 11.2361, 6.19577, 2, + 10, 10, -2, + 10, 10, 2 +}; +static const unsigned some_enclosures_triangles_count = 1280; +static const unsigned some_enclosures_triangles[3840] = +{ + 0, 1, 2, + 2, 1, 3, + 2, 3, 4, + 4, 3, 5, + 4, 5, 6, + 6, 5, 7, + 6, 7, 8, + 8, 7, 9, + 8, 9, 0, + 0, 9, 1, + 10, 0, 2, + 10, 2, 4, + 10, 4, 6, + 10, 6, 8, + 10, 8, 0, + 11, 3, 1, + 11, 5, 3, + 11, 7, 5, + 11, 9, 7, + 11, 1, 9, + 12, 13, 14, + 14, 13, 15, + 14, 15, 16, + 16, 15, 17, + 16, 17, 18, + 18, 17, 19, + 18, 19, 20, + 20, 19, 21, + 20, 21, 12, + 12, 21, 13, + 22, 12, 14, + 22, 14, 16, + 22, 16, 18, + 22, 18, 20, + 22, 20, 12, + 23, 15, 13, + 23, 17, 15, + 23, 19, 17, + 23, 21, 19, + 23, 13, 21, + 24, 25, 26, + 26, 25, 27, + 26, 27, 28, + 28, 27, 29, + 28, 29, 30, + 30, 29, 31, + 30, 31, 32, + 32, 31, 33, + 32, 33, 24, + 24, 33, 25, + 34, 24, 26, + 34, 26, 28, + 34, 28, 30, + 34, 30, 32, + 34, 32, 24, + 35, 27, 25, + 35, 29, 27, + 35, 31, 29, + 35, 33, 31, + 35, 25, 33, + 36, 37, 38, + 38, 37, 39, + 38, 39, 40, + 40, 39, 41, + 40, 41, 42, + 42, 41, 43, + 42, 43, 44, + 44, 43, 45, + 44, 45, 36, + 36, 45, 37, + 46, 36, 38, + 46, 38, 40, + 46, 40, 42, + 46, 42, 44, + 46, 44, 36, + 47, 39, 37, + 47, 41, 39, + 47, 43, 41, + 47, 45, 43, + 47, 37, 45, + 48, 49, 50, + 50, 49, 51, + 50, 51, 52, + 52, 51, 53, + 52, 53, 54, + 54, 53, 55, + 54, 55, 56, + 56, 55, 57, + 56, 57, 48, + 48, 57, 49, + 58, 48, 50, + 58, 50, 52, + 58, 52, 54, + 58, 54, 56, + 58, 56, 48, + 59, 51, 49, + 59, 53, 51, + 59, 55, 53, + 59, 57, 55, + 59, 49, 57, + 60, 61, 62, + 62, 61, 63, + 62, 63, 64, + 64, 63, 65, + 64, 65, 66, + 66, 65, 67, + 66, 67, 68, + 68, 67, 69, + 68, 69, 60, + 60, 69, 61, + 70, 60, 62, + 70, 62, 64, + 70, 64, 66, + 70, 66, 68, + 70, 68, 60, + 71, 63, 61, + 71, 65, 63, + 71, 67, 65, + 71, 69, 67, + 71, 61, 69, + 72, 73, 74, + 74, 73, 75, + 74, 75, 76, + 76, 75, 77, + 76, 77, 78, + 78, 77, 79, + 78, 79, 80, + 80, 79, 81, + 80, 81, 72, + 72, 81, 73, + 82, 72, 74, + 82, 74, 76, + 82, 76, 78, + 82, 78, 80, + 82, 80, 72, + 83, 75, 73, + 83, 77, 75, + 83, 79, 77, + 83, 81, 79, + 83, 73, 81, + 84, 85, 86, + 86, 85, 87, + 86, 87, 88, + 88, 87, 89, + 88, 89, 90, + 90, 89, 91, + 90, 91, 92, + 92, 91, 93, + 92, 93, 84, + 84, 93, 85, + 94, 84, 86, + 94, 86, 88, + 94, 88, 90, + 94, 90, 92, + 94, 92, 84, + 95, 87, 85, + 95, 89, 87, + 95, 91, 89, + 95, 93, 91, + 95, 85, 93, + 96, 97, 98, + 98, 97, 99, + 98, 99, 100, + 100, 99, 101, + 100, 101, 102, + 102, 101, 103, + 102, 103, 104, + 104, 103, 105, + 104, 105, 96, + 96, 105, 97, + 106, 96, 98, + 106, 98, 100, + 106, 100, 102, + 106, 102, 104, + 106, 104, 96, + 107, 99, 97, + 107, 101, 99, + 107, 103, 101, + 107, 105, 103, + 107, 97, 105, + 108, 109, 110, + 110, 109, 111, + 110, 111, 112, + 112, 111, 113, + 112, 113, 114, + 114, 113, 115, + 114, 115, 116, + 116, 115, 117, + 116, 117, 108, + 108, 117, 109, + 118, 108, 110, + 118, 110, 112, + 118, 112, 114, + 118, 114, 116, + 118, 116, 108, + 119, 111, 109, + 119, 113, 111, + 119, 115, 113, + 119, 117, 115, + 119, 109, 117, + 120, 121, 122, + 122, 121, 123, + 122, 123, 124, + 124, 123, 125, + 124, 125, 126, + 126, 125, 127, + 126, 127, 128, + 128, 127, 129, + 128, 129, 120, + 120, 129, 121, + 130, 120, 122, + 130, 122, 124, + 130, 124, 126, + 130, 126, 128, + 130, 128, 120, + 131, 123, 121, + 131, 125, 123, + 131, 127, 125, + 131, 129, 127, + 131, 121, 129, + 132, 133, 134, + 134, 133, 135, + 134, 135, 136, + 136, 135, 137, + 136, 137, 138, + 138, 137, 139, + 138, 139, 140, + 140, 139, 141, + 140, 141, 132, + 132, 141, 133, + 142, 132, 134, + 142, 134, 136, + 142, 136, 138, + 142, 138, 140, + 142, 140, 132, + 143, 135, 133, + 143, 137, 135, + 143, 139, 137, + 143, 141, 139, + 143, 133, 141, + 144, 145, 146, + 146, 145, 147, + 146, 147, 148, + 148, 147, 149, + 148, 149, 150, + 150, 149, 151, + 150, 151, 152, + 152, 151, 153, + 152, 153, 144, + 144, 153, 145, + 154, 144, 146, + 154, 146, 148, + 154, 148, 150, + 154, 150, 152, + 154, 152, 144, + 155, 147, 145, + 155, 149, 147, + 155, 151, 149, + 155, 153, 151, + 155, 145, 153, + 156, 157, 158, + 158, 157, 159, + 158, 159, 160, + 160, 159, 161, + 160, 161, 162, + 162, 161, 163, + 162, 163, 164, + 164, 163, 165, + 164, 165, 156, + 156, 165, 157, + 166, 156, 158, + 166, 158, 160, + 166, 160, 162, + 166, 162, 164, + 166, 164, 156, + 167, 159, 157, + 167, 161, 159, + 167, 163, 161, + 167, 165, 163, + 167, 157, 165, + 168, 169, 170, + 170, 169, 171, + 170, 171, 172, + 172, 171, 173, + 172, 173, 174, + 174, 173, 175, + 174, 175, 176, + 176, 175, 177, + 176, 177, 168, + 168, 177, 169, + 178, 168, 170, + 178, 170, 172, + 178, 172, 174, + 178, 174, 176, + 178, 176, 168, + 179, 171, 169, + 179, 173, 171, + 179, 175, 173, + 179, 177, 175, + 179, 169, 177, + 180, 181, 182, + 182, 181, 183, + 182, 183, 184, + 184, 183, 185, + 184, 185, 186, + 186, 185, 187, + 186, 187, 188, + 188, 187, 189, + 188, 189, 180, + 180, 189, 181, + 190, 180, 182, + 190, 182, 184, + 190, 184, 186, + 190, 186, 188, + 190, 188, 180, + 191, 183, 181, + 191, 185, 183, + 191, 187, 185, + 191, 189, 187, + 191, 181, 189, + 192, 193, 194, + 194, 193, 195, + 194, 195, 196, + 196, 195, 197, + 196, 197, 198, + 198, 197, 199, + 198, 199, 200, + 200, 199, 201, + 200, 201, 192, + 192, 201, 193, + 202, 192, 194, + 202, 194, 196, + 202, 196, 198, + 202, 198, 200, + 202, 200, 192, + 203, 195, 193, + 203, 197, 195, + 203, 199, 197, + 203, 201, 199, + 203, 193, 201, + 204, 205, 206, + 206, 205, 207, + 206, 207, 208, + 208, 207, 209, + 208, 209, 210, + 210, 209, 211, + 210, 211, 212, + 212, 211, 213, + 212, 213, 204, + 204, 213, 205, + 214, 204, 206, + 214, 206, 208, + 214, 208, 210, + 214, 210, 212, + 214, 212, 204, + 215, 207, 205, + 215, 209, 207, + 215, 211, 209, + 215, 213, 211, + 215, 205, 213, + 216, 217, 218, + 218, 217, 219, + 218, 219, 220, + 220, 219, 221, + 220, 221, 222, + 222, 221, 223, + 222, 223, 224, + 224, 223, 225, + 224, 225, 216, + 216, 225, 217, + 226, 216, 218, + 226, 218, 220, + 226, 220, 222, + 226, 222, 224, + 226, 224, 216, + 227, 219, 217, + 227, 221, 219, + 227, 223, 221, + 227, 225, 223, + 227, 217, 225, + 228, 229, 230, + 230, 229, 231, + 230, 231, 232, + 232, 231, 233, + 232, 233, 234, + 234, 233, 235, + 234, 235, 236, + 236, 235, 237, + 236, 237, 228, + 228, 237, 229, + 238, 228, 230, + 238, 230, 232, + 238, 232, 234, + 238, 234, 236, + 238, 236, 228, + 239, 231, 229, + 239, 233, 231, + 239, 235, 233, + 239, 237, 235, + 239, 229, 237, + 240, 241, 242, + 242, 241, 243, + 242, 243, 244, + 244, 243, 245, + 244, 245, 246, + 246, 245, 247, + 246, 247, 248, + 248, 247, 249, + 248, 249, 240, + 240, 249, 241, + 250, 240, 242, + 250, 242, 244, + 250, 244, 246, + 250, 246, 248, + 250, 248, 240, + 251, 243, 241, + 251, 245, 243, + 251, 247, 245, + 251, 249, 247, + 251, 241, 249, + 252, 253, 254, + 254, 253, 255, + 254, 255, 256, + 256, 255, 257, + 256, 257, 258, + 258, 257, 259, + 258, 259, 260, + 260, 259, 261, + 260, 261, 252, + 252, 261, 253, + 262, 252, 254, + 262, 254, 256, + 262, 256, 258, + 262, 258, 260, + 262, 260, 252, + 263, 255, 253, + 263, 257, 255, + 263, 259, 257, + 263, 261, 259, + 263, 253, 261, + 264, 265, 266, + 266, 265, 267, + 266, 267, 268, + 268, 267, 269, + 268, 269, 270, + 270, 269, 271, + 270, 271, 272, + 272, 271, 273, + 272, 273, 264, + 264, 273, 265, + 274, 264, 266, + 274, 266, 268, + 274, 268, 270, + 274, 270, 272, + 274, 272, 264, + 275, 267, 265, + 275, 269, 267, + 275, 271, 269, + 275, 273, 271, + 275, 265, 273, + 276, 277, 278, + 278, 277, 279, + 278, 279, 280, + 280, 279, 281, + 280, 281, 282, + 282, 281, 283, + 282, 283, 284, + 284, 283, 285, + 284, 285, 276, + 276, 285, 277, + 286, 276, 278, + 286, 278, 280, + 286, 280, 282, + 286, 282, 284, + 286, 284, 276, + 287, 279, 277, + 287, 281, 279, + 287, 283, 281, + 287, 285, 283, + 287, 277, 285, + 288, 289, 290, + 290, 289, 291, + 290, 291, 292, + 292, 291, 293, + 292, 293, 294, + 294, 293, 295, + 294, 295, 296, + 296, 295, 297, + 296, 297, 288, + 288, 297, 289, + 298, 288, 290, + 298, 290, 292, + 298, 292, 294, + 298, 294, 296, + 298, 296, 288, + 299, 291, 289, + 299, 293, 291, + 299, 295, 293, + 299, 297, 295, + 299, 289, 297, + 300, 301, 302, + 302, 301, 303, + 302, 303, 304, + 304, 303, 305, + 304, 305, 306, + 306, 305, 307, + 306, 307, 308, + 308, 307, 309, + 308, 309, 300, + 300, 309, 301, + 310, 300, 302, + 310, 302, 304, + 310, 304, 306, + 310, 306, 308, + 310, 308, 300, + 311, 303, 301, + 311, 305, 303, + 311, 307, 305, + 311, 309, 307, + 311, 301, 309, + 312, 313, 314, + 314, 313, 315, + 314, 315, 316, + 316, 315, 317, + 316, 317, 318, + 318, 317, 319, + 318, 319, 320, + 320, 319, 321, + 320, 321, 312, + 312, 321, 313, + 322, 312, 314, + 322, 314, 316, + 322, 316, 318, + 322, 318, 320, + 322, 320, 312, + 323, 315, 313, + 323, 317, 315, + 323, 319, 317, + 323, 321, 319, + 323, 313, 321, + 324, 325, 326, + 326, 325, 327, + 326, 327, 328, + 328, 327, 329, + 328, 329, 330, + 330, 329, 331, + 330, 331, 332, + 332, 331, 333, + 332, 333, 324, + 324, 333, 325, + 334, 324, 326, + 334, 326, 328, + 334, 328, 330, + 334, 330, 332, + 334, 332, 324, + 335, 327, 325, + 335, 329, 327, + 335, 331, 329, + 335, 333, 331, + 335, 325, 333, + 336, 337, 338, + 338, 337, 339, + 338, 339, 340, + 340, 339, 341, + 340, 341, 342, + 342, 341, 343, + 342, 343, 344, + 344, 343, 345, + 344, 345, 336, + 336, 345, 337, + 346, 336, 338, + 346, 338, 340, + 346, 340, 342, + 346, 342, 344, + 346, 344, 336, + 347, 339, 337, + 347, 341, 339, + 347, 343, 341, + 347, 345, 343, + 347, 337, 345, + 348, 349, 350, + 350, 349, 351, + 350, 351, 352, + 352, 351, 353, + 352, 353, 354, + 354, 353, 355, + 354, 355, 356, + 356, 355, 357, + 356, 357, 348, + 348, 357, 349, + 358, 348, 350, + 358, 350, 352, + 358, 352, 354, + 358, 354, 356, + 358, 356, 348, + 359, 351, 349, + 359, 353, 351, + 359, 355, 353, + 359, 357, 355, + 359, 349, 357, + 360, 361, 362, + 362, 361, 363, + 362, 363, 364, + 364, 363, 365, + 364, 365, 366, + 366, 365, 367, + 366, 367, 368, + 368, 367, 369, + 368, 369, 360, + 360, 369, 361, + 370, 360, 362, + 370, 362, 364, + 370, 364, 366, + 370, 366, 368, + 370, 368, 360, + 371, 363, 361, + 371, 365, 363, + 371, 367, 365, + 371, 369, 367, + 371, 361, 369, + 372, 373, 374, + 374, 373, 375, + 374, 375, 376, + 376, 375, 377, + 376, 377, 378, + 378, 377, 379, + 378, 379, 380, + 380, 379, 381, + 380, 381, 372, + 372, 381, 373, + 382, 372, 374, + 382, 374, 376, + 382, 376, 378, + 382, 378, 380, + 382, 380, 372, + 383, 375, 373, + 383, 377, 375, + 383, 379, 377, + 383, 381, 379, + 383, 373, 381, + 384, 385, 386, + 386, 385, 387, + 386, 387, 388, + 388, 387, 389, + 388, 389, 390, + 390, 389, 391, + 390, 391, 392, + 392, 391, 393, + 392, 393, 384, + 384, 393, 385, + 394, 384, 386, + 394, 386, 388, + 394, 388, 390, + 394, 390, 392, + 394, 392, 384, + 395, 387, 385, + 395, 389, 387, + 395, 391, 389, + 395, 393, 391, + 395, 385, 393, + 396, 397, 398, + 398, 397, 399, + 398, 399, 400, + 400, 399, 401, + 400, 401, 402, + 402, 401, 403, + 402, 403, 404, + 404, 403, 405, + 404, 405, 396, + 396, 405, 397, + 406, 396, 398, + 406, 398, 400, + 406, 400, 402, + 406, 402, 404, + 406, 404, 396, + 407, 399, 397, + 407, 401, 399, + 407, 403, 401, + 407, 405, 403, + 407, 397, 405, + 408, 409, 410, + 410, 409, 411, + 410, 411, 412, + 412, 411, 413, + 412, 413, 414, + 414, 413, 415, + 414, 415, 416, + 416, 415, 417, + 416, 417, 408, + 408, 417, 409, + 418, 408, 410, + 418, 410, 412, + 418, 412, 414, + 418, 414, 416, + 418, 416, 408, + 419, 411, 409, + 419, 413, 411, + 419, 415, 413, + 419, 417, 415, + 419, 409, 417, + 420, 421, 422, + 422, 421, 423, + 422, 423, 424, + 424, 423, 425, + 424, 425, 426, + 426, 425, 427, + 426, 427, 428, + 428, 427, 429, + 428, 429, 420, + 420, 429, 421, + 430, 420, 422, + 430, 422, 424, + 430, 424, 426, + 430, 426, 428, + 430, 428, 420, + 431, 423, 421, + 431, 425, 423, + 431, 427, 425, + 431, 429, 427, + 431, 421, 429, + 432, 433, 434, + 434, 433, 435, + 434, 435, 436, + 436, 435, 437, + 436, 437, 438, + 438, 437, 439, + 438, 439, 440, + 440, 439, 441, + 440, 441, 432, + 432, 441, 433, + 442, 432, 434, + 442, 434, 436, + 442, 436, 438, + 442, 438, 440, + 442, 440, 432, + 443, 435, 433, + 443, 437, 435, + 443, 439, 437, + 443, 441, 439, + 443, 433, 441, + 444, 445, 446, + 446, 445, 447, + 446, 447, 448, + 448, 447, 449, + 448, 449, 450, + 450, 449, 451, + 450, 451, 452, + 452, 451, 453, + 452, 453, 444, + 444, 453, 445, + 454, 444, 446, + 454, 446, 448, + 454, 448, 450, + 454, 450, 452, + 454, 452, 444, + 455, 447, 445, + 455, 449, 447, + 455, 451, 449, + 455, 453, 451, + 455, 445, 453, + 456, 457, 458, + 458, 457, 459, + 458, 459, 460, + 460, 459, 461, + 460, 461, 462, + 462, 461, 463, + 462, 463, 464, + 464, 463, 465, + 464, 465, 456, + 456, 465, 457, + 466, 456, 458, + 466, 458, 460, + 466, 460, 462, + 466, 462, 464, + 466, 464, 456, + 467, 459, 457, + 467, 461, 459, + 467, 463, 461, + 467, 465, 463, + 467, 457, 465, + 468, 469, 470, + 470, 469, 471, + 470, 471, 472, + 472, 471, 473, + 472, 473, 474, + 474, 473, 475, + 474, 475, 476, + 476, 475, 477, + 476, 477, 468, + 468, 477, 469, + 478, 468, 470, + 478, 470, 472, + 478, 472, 474, + 478, 474, 476, + 478, 476, 468, + 479, 471, 469, + 479, 473, 471, + 479, 475, 473, + 479, 477, 475, + 479, 469, 477, + 480, 481, 482, + 482, 481, 483, + 482, 483, 484, + 484, 483, 485, + 484, 485, 486, + 486, 485, 487, + 486, 487, 488, + 488, 487, 489, + 488, 489, 480, + 480, 489, 481, + 490, 480, 482, + 490, 482, 484, + 490, 484, 486, + 490, 486, 488, + 490, 488, 480, + 491, 483, 481, + 491, 485, 483, + 491, 487, 485, + 491, 489, 487, + 491, 481, 489, + 492, 493, 494, + 494, 493, 495, + 494, 495, 496, + 496, 495, 497, + 496, 497, 498, + 498, 497, 499, + 498, 499, 500, + 500, 499, 501, + 500, 501, 492, + 492, 501, 493, + 502, 492, 494, + 502, 494, 496, + 502, 496, 498, + 502, 498, 500, + 502, 500, 492, + 503, 495, 493, + 503, 497, 495, + 503, 499, 497, + 503, 501, 499, + 503, 493, 501, + 504, 505, 506, + 506, 505, 507, + 506, 507, 508, + 508, 507, 509, + 508, 509, 510, + 510, 509, 511, + 510, 511, 512, + 512, 511, 513, + 512, 513, 504, + 504, 513, 505, + 514, 504, 506, + 514, 506, 508, + 514, 508, 510, + 514, 510, 512, + 514, 512, 504, + 515, 507, 505, + 515, 509, 507, + 515, 511, 509, + 515, 513, 511, + 515, 505, 513, + 516, 517, 518, + 518, 517, 519, + 518, 519, 520, + 520, 519, 521, + 520, 521, 522, + 522, 521, 523, + 522, 523, 524, + 524, 523, 525, + 524, 525, 516, + 516, 525, 517, + 526, 516, 518, + 526, 518, 520, + 526, 520, 522, + 526, 522, 524, + 526, 524, 516, + 527, 519, 517, + 527, 521, 519, + 527, 523, 521, + 527, 525, 523, + 527, 517, 525, + 528, 529, 530, + 530, 529, 531, + 530, 531, 532, + 532, 531, 533, + 532, 533, 534, + 534, 533, 535, + 534, 535, 536, + 536, 535, 537, + 536, 537, 528, + 528, 537, 529, + 538, 528, 530, + 538, 530, 532, + 538, 532, 534, + 538, 534, 536, + 538, 536, 528, + 539, 531, 529, + 539, 533, 531, + 539, 535, 533, + 539, 537, 535, + 539, 529, 537, + 540, 541, 542, + 542, 541, 543, + 542, 543, 544, + 544, 543, 545, + 544, 545, 546, + 546, 545, 547, + 546, 547, 548, + 548, 547, 549, + 548, 549, 540, + 540, 549, 541, + 550, 540, 542, + 550, 542, 544, + 550, 544, 546, + 550, 546, 548, + 550, 548, 540, + 551, 543, 541, + 551, 545, 543, + 551, 547, 545, + 551, 549, 547, + 551, 541, 549, + 552, 553, 554, + 554, 553, 555, + 554, 555, 556, + 556, 555, 557, + 556, 557, 558, + 558, 557, 559, + 558, 559, 560, + 560, 559, 561, + 560, 561, 552, + 552, 561, 553, + 562, 552, 554, + 562, 554, 556, + 562, 556, 558, + 562, 558, 560, + 562, 560, 552, + 563, 555, 553, + 563, 557, 555, + 563, 559, 557, + 563, 561, 559, + 563, 553, 561, + 564, 565, 566, + 566, 565, 567, + 566, 567, 568, + 568, 567, 569, + 568, 569, 570, + 570, 569, 571, + 570, 571, 572, + 572, 571, 573, + 572, 573, 564, + 564, 573, 565, + 574, 564, 566, + 574, 566, 568, + 574, 568, 570, + 574, 570, 572, + 574, 572, 564, + 575, 567, 565, + 575, 569, 567, + 575, 571, 569, + 575, 573, 571, + 575, 565, 573, + 576, 577, 578, + 578, 577, 579, + 578, 579, 580, + 580, 579, 581, + 580, 581, 582, + 582, 581, 583, + 582, 583, 584, + 584, 583, 585, + 584, 585, 576, + 576, 585, 577, + 586, 576, 578, + 586, 578, 580, + 586, 580, 582, + 586, 582, 584, + 586, 584, 576, + 587, 579, 577, + 587, 581, 579, + 587, 583, 581, + 587, 585, 583, + 587, 577, 585, + 588, 589, 590, + 590, 589, 591, + 590, 591, 592, + 592, 591, 593, + 592, 593, 594, + 594, 593, 595, + 594, 595, 596, + 596, 595, 597, + 596, 597, 588, + 588, 597, 589, + 598, 588, 590, + 598, 590, 592, + 598, 592, 594, + 598, 594, 596, + 598, 596, 588, + 599, 591, 589, + 599, 593, 591, + 599, 595, 593, + 599, 597, 595, + 599, 589, 597, + 600, 601, 602, + 602, 601, 603, + 602, 603, 604, + 604, 603, 605, + 604, 605, 606, + 606, 605, 607, + 606, 607, 608, + 608, 607, 609, + 608, 609, 600, + 600, 609, 601, + 610, 600, 602, + 610, 602, 604, + 610, 604, 606, + 610, 606, 608, + 610, 608, 600, + 611, 603, 601, + 611, 605, 603, + 611, 607, 605, + 611, 609, 607, + 611, 601, 609, + 612, 613, 614, + 614, 613, 615, + 614, 615, 616, + 616, 615, 617, + 616, 617, 618, + 618, 617, 619, + 618, 619, 620, + 620, 619, 621, + 620, 621, 612, + 612, 621, 613, + 622, 612, 614, + 622, 614, 616, + 622, 616, 618, + 622, 618, 620, + 622, 620, 612, + 623, 615, 613, + 623, 617, 615, + 623, 619, 617, + 623, 621, 619, + 623, 613, 621, + 624, 625, 626, + 626, 625, 627, + 626, 627, 628, + 628, 627, 629, + 628, 629, 630, + 630, 629, 631, + 630, 631, 632, + 632, 631, 633, + 632, 633, 624, + 624, 633, 625, + 634, 624, 626, + 634, 626, 628, + 634, 628, 630, + 634, 630, 632, + 634, 632, 624, + 635, 627, 625, + 635, 629, 627, + 635, 631, 629, + 635, 633, 631, + 635, 625, 633, + 636, 637, 638, + 638, 637, 639, + 638, 639, 640, + 640, 639, 641, + 640, 641, 642, + 642, 641, 643, + 642, 643, 644, + 644, 643, 645, + 644, 645, 636, + 636, 645, 637, + 646, 636, 638, + 646, 638, 640, + 646, 640, 642, + 646, 642, 644, + 646, 644, 636, + 647, 639, 637, + 647, 641, 639, + 647, 643, 641, + 647, 645, 643, + 647, 637, 645, + 648, 649, 650, + 650, 649, 651, + 650, 651, 652, + 652, 651, 653, + 652, 653, 654, + 654, 653, 655, + 654, 655, 656, + 656, 655, 657, + 656, 657, 648, + 648, 657, 649, + 658, 648, 650, + 658, 650, 652, + 658, 652, 654, + 658, 654, 656, + 658, 656, 648, + 659, 651, 649, + 659, 653, 651, + 659, 655, 653, + 659, 657, 655, + 659, 649, 657, + 660, 661, 662, + 662, 661, 663, + 662, 663, 664, + 664, 663, 665, + 664, 665, 666, + 666, 665, 667, + 666, 667, 668, + 668, 667, 669, + 668, 669, 660, + 660, 669, 661, + 670, 660, 662, + 670, 662, 664, + 670, 664, 666, + 670, 666, 668, + 670, 668, 660, + 671, 663, 661, + 671, 665, 663, + 671, 667, 665, + 671, 669, 667, + 671, 661, 669, + 672, 673, 674, + 674, 673, 675, + 674, 675, 676, + 676, 675, 677, + 676, 677, 678, + 678, 677, 679, + 678, 679, 680, + 680, 679, 681, + 680, 681, 672, + 672, 681, 673, + 682, 672, 674, + 682, 674, 676, + 682, 676, 678, + 682, 678, 680, + 682, 680, 672, + 683, 675, 673, + 683, 677, 675, + 683, 679, 677, + 683, 681, 679, + 683, 673, 681, + 684, 685, 686, + 686, 685, 687, + 686, 687, 688, + 688, 687, 689, + 688, 689, 690, + 690, 689, 691, + 690, 691, 692, + 692, 691, 693, + 692, 693, 684, + 684, 693, 685, + 694, 684, 686, + 694, 686, 688, + 694, 688, 690, + 694, 690, 692, + 694, 692, 684, + 695, 687, 685, + 695, 689, 687, + 695, 691, 689, + 695, 693, 691, + 695, 685, 693, + 696, 697, 698, + 698, 697, 699, + 698, 699, 700, + 700, 699, 701, + 700, 701, 702, + 702, 701, 703, + 702, 703, 704, + 704, 703, 705, + 704, 705, 696, + 696, 705, 697, + 706, 696, 698, + 706, 698, 700, + 706, 700, 702, + 706, 702, 704, + 706, 704, 696, + 707, 699, 697, + 707, 701, 699, + 707, 703, 701, + 707, 705, 703, + 707, 697, 705, + 708, 709, 710, + 710, 709, 711, + 710, 711, 712, + 712, 711, 713, + 712, 713, 714, + 714, 713, 715, + 714, 715, 716, + 716, 715, 717, + 716, 717, 708, + 708, 717, 709, + 718, 708, 710, + 718, 710, 712, + 718, 712, 714, + 718, 714, 716, + 718, 716, 708, + 719, 711, 709, + 719, 713, 711, + 719, 715, 713, + 719, 717, 715, + 719, 709, 717, + 720, 721, 722, + 722, 721, 723, + 722, 723, 724, + 724, 723, 725, + 724, 725, 726, + 726, 725, 727, + 726, 727, 728, + 728, 727, 729, + 728, 729, 720, + 720, 729, 721, + 730, 720, 722, + 730, 722, 724, + 730, 724, 726, + 730, 726, 728, + 730, 728, 720, + 731, 723, 721, + 731, 725, 723, + 731, 727, 725, + 731, 729, 727, + 731, 721, 729, + 732, 733, 734, + 734, 733, 735, + 734, 735, 736, + 736, 735, 737, + 736, 737, 738, + 738, 737, 739, + 738, 739, 740, + 740, 739, 741, + 740, 741, 732, + 732, 741, 733, + 742, 732, 734, + 742, 734, 736, + 742, 736, 738, + 742, 738, 740, + 742, 740, 732, + 743, 735, 733, + 743, 737, 735, + 743, 739, 737, + 743, 741, 739, + 743, 733, 741, + 744, 745, 746, + 746, 745, 747, + 746, 747, 748, + 748, 747, 749, + 748, 749, 750, + 750, 749, 751, + 750, 751, 752, + 752, 751, 753, + 752, 753, 744, + 744, 753, 745, + 754, 744, 746, + 754, 746, 748, + 754, 748, 750, + 754, 750, 752, + 754, 752, 744, + 755, 747, 745, + 755, 749, 747, + 755, 751, 749, + 755, 753, 751, + 755, 745, 753, + 756, 757, 758, + 758, 757, 759, + 758, 759, 760, + 760, 759, 761, + 760, 761, 762, + 762, 761, 763, + 762, 763, 764, + 764, 763, 765, + 764, 765, 756, + 756, 765, 757, + 766, 756, 758, + 766, 758, 760, + 766, 760, 762, + 766, 762, 764, + 766, 764, 756, + 767, 759, 757, + 767, 761, 759, + 767, 763, 761, + 767, 765, 763, + 767, 757, 765 +}; +static const unsigned some_enclosures_properties[3840] = +{ +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, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 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, + 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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3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 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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 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, + 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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, +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, + 3, 4, 0, + 3, 4, 0, + 3, 4, 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, + 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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 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, + 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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 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 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, + 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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, +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, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 1, 2, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 2, 3, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0, + 3, 4, 0 +}; + +#define NB_CYL_X 4 +#define NB_CYL_Y 4 +#define NB_CYL_Z 4 +#define NB_CYL (NB_CYL_X * NB_CYL_Y * NB_CYL_Z) +#define CYL_VRTX_COUNT 12u +#define CYL_TRG_COUNT 20u + +int +main(int argc, char** argv) +{ + struct mem_allocator allocator; + struct senc_device* dev = NULL; + struct senc_scene* scn = NULL; + struct context ctx = CONTEXT_NULL__; + unsigned e, count; + (void)argc, (void)argv; + + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, 1, 1, &dev)); + + /* Create a scene */ + ctx.positions = some_enclosures_vertices; + ctx.indices = some_enclosures_triangles; + ctx.properties = some_enclosures_properties; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + some_enclosures_triangles_count, get_indices, get_media_from_properties, + some_enclosures_vertices_count, get_position, &ctx, &scn)); + + OK(senc_scene_get_vertices_count(scn, &count)); + CHK(count == NB_CYL * CYL_VRTX_COUNT); + OK(senc_scene_get_triangles_count(scn, &count)); + CHK(count == NB_CYL * CYL_TRG_COUNT); + + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 1 + NB_CYL); + FOR_EACH(e, 0, count) { + struct senc_enclosure* enclosure; + struct senc_enclosure_header header; + unsigned m; + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + 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 == + (header.is_infinite /* Outermost enclosure: NB_CYL_X*NB_CYL_Y cylinders */ + ? NB_CYL_X * NB_CYL_Y * CYL_TRG_COUNT + : (m == 0 + ? CYL_TRG_COUNT /* Innermost enclosures: 1 cylinder */ + : 2 * CYL_TRG_COUNT))); /* Other enclosures: 2 cylinders */ + OK(senc_enclosure_ref_put(enclosure)); + } + + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); + + check_memory_allocator(&allocator); + mem_shutdown_proxy_allocator(&allocator); + CHK(mem_allocated_size() == 0); + return 0; +} diff --git a/src/test_senc_some_triangles.c b/src/test_senc_some_triangles.c @@ -0,0 +1,2737 @@ +/* Copyright (C) |Meso|Star> 2016-2018 (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_some_triangles. + * This test is similar to test_senc_many_triangles that creates a huge + * geometry by program. */ + +#include "senc.h" +#include "test_senc_utils.h" + +#include <rsys/double3.h> + +/* Dump of star-geometry 'some_triangles'. */ +static const unsigned some_triangles_vertices_count = 536; +static const double some_triangles_vertices[1608] = +{ + 1, 0, -1, + 1, 0, -0.8, + 1, 0, -0.6, + 1, 0, -0.4, + 1, 0, -0.2, + 1, 0, -5.55112e-17, + 1, 0, 0.2, + 1, 0, 0.4, + 1, 0, 0.6, + 1, 0, 0.8, + 1, 0, 1, + 0.866025, 0.5, -1, + 0.866025, 0.5, -0.8, + 0.866025, 0.5, -0.6, + 0.866025, 0.5, -0.4, + 0.866025, 0.5, -0.2, + 0.866025, 0.5, -5.55112e-17, + 0.866025, 0.5, 0.2, + 0.866025, 0.5, 0.4, + 0.866025, 0.5, 0.6, + 0.866025, 0.5, 0.8, + 0.866025, 0.5, 1, + 0.5, 0.866025, -1, + 0.5, 0.866025, -0.8, + 0.5, 0.866025, -0.6, + 0.5, 0.866025, -0.4, + 0.5, 0.866025, -0.2, + 0.5, 0.866025, -5.55112e-17, + 0.5, 0.866025, 0.2, + 0.5, 0.866025, 0.4, + 0.5, 0.866025, 0.6, + 0.5, 0.866025, 0.8, + 0.5, 0.866025, 1, + 6.12323e-17, 1, -1, + 6.12323e-17, 1, -0.8, + 6.12323e-17, 1, -0.6, + 6.12323e-17, 1, -0.4, + 6.12323e-17, 1, -0.2, + 6.12323e-17, 1, -5.55112e-17, + 6.12323e-17, 1, 0.2, + 6.12323e-17, 1, 0.4, + 6.12323e-17, 1, 0.6, + 6.12323e-17, 1, 0.8, + 6.12323e-17, 1, 1, + -0.5, 0.866025, -1, + -0.5, 0.866025, -0.8, + -0.5, 0.866025, -0.6, + -0.5, 0.866025, -0.4, + -0.5, 0.866025, -0.2, + -0.5, 0.866025, -5.55112e-17, + -0.5, 0.866025, 0.2, + -0.5, 0.866025, 0.4, + -0.5, 0.866025, 0.6, + -0.5, 0.866025, 0.8, + -0.5, 0.866025, 1, + -0.866025, 0.5, -1, + -0.866025, 0.5, -0.8, + -0.866025, 0.5, -0.6, + -0.866025, 0.5, -0.4, + -0.866025, 0.5, -0.2, + -0.866025, 0.5, -5.55112e-17, + -0.866025, 0.5, 0.2, + -0.866025, 0.5, 0.4, + -0.866025, 0.5, 0.6, + -0.866025, 0.5, 0.8, + -0.866025, 0.5, 1, + -1, 1.22465e-16, -1, + -1, 1.22465e-16, -0.8, + -1, 1.22465e-16, -0.6, + -1, 1.22465e-16, -0.4, + -1, 1.22465e-16, -0.2, + -1, 1.22465e-16, -5.55112e-17, + -1, 1.22465e-16, 0.2, + -1, 1.22465e-16, 0.4, + -1, 1.22465e-16, 0.6, + -1, 1.22465e-16, 0.8, + -1, 1.22465e-16, 1, + -0.866025, -0.5, -1, + -0.866025, -0.5, -0.8, + -0.866025, -0.5, -0.6, + -0.866025, -0.5, -0.4, + -0.866025, -0.5, -0.2, + -0.866025, -0.5, -5.55112e-17, + -0.866025, -0.5, 0.2, + -0.866025, -0.5, 0.4, + -0.866025, -0.5, 0.6, + -0.866025, -0.5, 0.8, + -0.866025, -0.5, 1, + -0.5, -0.866025, -1, + -0.5, -0.866025, -0.8, + -0.5, -0.866025, -0.6, + -0.5, -0.866025, -0.4, + -0.5, -0.866025, -0.2, + -0.5, -0.866025, -5.55112e-17, + -0.5, -0.866025, 0.2, + -0.5, -0.866025, 0.4, + -0.5, -0.866025, 0.6, + -0.5, -0.866025, 0.8, + -0.5, -0.866025, 1, + -1.83697e-16, -1, -1, + -1.83697e-16, -1, -0.8, + -1.83697e-16, -1, -0.6, + -1.83697e-16, -1, -0.4, + -1.83697e-16, -1, -0.2, + -1.83697e-16, -1, -5.55112e-17, + -1.83697e-16, -1, 0.2, + -1.83697e-16, -1, 0.4, + -1.83697e-16, -1, 0.6, + -1.83697e-16, -1, 0.8, + -1.83697e-16, -1, 1, + 0.5, -0.866025, -1, + 0.5, -0.866025, -0.8, + 0.5, -0.866025, -0.6, + 0.5, -0.866025, -0.4, + 0.5, -0.866025, -0.2, + 0.5, -0.866025, -5.55112e-17, + 0.5, -0.866025, 0.2, + 0.5, -0.866025, 0.4, + 0.5, -0.866025, 0.6, + 0.5, -0.866025, 0.8, + 0.5, -0.866025, 1, + 0.866025, -0.5, -1, + 0.866025, -0.5, -0.8, + 0.866025, -0.5, -0.6, + 0.866025, -0.5, -0.4, + 0.866025, -0.5, -0.2, + 0.866025, -0.5, -5.55112e-17, + 0.866025, -0.5, 0.2, + 0.866025, -0.5, 0.4, + 0.866025, -0.5, 0.6, + 0.866025, -0.5, 0.8, + 0.866025, -0.5, 1, + 0, 0, -1, + 0, 0, 1, + 1, 0, 9, + 1, 0, 9.2, + 1, 0, 9.4, + 1, 0, 9.6, + 1, 0, 9.8, + 1, 0, 10, + 1, 0, 10.2, + 1, 0, 10.4, + 1, 0, 10.6, + 1, 0, 10.8, + 1, 0, 11, + 0.866025, 0.5, 9, + 0.866025, 0.5, 9.2, + 0.866025, 0.5, 9.4, + 0.866025, 0.5, 9.6, + 0.866025, 0.5, 9.8, + 0.866025, 0.5, 10, + 0.866025, 0.5, 10.2, + 0.866025, 0.5, 10.4, + 0.866025, 0.5, 10.6, + 0.866025, 0.5, 10.8, + 0.866025, 0.5, 11, + 0.5, 0.866025, 9, + 0.5, 0.866025, 9.2, + 0.5, 0.866025, 9.4, + 0.5, 0.866025, 9.6, + 0.5, 0.866025, 9.8, + 0.5, 0.866025, 10, + 0.5, 0.866025, 10.2, + 0.5, 0.866025, 10.4, + 0.5, 0.866025, 10.6, + 0.5, 0.866025, 10.8, + 0.5, 0.866025, 11, + 6.12323e-17, 1, 9, + 6.12323e-17, 1, 9.2, + 6.12323e-17, 1, 9.4, + 6.12323e-17, 1, 9.6, + 6.12323e-17, 1, 9.8, + 6.12323e-17, 1, 10, + 6.12323e-17, 1, 10.2, + 6.12323e-17, 1, 10.4, + 6.12323e-17, 1, 10.6, + 6.12323e-17, 1, 10.8, + 6.12323e-17, 1, 11, + -0.5, 0.866025, 9, + -0.5, 0.866025, 9.2, + -0.5, 0.866025, 9.4, + -0.5, 0.866025, 9.6, + -0.5, 0.866025, 9.8, + -0.5, 0.866025, 10, + -0.5, 0.866025, 10.2, + -0.5, 0.866025, 10.4, + -0.5, 0.866025, 10.6, + -0.5, 0.866025, 10.8, + -0.5, 0.866025, 11, + -0.866025, 0.5, 9, + -0.866025, 0.5, 9.2, + -0.866025, 0.5, 9.4, + -0.866025, 0.5, 9.6, + -0.866025, 0.5, 9.8, + -0.866025, 0.5, 10, + -0.866025, 0.5, 10.2, + -0.866025, 0.5, 10.4, + -0.866025, 0.5, 10.6, + -0.866025, 0.5, 10.8, + -0.866025, 0.5, 11, + -1, 1.22465e-16, 9, + -1, 1.22465e-16, 9.2, + -1, 1.22465e-16, 9.4, + -1, 1.22465e-16, 9.6, + -1, 1.22465e-16, 9.8, + -1, 1.22465e-16, 10, + -1, 1.22465e-16, 10.2, + -1, 1.22465e-16, 10.4, + -1, 1.22465e-16, 10.6, + -1, 1.22465e-16, 10.8, + -1, 1.22465e-16, 11, + -0.866025, -0.5, 9, + -0.866025, -0.5, 9.2, + -0.866025, -0.5, 9.4, + -0.866025, -0.5, 9.6, + -0.866025, -0.5, 9.8, + -0.866025, -0.5, 10, + -0.866025, -0.5, 10.2, + -0.866025, -0.5, 10.4, + -0.866025, -0.5, 10.6, + -0.866025, -0.5, 10.8, + -0.866025, -0.5, 11, + -0.5, -0.866025, 9, + -0.5, -0.866025, 9.2, + -0.5, -0.866025, 9.4, + -0.5, -0.866025, 9.6, + -0.5, -0.866025, 9.8, + -0.5, -0.866025, 10, + -0.5, -0.866025, 10.2, + -0.5, -0.866025, 10.4, + -0.5, -0.866025, 10.6, + -0.5, -0.866025, 10.8, + -0.5, -0.866025, 11, + -1.83697e-16, -1, 9, + -1.83697e-16, -1, 9.2, + -1.83697e-16, -1, 9.4, + -1.83697e-16, -1, 9.6, + -1.83697e-16, -1, 9.8, + -1.83697e-16, -1, 10, + -1.83697e-16, -1, 10.2, + -1.83697e-16, -1, 10.4, + -1.83697e-16, -1, 10.6, + -1.83697e-16, -1, 10.8, + -1.83697e-16, -1, 11, + 0.5, -0.866025, 9, + 0.5, -0.866025, 9.2, + 0.5, -0.866025, 9.4, + 0.5, -0.866025, 9.6, + 0.5, -0.866025, 9.8, + 0.5, -0.866025, 10, + 0.5, -0.866025, 10.2, + 0.5, -0.866025, 10.4, + 0.5, -0.866025, 10.6, + 0.5, -0.866025, 10.8, + 0.5, -0.866025, 11, + 0.866025, -0.5, 9, + 0.866025, -0.5, 9.2, + 0.866025, -0.5, 9.4, + 0.866025, -0.5, 9.6, + 0.866025, -0.5, 9.8, + 0.866025, -0.5, 10, + 0.866025, -0.5, 10.2, + 0.866025, -0.5, 10.4, + 0.866025, -0.5, 10.6, + 0.866025, -0.5, 10.8, + 0.866025, -0.5, 11, + 0, 0, 9, + 0, 0, 11, + 1, 0, 19, + 1, 0, 19.2, + 1, 0, 19.4, + 1, 0, 19.6, + 1, 0, 19.8, + 1, 0, 20, + 1, 0, 20.2, + 1, 0, 20.4, + 1, 0, 20.6, + 1, 0, 20.8, + 1, 0, 21, + 0.866025, 0.5, 19, + 0.866025, 0.5, 19.2, + 0.866025, 0.5, 19.4, + 0.866025, 0.5, 19.6, + 0.866025, 0.5, 19.8, + 0.866025, 0.5, 20, + 0.866025, 0.5, 20.2, + 0.866025, 0.5, 20.4, + 0.866025, 0.5, 20.6, + 0.866025, 0.5, 20.8, + 0.866025, 0.5, 21, + 0.5, 0.866025, 19, + 0.5, 0.866025, 19.2, + 0.5, 0.866025, 19.4, + 0.5, 0.866025, 19.6, + 0.5, 0.866025, 19.8, + 0.5, 0.866025, 20, + 0.5, 0.866025, 20.2, + 0.5, 0.866025, 20.4, + 0.5, 0.866025, 20.6, + 0.5, 0.866025, 20.8, + 0.5, 0.866025, 21, + 6.12323e-17, 1, 19, + 6.12323e-17, 1, 19.2, + 6.12323e-17, 1, 19.4, + 6.12323e-17, 1, 19.6, + 6.12323e-17, 1, 19.8, + 6.12323e-17, 1, 20, + 6.12323e-17, 1, 20.2, + 6.12323e-17, 1, 20.4, + 6.12323e-17, 1, 20.6, + 6.12323e-17, 1, 20.8, + 6.12323e-17, 1, 21, + -0.5, 0.866025, 19, + -0.5, 0.866025, 19.2, + -0.5, 0.866025, 19.4, + -0.5, 0.866025, 19.6, + -0.5, 0.866025, 19.8, + -0.5, 0.866025, 20, + -0.5, 0.866025, 20.2, + -0.5, 0.866025, 20.4, + -0.5, 0.866025, 20.6, + -0.5, 0.866025, 20.8, + -0.5, 0.866025, 21, + -0.866025, 0.5, 19, + -0.866025, 0.5, 19.2, + -0.866025, 0.5, 19.4, + -0.866025, 0.5, 19.6, + -0.866025, 0.5, 19.8, + -0.866025, 0.5, 20, + -0.866025, 0.5, 20.2, + -0.866025, 0.5, 20.4, + -0.866025, 0.5, 20.6, + -0.866025, 0.5, 20.8, + -0.866025, 0.5, 21, + -1, 1.22465e-16, 19, + -1, 1.22465e-16, 19.2, + -1, 1.22465e-16, 19.4, + -1, 1.22465e-16, 19.6, + -1, 1.22465e-16, 19.8, + -1, 1.22465e-16, 20, + -1, 1.22465e-16, 20.2, + -1, 1.22465e-16, 20.4, + -1, 1.22465e-16, 20.6, + -1, 1.22465e-16, 20.8, + -1, 1.22465e-16, 21, + -0.866025, -0.5, 19, + -0.866025, -0.5, 19.2, + -0.866025, -0.5, 19.4, + -0.866025, -0.5, 19.6, + -0.866025, -0.5, 19.8, + -0.866025, -0.5, 20, + -0.866025, -0.5, 20.2, + -0.866025, -0.5, 20.4, + -0.866025, -0.5, 20.6, + -0.866025, -0.5, 20.8, + -0.866025, -0.5, 21, + -0.5, -0.866025, 19, + -0.5, -0.866025, 19.2, + -0.5, -0.866025, 19.4, + -0.5, -0.866025, 19.6, + -0.5, -0.866025, 19.8, + -0.5, -0.866025, 20, + -0.5, -0.866025, 20.2, + -0.5, -0.866025, 20.4, + -0.5, -0.866025, 20.6, + -0.5, -0.866025, 20.8, + -0.5, -0.866025, 21, + -1.83697e-16, -1, 19, + -1.83697e-16, -1, 19.2, + -1.83697e-16, -1, 19.4, + -1.83697e-16, -1, 19.6, + -1.83697e-16, -1, 19.8, + -1.83697e-16, -1, 20, + -1.83697e-16, -1, 20.2, + -1.83697e-16, -1, 20.4, + -1.83697e-16, -1, 20.6, + -1.83697e-16, -1, 20.8, + -1.83697e-16, -1, 21, + 0.5, -0.866025, 19, + 0.5, -0.866025, 19.2, + 0.5, -0.866025, 19.4, + 0.5, -0.866025, 19.6, + 0.5, -0.866025, 19.8, + 0.5, -0.866025, 20, + 0.5, -0.866025, 20.2, + 0.5, -0.866025, 20.4, + 0.5, -0.866025, 20.6, + 0.5, -0.866025, 20.8, + 0.5, -0.866025, 21, + 0.866025, -0.5, 19, + 0.866025, -0.5, 19.2, + 0.866025, -0.5, 19.4, + 0.866025, -0.5, 19.6, + 0.866025, -0.5, 19.8, + 0.866025, -0.5, 20, + 0.866025, -0.5, 20.2, + 0.866025, -0.5, 20.4, + 0.866025, -0.5, 20.6, + 0.866025, -0.5, 20.8, + 0.866025, -0.5, 21, + 0, 0, 19, + 0, 0, 21, + 1, 0, 29, + 1, 0, 29.2, + 1, 0, 29.4, + 1, 0, 29.6, + 1, 0, 29.8, + 1, 0, 30, + 1, 0, 30.2, + 1, 0, 30.4, + 1, 0, 30.6, + 1, 0, 30.8, + 1, 0, 31, + 0.866025, 0.5, 29, + 0.866025, 0.5, 29.2, + 0.866025, 0.5, 29.4, + 0.866025, 0.5, 29.6, + 0.866025, 0.5, 29.8, + 0.866025, 0.5, 30, + 0.866025, 0.5, 30.2, + 0.866025, 0.5, 30.4, + 0.866025, 0.5, 30.6, + 0.866025, 0.5, 30.8, + 0.866025, 0.5, 31, + 0.5, 0.866025, 29, + 0.5, 0.866025, 29.2, + 0.5, 0.866025, 29.4, + 0.5, 0.866025, 29.6, + 0.5, 0.866025, 29.8, + 0.5, 0.866025, 30, + 0.5, 0.866025, 30.2, + 0.5, 0.866025, 30.4, + 0.5, 0.866025, 30.6, + 0.5, 0.866025, 30.8, + 0.5, 0.866025, 31, + 6.12323e-17, 1, 29, + 6.12323e-17, 1, 29.2, + 6.12323e-17, 1, 29.4, + 6.12323e-17, 1, 29.6, + 6.12323e-17, 1, 29.8, + 6.12323e-17, 1, 30, + 6.12323e-17, 1, 30.2, + 6.12323e-17, 1, 30.4, + 6.12323e-17, 1, 30.6, + 6.12323e-17, 1, 30.8, + 6.12323e-17, 1, 31, + -0.5, 0.866025, 29, + -0.5, 0.866025, 29.2, + -0.5, 0.866025, 29.4, + -0.5, 0.866025, 29.6, + -0.5, 0.866025, 29.8, + -0.5, 0.866025, 30, + -0.5, 0.866025, 30.2, + -0.5, 0.866025, 30.4, + -0.5, 0.866025, 30.6, + -0.5, 0.866025, 30.8, + -0.5, 0.866025, 31, + -0.866025, 0.5, 29, + -0.866025, 0.5, 29.2, + -0.866025, 0.5, 29.4, + -0.866025, 0.5, 29.6, + -0.866025, 0.5, 29.8, + -0.866025, 0.5, 30, + -0.866025, 0.5, 30.2, + -0.866025, 0.5, 30.4, + -0.866025, 0.5, 30.6, + -0.866025, 0.5, 30.8, + -0.866025, 0.5, 31, + -1, 1.22465e-16, 29, + -1, 1.22465e-16, 29.2, + -1, 1.22465e-16, 29.4, + -1, 1.22465e-16, 29.6, + -1, 1.22465e-16, 29.8, + -1, 1.22465e-16, 30, + -1, 1.22465e-16, 30.2, + -1, 1.22465e-16, 30.4, + -1, 1.22465e-16, 30.6, + -1, 1.22465e-16, 30.8, + -1, 1.22465e-16, 31, + -0.866025, -0.5, 29, + -0.866025, -0.5, 29.2, + -0.866025, -0.5, 29.4, + -0.866025, -0.5, 29.6, + -0.866025, -0.5, 29.8, + -0.866025, -0.5, 30, + -0.866025, -0.5, 30.2, + -0.866025, -0.5, 30.4, + -0.866025, -0.5, 30.6, + -0.866025, -0.5, 30.8, + -0.866025, -0.5, 31, + -0.5, -0.866025, 29, + -0.5, -0.866025, 29.2, + -0.5, -0.866025, 29.4, + -0.5, -0.866025, 29.6, + -0.5, -0.866025, 29.8, + -0.5, -0.866025, 30, + -0.5, -0.866025, 30.2, + -0.5, -0.866025, 30.4, + -0.5, -0.866025, 30.6, + -0.5, -0.866025, 30.8, + -0.5, -0.866025, 31, + -1.83697e-16, -1, 29, + -1.83697e-16, -1, 29.2, + -1.83697e-16, -1, 29.4, + -1.83697e-16, -1, 29.6, + -1.83697e-16, -1, 29.8, + -1.83697e-16, -1, 30, + -1.83697e-16, -1, 30.2, + -1.83697e-16, -1, 30.4, + -1.83697e-16, -1, 30.6, + -1.83697e-16, -1, 30.8, + -1.83697e-16, -1, 31, + 0.5, -0.866025, 29, + 0.5, -0.866025, 29.2, + 0.5, -0.866025, 29.4, + 0.5, -0.866025, 29.6, + 0.5, -0.866025, 29.8, + 0.5, -0.866025, 30, + 0.5, -0.866025, 30.2, + 0.5, -0.866025, 30.4, + 0.5, -0.866025, 30.6, + 0.5, -0.866025, 30.8, + 0.5, -0.866025, 31, + 0.866025, -0.5, 29, + 0.866025, -0.5, 29.2, + 0.866025, -0.5, 29.4, + 0.866025, -0.5, 29.6, + 0.866025, -0.5, 29.8, + 0.866025, -0.5, 30, + 0.866025, -0.5, 30.2, + 0.866025, -0.5, 30.4, + 0.866025, -0.5, 30.6, + 0.866025, -0.5, 30.8, + 0.866025, -0.5, 31, + 0, 0, 29, + 0, 0, 31 +}; +static const unsigned some_triangles_triangles_count = 1056; +static const unsigned some_triangles_triangles[3168] = +{ + 0, 1, 11, + 11, 1, 12, + 1, 2, 12, + 12, 2, 13, + 2, 3, 13, + 13, 3, 14, + 3, 4, 14, + 14, 4, 15, + 4, 5, 15, + 15, 5, 16, + 5, 6, 16, + 16, 6, 17, + 6, 7, 17, + 17, 7, 18, + 7, 8, 18, + 18, 8, 19, + 8, 9, 19, + 19, 9, 20, + 9, 10, 20, + 20, 10, 21, + 11, 12, 22, + 22, 12, 23, + 12, 13, 23, + 23, 13, 24, + 13, 14, 24, + 24, 14, 25, + 14, 15, 25, + 25, 15, 26, + 15, 16, 26, + 26, 16, 27, + 16, 17, 27, + 27, 17, 28, + 17, 18, 28, + 28, 18, 29, + 18, 19, 29, + 29, 19, 30, + 19, 20, 30, + 30, 20, 31, + 20, 21, 31, + 31, 21, 32, + 22, 23, 33, + 33, 23, 34, + 23, 24, 34, + 34, 24, 35, + 24, 25, 35, + 35, 25, 36, + 25, 26, 36, + 36, 26, 37, + 26, 27, 37, + 37, 27, 38, + 27, 28, 38, + 38, 28, 39, + 28, 29, 39, + 39, 29, 40, + 29, 30, 40, + 40, 30, 41, + 30, 31, 41, + 41, 31, 42, + 31, 32, 42, + 42, 32, 43, + 33, 34, 44, + 44, 34, 45, + 34, 35, 45, + 45, 35, 46, + 35, 36, 46, + 46, 36, 47, + 36, 37, 47, + 47, 37, 48, + 37, 38, 48, + 48, 38, 49, + 38, 39, 49, + 49, 39, 50, + 39, 40, 50, + 50, 40, 51, + 40, 41, 51, + 51, 41, 52, + 41, 42, 52, + 52, 42, 53, + 42, 43, 53, + 53, 43, 54, + 44, 45, 55, + 55, 45, 56, + 45, 46, 56, + 56, 46, 57, + 46, 47, 57, + 57, 47, 58, + 47, 48, 58, + 58, 48, 59, + 48, 49, 59, + 59, 49, 60, + 49, 50, 60, + 60, 50, 61, + 50, 51, 61, + 61, 51, 62, + 51, 52, 62, + 62, 52, 63, + 52, 53, 63, + 63, 53, 64, + 53, 54, 64, + 64, 54, 65, + 55, 56, 66, + 66, 56, 67, + 56, 57, 67, + 67, 57, 68, + 57, 58, 68, + 68, 58, 69, + 58, 59, 69, + 69, 59, 70, + 59, 60, 70, + 70, 60, 71, + 60, 61, 71, + 71, 61, 72, + 61, 62, 72, + 72, 62, 73, + 62, 63, 73, + 73, 63, 74, + 63, 64, 74, + 74, 64, 75, + 64, 65, 75, + 75, 65, 76, + 66, 67, 77, + 77, 67, 78, + 67, 68, 78, + 78, 68, 79, + 68, 69, 79, + 79, 69, 80, + 69, 70, 80, + 80, 70, 81, + 70, 71, 81, + 81, 71, 82, + 71, 72, 82, + 82, 72, 83, + 72, 73, 83, + 83, 73, 84, + 73, 74, 84, + 84, 74, 85, + 74, 75, 85, + 85, 75, 86, + 75, 76, 86, + 86, 76, 87, + 77, 78, 88, + 88, 78, 89, + 78, 79, 89, + 89, 79, 90, + 79, 80, 90, + 90, 80, 91, + 80, 81, 91, + 91, 81, 92, + 81, 82, 92, + 92, 82, 93, + 82, 83, 93, + 93, 83, 94, + 83, 84, 94, + 94, 84, 95, + 84, 85, 95, + 95, 85, 96, + 85, 86, 96, + 96, 86, 97, + 86, 87, 97, + 97, 87, 98, + 88, 89, 99, + 99, 89, 100, + 89, 90, 100, + 100, 90, 101, + 90, 91, 101, + 101, 91, 102, + 91, 92, 102, + 102, 92, 103, + 92, 93, 103, + 103, 93, 104, + 93, 94, 104, + 104, 94, 105, + 94, 95, 105, + 105, 95, 106, + 95, 96, 106, + 106, 96, 107, + 96, 97, 107, + 107, 97, 108, + 97, 98, 108, + 108, 98, 109, + 99, 100, 110, + 110, 100, 111, + 100, 101, 111, + 111, 101, 112, + 101, 102, 112, + 112, 102, 113, + 102, 103, 113, + 113, 103, 114, + 103, 104, 114, + 114, 104, 115, + 104, 105, 115, + 115, 105, 116, + 105, 106, 116, + 116, 106, 117, + 106, 107, 117, + 117, 107, 118, + 107, 108, 118, + 118, 108, 119, + 108, 109, 119, + 119, 109, 120, + 110, 111, 121, + 121, 111, 122, + 111, 112, 122, + 122, 112, 123, + 112, 113, 123, + 123, 113, 124, + 113, 114, 124, + 124, 114, 125, + 114, 115, 125, + 125, 115, 126, + 115, 116, 126, + 126, 116, 127, + 116, 117, 127, + 127, 117, 128, + 117, 118, 128, + 128, 118, 129, + 118, 119, 129, + 129, 119, 130, + 119, 120, 130, + 130, 120, 131, + 121, 122, 0, + 0, 122, 1, + 122, 123, 1, + 1, 123, 2, + 123, 124, 2, + 2, 124, 3, + 124, 125, 3, + 3, 125, 4, + 125, 126, 4, + 4, 126, 5, + 126, 127, 5, + 5, 127, 6, + 127, 128, 6, + 6, 128, 7, + 128, 129, 7, + 7, 129, 8, + 129, 130, 8, + 8, 130, 9, + 130, 131, 9, + 9, 131, 10, + 132, 0, 11, + 132, 11, 22, + 132, 22, 33, + 132, 33, 44, + 132, 44, 55, + 132, 55, 66, + 132, 66, 77, + 132, 77, 88, + 132, 88, 99, + 132, 99, 110, + 132, 110, 121, + 132, 121, 0, + 133, 21, 10, + 133, 32, 21, + 133, 43, 32, + 133, 54, 43, + 133, 65, 54, + 133, 76, 65, + 133, 87, 76, + 133, 98, 87, + 133, 109, 98, + 133, 120, 109, + 133, 131, 120, + 133, 10, 131, + 134, 135, 145, + 145, 135, 146, + 135, 136, 146, + 146, 136, 147, + 136, 137, 147, + 147, 137, 148, + 137, 138, 148, + 148, 138, 149, + 138, 139, 149, + 149, 139, 150, + 139, 140, 150, + 150, 140, 151, + 140, 141, 151, + 151, 141, 152, + 141, 142, 152, + 152, 142, 153, + 142, 143, 153, + 153, 143, 154, + 143, 144, 154, + 154, 144, 155, + 145, 146, 156, + 156, 146, 157, + 146, 147, 157, + 157, 147, 158, + 147, 148, 158, + 158, 148, 159, + 148, 149, 159, + 159, 149, 160, + 149, 150, 160, + 160, 150, 161, + 150, 151, 161, + 161, 151, 162, + 151, 152, 162, + 162, 152, 163, + 152, 153, 163, + 163, 153, 164, + 153, 154, 164, + 164, 154, 165, + 154, 155, 165, + 165, 155, 166, + 156, 157, 167, + 167, 157, 168, + 157, 158, 168, + 168, 158, 169, + 158, 159, 169, + 169, 159, 170, + 159, 160, 170, + 170, 160, 171, + 160, 161, 171, + 171, 161, 172, + 161, 162, 172, + 172, 162, 173, + 162, 163, 173, + 173, 163, 174, + 163, 164, 174, + 174, 164, 175, + 164, 165, 175, + 175, 165, 176, + 165, 166, 176, + 176, 166, 177, + 167, 168, 178, + 178, 168, 179, + 168, 169, 179, + 179, 169, 180, + 169, 170, 180, + 180, 170, 181, + 170, 171, 181, + 181, 171, 182, + 171, 172, 182, + 182, 172, 183, + 172, 173, 183, + 183, 173, 184, + 173, 174, 184, + 184, 174, 185, + 174, 175, 185, + 185, 175, 186, + 175, 176, 186, + 186, 176, 187, + 176, 177, 187, + 187, 177, 188, + 178, 179, 189, + 189, 179, 190, + 179, 180, 190, + 190, 180, 191, + 180, 181, 191, + 191, 181, 192, + 181, 182, 192, + 192, 182, 193, + 182, 183, 193, + 193, 183, 194, + 183, 184, 194, + 194, 184, 195, + 184, 185, 195, + 195, 185, 196, + 185, 186, 196, + 196, 186, 197, + 186, 187, 197, + 197, 187, 198, + 187, 188, 198, + 198, 188, 199, + 189, 190, 200, + 200, 190, 201, + 190, 191, 201, + 201, 191, 202, + 191, 192, 202, + 202, 192, 203, + 192, 193, 203, + 203, 193, 204, + 193, 194, 204, + 204, 194, 205, + 194, 195, 205, + 205, 195, 206, + 195, 196, 206, + 206, 196, 207, + 196, 197, 207, + 207, 197, 208, + 197, 198, 208, + 208, 198, 209, + 198, 199, 209, + 209, 199, 210, + 200, 201, 211, + 211, 201, 212, + 201, 202, 212, + 212, 202, 213, + 202, 203, 213, + 213, 203, 214, + 203, 204, 214, + 214, 204, 215, + 204, 205, 215, + 215, 205, 216, + 205, 206, 216, + 216, 206, 217, + 206, 207, 217, + 217, 207, 218, + 207, 208, 218, + 218, 208, 219, + 208, 209, 219, + 219, 209, 220, + 209, 210, 220, + 220, 210, 221, + 211, 212, 222, + 222, 212, 223, + 212, 213, 223, + 223, 213, 224, + 213, 214, 224, + 224, 214, 225, + 214, 215, 225, + 225, 215, 226, + 215, 216, 226, + 226, 216, 227, + 216, 217, 227, + 227, 217, 228, + 217, 218, 228, + 228, 218, 229, + 218, 219, 229, + 229, 219, 230, + 219, 220, 230, + 230, 220, 231, + 220, 221, 231, + 231, 221, 232, + 222, 223, 233, + 233, 223, 234, + 223, 224, 234, + 234, 224, 235, + 224, 225, 235, + 235, 225, 236, + 225, 226, 236, + 236, 226, 237, + 226, 227, 237, + 237, 227, 238, + 227, 228, 238, + 238, 228, 239, + 228, 229, 239, + 239, 229, 240, + 229, 230, 240, + 240, 230, 241, + 230, 231, 241, + 241, 231, 242, + 231, 232, 242, + 242, 232, 243, + 233, 234, 244, + 244, 234, 245, + 234, 235, 245, + 245, 235, 246, + 235, 236, 246, + 246, 236, 247, + 236, 237, 247, + 247, 237, 248, + 237, 238, 248, + 248, 238, 249, + 238, 239, 249, + 249, 239, 250, + 239, 240, 250, + 250, 240, 251, + 240, 241, 251, + 251, 241, 252, + 241, 242, 252, + 252, 242, 253, + 242, 243, 253, + 253, 243, 254, + 244, 245, 255, + 255, 245, 256, + 245, 246, 256, + 256, 246, 257, + 246, 247, 257, + 257, 247, 258, + 247, 248, 258, + 258, 248, 259, + 248, 249, 259, + 259, 249, 260, + 249, 250, 260, + 260, 250, 261, + 250, 251, 261, + 261, 251, 262, + 251, 252, 262, + 262, 252, 263, + 252, 253, 263, + 263, 253, 264, + 253, 254, 264, + 264, 254, 265, + 255, 256, 134, + 134, 256, 135, + 256, 257, 135, + 135, 257, 136, + 257, 258, 136, + 136, 258, 137, + 258, 259, 137, + 137, 259, 138, + 259, 260, 138, + 138, 260, 139, + 260, 261, 139, + 139, 261, 140, + 261, 262, 140, + 140, 262, 141, + 262, 263, 141, + 141, 263, 142, + 263, 264, 142, + 142, 264, 143, + 264, 265, 143, + 143, 265, 144, + 266, 134, 145, + 266, 145, 156, + 266, 156, 167, + 266, 167, 178, + 266, 178, 189, + 266, 189, 200, + 266, 200, 211, + 266, 211, 222, + 266, 222, 233, + 266, 233, 244, + 266, 244, 255, + 266, 255, 134, + 267, 155, 144, + 267, 166, 155, + 267, 177, 166, + 267, 188, 177, + 267, 199, 188, + 267, 210, 199, + 267, 221, 210, + 267, 232, 221, + 267, 243, 232, + 267, 254, 243, + 267, 265, 254, + 267, 144, 265, + 268, 269, 279, + 279, 269, 280, + 269, 270, 280, + 280, 270, 281, + 270, 271, 281, + 281, 271, 282, + 271, 272, 282, + 282, 272, 283, + 272, 273, 283, + 283, 273, 284, + 273, 274, 284, + 284, 274, 285, + 274, 275, 285, + 285, 275, 286, + 275, 276, 286, + 286, 276, 287, + 276, 277, 287, + 287, 277, 288, + 277, 278, 288, + 288, 278, 289, + 279, 280, 290, + 290, 280, 291, + 280, 281, 291, + 291, 281, 292, + 281, 282, 292, + 292, 282, 293, + 282, 283, 293, + 293, 283, 294, + 283, 284, 294, + 294, 284, 295, + 284, 285, 295, + 295, 285, 296, + 285, 286, 296, + 296, 286, 297, + 286, 287, 297, + 297, 287, 298, + 287, 288, 298, + 298, 288, 299, + 288, 289, 299, + 299, 289, 300, + 290, 291, 301, + 301, 291, 302, + 291, 292, 302, + 302, 292, 303, + 292, 293, 303, + 303, 293, 304, + 293, 294, 304, + 304, 294, 305, + 294, 295, 305, + 305, 295, 306, + 295, 296, 306, + 306, 296, 307, + 296, 297, 307, + 307, 297, 308, + 297, 298, 308, + 308, 298, 309, + 298, 299, 309, + 309, 299, 310, + 299, 300, 310, + 310, 300, 311, + 301, 302, 312, + 312, 302, 313, + 302, 303, 313, + 313, 303, 314, + 303, 304, 314, + 314, 304, 315, + 304, 305, 315, + 315, 305, 316, + 305, 306, 316, + 316, 306, 317, + 306, 307, 317, + 317, 307, 318, + 307, 308, 318, + 318, 308, 319, + 308, 309, 319, + 319, 309, 320, + 309, 310, 320, + 320, 310, 321, + 310, 311, 321, + 321, 311, 322, + 312, 313, 323, + 323, 313, 324, + 313, 314, 324, + 324, 314, 325, + 314, 315, 325, + 325, 315, 326, + 315, 316, 326, + 326, 316, 327, + 316, 317, 327, + 327, 317, 328, + 317, 318, 328, + 328, 318, 329, + 318, 319, 329, + 329, 319, 330, + 319, 320, 330, + 330, 320, 331, + 320, 321, 331, + 331, 321, 332, + 321, 322, 332, + 332, 322, 333, + 323, 324, 334, + 334, 324, 335, + 324, 325, 335, + 335, 325, 336, + 325, 326, 336, + 336, 326, 337, + 326, 327, 337, + 337, 327, 338, + 327, 328, 338, + 338, 328, 339, + 328, 329, 339, + 339, 329, 340, + 329, 330, 340, + 340, 330, 341, + 330, 331, 341, + 341, 331, 342, + 331, 332, 342, + 342, 332, 343, + 332, 333, 343, + 343, 333, 344, + 334, 335, 345, + 345, 335, 346, + 335, 336, 346, + 346, 336, 347, + 336, 337, 347, + 347, 337, 348, + 337, 338, 348, + 348, 338, 349, + 338, 339, 349, + 349, 339, 350, + 339, 340, 350, + 350, 340, 351, + 340, 341, 351, + 351, 341, 352, + 341, 342, 352, + 352, 342, 353, + 342, 343, 353, + 353, 343, 354, + 343, 344, 354, + 354, 344, 355, + 345, 346, 356, + 356, 346, 357, + 346, 347, 357, + 357, 347, 358, + 347, 348, 358, + 358, 348, 359, + 348, 349, 359, + 359, 349, 360, + 349, 350, 360, + 360, 350, 361, + 350, 351, 361, + 361, 351, 362, + 351, 352, 362, + 362, 352, 363, + 352, 353, 363, + 363, 353, 364, + 353, 354, 364, + 364, 354, 365, + 354, 355, 365, + 365, 355, 366, + 356, 357, 367, + 367, 357, 368, + 357, 358, 368, + 368, 358, 369, + 358, 359, 369, + 369, 359, 370, + 359, 360, 370, + 370, 360, 371, + 360, 361, 371, + 371, 361, 372, + 361, 362, 372, + 372, 362, 373, + 362, 363, 373, + 373, 363, 374, + 363, 364, 374, + 374, 364, 375, + 364, 365, 375, + 375, 365, 376, + 365, 366, 376, + 376, 366, 377, + 367, 368, 378, + 378, 368, 379, + 368, 369, 379, + 379, 369, 380, + 369, 370, 380, + 380, 370, 381, + 370, 371, 381, + 381, 371, 382, + 371, 372, 382, + 382, 372, 383, + 372, 373, 383, + 383, 373, 384, + 373, 374, 384, + 384, 374, 385, + 374, 375, 385, + 385, 375, 386, + 375, 376, 386, + 386, 376, 387, + 376, 377, 387, + 387, 377, 388, + 378, 379, 389, + 389, 379, 390, + 379, 380, 390, + 390, 380, 391, + 380, 381, 391, + 391, 381, 392, + 381, 382, 392, + 392, 382, 393, + 382, 383, 393, + 393, 383, 394, + 383, 384, 394, + 394, 384, 395, + 384, 385, 395, + 395, 385, 396, + 385, 386, 396, + 396, 386, 397, + 386, 387, 397, + 397, 387, 398, + 387, 388, 398, + 398, 388, 399, + 389, 390, 268, + 268, 390, 269, + 390, 391, 269, + 269, 391, 270, + 391, 392, 270, + 270, 392, 271, + 392, 393, 271, + 271, 393, 272, + 393, 394, 272, + 272, 394, 273, + 394, 395, 273, + 273, 395, 274, + 395, 396, 274, + 274, 396, 275, + 396, 397, 275, + 275, 397, 276, + 397, 398, 276, + 276, 398, 277, + 398, 399, 277, + 277, 399, 278, + 400, 268, 279, + 400, 279, 290, + 400, 290, 301, + 400, 301, 312, + 400, 312, 323, + 400, 323, 334, + 400, 334, 345, + 400, 345, 356, + 400, 356, 367, + 400, 367, 378, + 400, 378, 389, + 400, 389, 268, + 401, 289, 278, + 401, 300, 289, + 401, 311, 300, + 401, 322, 311, + 401, 333, 322, + 401, 344, 333, + 401, 355, 344, + 401, 366, 355, + 401, 377, 366, + 401, 388, 377, + 401, 399, 388, + 401, 278, 399, + 402, 403, 413, + 413, 403, 414, + 403, 404, 414, + 414, 404, 415, + 404, 405, 415, + 415, 405, 416, + 405, 406, 416, + 416, 406, 417, + 406, 407, 417, + 417, 407, 418, + 407, 408, 418, + 418, 408, 419, + 408, 409, 419, + 419, 409, 420, + 409, 410, 420, + 420, 410, 421, + 410, 411, 421, + 421, 411, 422, + 411, 412, 422, + 422, 412, 423, + 413, 414, 424, + 424, 414, 425, + 414, 415, 425, + 425, 415, 426, + 415, 416, 426, + 426, 416, 427, + 416, 417, 427, + 427, 417, 428, + 417, 418, 428, + 428, 418, 429, + 418, 419, 429, + 429, 419, 430, + 419, 420, 430, + 430, 420, 431, + 420, 421, 431, + 431, 421, 432, + 421, 422, 432, + 432, 422, 433, + 422, 423, 433, + 433, 423, 434, + 424, 425, 435, + 435, 425, 436, + 425, 426, 436, + 436, 426, 437, + 426, 427, 437, + 437, 427, 438, + 427, 428, 438, + 438, 428, 439, + 428, 429, 439, + 439, 429, 440, + 429, 430, 440, + 440, 430, 441, + 430, 431, 441, + 441, 431, 442, + 431, 432, 442, + 442, 432, 443, + 432, 433, 443, + 443, 433, 444, + 433, 434, 444, + 444, 434, 445, + 435, 436, 446, + 446, 436, 447, + 436, 437, 447, + 447, 437, 448, + 437, 438, 448, + 448, 438, 449, + 438, 439, 449, + 449, 439, 450, + 439, 440, 450, + 450, 440, 451, + 440, 441, 451, + 451, 441, 452, + 441, 442, 452, + 452, 442, 453, + 442, 443, 453, + 453, 443, 454, + 443, 444, 454, + 454, 444, 455, + 444, 445, 455, + 455, 445, 456, + 446, 447, 457, + 457, 447, 458, + 447, 448, 458, + 458, 448, 459, + 448, 449, 459, + 459, 449, 460, + 449, 450, 460, + 460, 450, 461, + 450, 451, 461, + 461, 451, 462, + 451, 452, 462, + 462, 452, 463, + 452, 453, 463, + 463, 453, 464, + 453, 454, 464, + 464, 454, 465, + 454, 455, 465, + 465, 455, 466, + 455, 456, 466, + 466, 456, 467, + 457, 458, 468, + 468, 458, 469, + 458, 459, 469, + 469, 459, 470, + 459, 460, 470, + 470, 460, 471, + 460, 461, 471, + 471, 461, 472, + 461, 462, 472, + 472, 462, 473, + 462, 463, 473, + 473, 463, 474, + 463, 464, 474, + 474, 464, 475, + 464, 465, 475, + 475, 465, 476, + 465, 466, 476, + 476, 466, 477, + 466, 467, 477, + 477, 467, 478, + 468, 469, 479, + 479, 469, 480, + 469, 470, 480, + 480, 470, 481, + 470, 471, 481, + 481, 471, 482, + 471, 472, 482, + 482, 472, 483, + 472, 473, 483, + 483, 473, 484, + 473, 474, 484, + 484, 474, 485, + 474, 475, 485, + 485, 475, 486, + 475, 476, 486, + 486, 476, 487, + 476, 477, 487, + 487, 477, 488, + 477, 478, 488, + 488, 478, 489, + 479, 480, 490, + 490, 480, 491, + 480, 481, 491, + 491, 481, 492, + 481, 482, 492, + 492, 482, 493, + 482, 483, 493, + 493, 483, 494, + 483, 484, 494, + 494, 484, 495, + 484, 485, 495, + 495, 485, 496, + 485, 486, 496, + 496, 486, 497, + 486, 487, 497, + 497, 487, 498, + 487, 488, 498, + 498, 488, 499, + 488, 489, 499, + 499, 489, 500, + 490, 491, 501, + 501, 491, 502, + 491, 492, 502, + 502, 492, 503, + 492, 493, 503, + 503, 493, 504, + 493, 494, 504, + 504, 494, 505, + 494, 495, 505, + 505, 495, 506, + 495, 496, 506, + 506, 496, 507, + 496, 497, 507, + 507, 497, 508, + 497, 498, 508, + 508, 498, 509, + 498, 499, 509, + 509, 499, 510, + 499, 500, 510, + 510, 500, 511, + 501, 502, 512, + 512, 502, 513, + 502, 503, 513, + 513, 503, 514, + 503, 504, 514, + 514, 504, 515, + 504, 505, 515, + 515, 505, 516, + 505, 506, 516, + 516, 506, 517, + 506, 507, 517, + 517, 507, 518, + 507, 508, 518, + 518, 508, 519, + 508, 509, 519, + 519, 509, 520, + 509, 510, 520, + 520, 510, 521, + 510, 511, 521, + 521, 511, 522, + 512, 513, 523, + 523, 513, 524, + 513, 514, 524, + 524, 514, 525, + 514, 515, 525, + 525, 515, 526, + 515, 516, 526, + 526, 516, 527, + 516, 517, 527, + 527, 517, 528, + 517, 518, 528, + 528, 518, 529, + 518, 519, 529, + 529, 519, 530, + 519, 520, 530, + 530, 520, 531, + 520, 521, 531, + 531, 521, 532, + 521, 522, 532, + 532, 522, 533, + 523, 524, 402, + 402, 524, 403, + 524, 525, 403, + 403, 525, 404, + 525, 526, 404, + 404, 526, 405, + 526, 527, 405, + 405, 527, 406, + 527, 528, 406, + 406, 528, 407, + 528, 529, 407, + 407, 529, 408, + 529, 530, 408, + 408, 530, 409, + 530, 531, 409, + 409, 531, 410, + 531, 532, 410, + 410, 532, 411, + 532, 533, 411, + 411, 533, 412, + 534, 402, 413, + 534, 413, 424, + 534, 424, 435, + 534, 435, 446, + 534, 446, 457, + 534, 457, 468, + 534, 468, 479, + 534, 479, 490, + 534, 490, 501, + 534, 501, 512, + 534, 512, 523, + 534, 523, 402, + 535, 423, 412, + 535, 434, 423, + 535, 445, 434, + 535, 456, 445, + 535, 467, 456, + 535, 478, 467, + 535, 489, 478, + 535, 500, 489, + 535, 511, 500, + 535, 522, 511, + 535, 533, 522, + 535, 412, 533 +}; +static const unsigned some_triangles_properties[3168] = +{ + 0, 0, 0, + 0, 0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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, 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, 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, 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, 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, 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, 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, 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, 0, + 1, 0, 0, + 1, 0, 0, + 1, 0, 0, + 1, 0, 0, + 1, 0, 0, + 1, 0, 0, + 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0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 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, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0, + 3, 0, 0 +}; + +#define NB_CYL 4 +#define CYL_VRTX_COUNT 134u +#define CYL_TRG_COUNT 264u + +int +main(int argc, char** argv) +{ + struct mem_allocator allocator; + struct senc_device* dev = NULL; + struct senc_scene* scn = NULL; + struct context ctx = CONTEXT_NULL__; + unsigned e, count; + (void)argc, (void)argv; + + OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); + OK(senc_device_create(NULL, &allocator, 1, 1, &dev)); + + /* Create a scene */ + ctx.positions = some_triangles_vertices; + ctx.indices = some_triangles_triangles; + ctx.properties = some_triangles_properties; + OK(senc_scene_create(dev, + SENC_CONVENTION_NORMAL_FRONT | SENC_CONVENTION_NORMAL_INSIDE, + some_triangles_triangles_count, get_indices, get_media_from_properties, + some_triangles_vertices_count, get_position, &ctx, &scn)); + + OK(senc_scene_get_vertices_count(scn, &count)); + CHK(count == NB_CYL * CYL_VRTX_COUNT); + OK(senc_scene_get_triangles_count(scn, &count)); + CHK(count == NB_CYL * CYL_TRG_COUNT); + + OK(senc_scene_get_enclosure_count(scn, &count)); + CHK(count == 1 + NB_CYL); + FOR_EACH(e, 0, count) { + struct senc_enclosure* enclosure; + struct senc_enclosure_header header; + OK(senc_scene_get_enclosure(scn, e, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); + CHK(header.triangle_count == + e ? CYL_TRG_COUNT : NB_CYL * CYL_TRG_COUNT); + OK(senc_enclosure_ref_put(enclosure)); + } + + OK(senc_scene_ref_put(scn)); + OK(senc_device_ref_put(dev)); + + check_memory_allocator(&allocator); + mem_shutdown_proxy_allocator(&allocator); + CHK(mem_allocated_size() == 0); + return 0; +} diff --git a/src/test_senc_undefined_medium.c b/src/test_senc_undefined_medium.c @@ -13,17 +13,156 @@ * 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_wrapper.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 descriptor* desc = NULL; struct senc_device* dev = NULL; struct senc_scene* scn = NULL; struct senc_enclosure* enclosure; @@ -32,62 +171,28 @@ test(const int convention) unsigned gid; enum senc_side side; struct context ctx = CONTEXT_NULL__; - unsigned i, t, ecount, vcount, tcount, scount; - unsigned media[12]; - unsigned rev_box_indices[sizeof(box_indices) / sizeof(*box_indices)]; + unsigned i, t, ecount; const int conv_front = (convention & SENC_CONVENTION_NORMAL_FRONT) != 0; - /* Create a box with reversed triangles */ - FOR_EACH(i, 0, sizeof(rev_box_indices) / sizeof(*rev_box_indices)) { - switch (i % 3) { - case 0: rev_box_indices[i] = box_indices[i]; break; - case 1: rev_box_indices[i] = box_indices[i + 1]; break; - case 2: rev_box_indices[i] = box_indices[i - 1]; break; - } - } OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); - - OK(senc_scene_create(dev, convention, &scn)); - /* A 3D cube. - * 2 enclosures (inside, outside) sharing the same triangles, - * but opposite sides */ - ctx.positions = box_vertices; - ctx.indices = box_indices; - ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; - d3(ctx.offset, 0, 0, 0); - ctx.front_media = media; - ctx.back_media = medium1; - - /* Can add the same triangles again defined/undefined media in any order */ - - /* Add geometry with no media information on both sides */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = SENC_UNDEFINED_MEDIUM; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, NULL, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 2 * ntriangles); - - /* Add geometry with no media information on the front sides */ - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles); - - /* Analyze with undefined media on the front sides */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_get_enclosure_count(desc, &ecount)); + /* 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_descriptor_get_enclosure(desc, i, &enclosure)); + OK(senc_scene_get_enclosure(scn, i, &enclosure)); OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.enclosure_id == i); @@ -107,9 +212,9 @@ test(const int convention) CHK(header.vertices_count == nvertices); CHK(header.is_infinite == (i == 0)); - OK(senc_descriptor_get_enclosure_count_by_medium(desc, medium, &cc)); + OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc)); CHK(cc == 1); - OK(senc_descriptor_get_enclosure_by_medium(desc, medium, 0, &ee)); + 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)); @@ -118,115 +223,61 @@ test(const int convention) 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); + CHK(side == (medium == 1) ? SENC_BACK : SENC_FRONT); OK(senc_enclosure_get_triangle(enclosure, t, ind)); } OK(senc_enclosure_ref_put(enclosure)); } - OK(senc_descriptor_ref_put(desc)); + OK(senc_scene_ref_put(scn)); /* Same geometry, front media are defined for odd triangles */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2) ? 0 : SENC_UNDEFINED_MEDIUM; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles / 2); - - /* Analyze with undefined media */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); - - /* Get the deduplicated geometry without (successful) analyze */ - OK(senc_scene_get_unique_vertices_count(scn, &vcount)); - CHK(vcount == nvertices); - OK(senc_scene_get_triangles_count(scn, &tcount)); - CHK(tcount == ntriangles); - FOR_EACH(i, 0, tcount) { - int j; - unsigned med[2], ids[3]; - OK(senc_scene_get_triangle(scn, i, ids)); - OK(senc_scene_get_triangle_media(scn, i, med)); - CHK(med[0] == ((i % 2) ? 0 : SENC_UNDEFINED_MEDIUM) && med[1] == 1); - FOR_EACH(j, 0, 3) { - double pos[3]; - CHK(ids[j] < vcount); - OK(senc_scene_get_vertex(scn, ids[j], pos)); - } - } - - /* Same information again, using a reversed box */ - ctx.indices = rev_box_indices; - SWAP(const unsigned*, ctx.front_media, ctx.back_media); - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles / 2); + 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); - /* Analyze with undefined media */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); + 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)); - /* Define media for remaining triangles, using reversed box */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2) ? SENC_UNDEFINED_MEDIUM : 0; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); + CHK(header.enclosure_id == i); - /* Get the deduplicated geometry without (successful) analyze */ - OK(senc_scene_get_unique_vertices_count(scn, &vcount)); - CHK(vcount == nvertices); - OK(senc_scene_get_triangles_count(scn, &tcount)); - CHK(tcount == ntriangles); - FOR_EACH(i, 0, tcount) { - int j; - unsigned med[2], ids[3]; - OK(senc_scene_get_triangle(scn, i, ids)); - OK(senc_scene_get_triangle_media(scn, i, med)); - CHK(med[0] == 0 && med[1] == 1); - FOR_EACH(j, 0, 3) { - double pos[3]; - CHK(ids[j] < vcount); - OK(senc_scene_get_vertex(scn, ids[j], pos)); - } + 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)); - /* Analyze with all media defined */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); - - /* Define media for all triangles, nothing new here */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = 0; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); - - /* Define incoherent media for some triangles */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2); - BA(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, NULL, NULL, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); - - /* Scene is still OK and can be analyzed */ - OK(senc_scene_analyze(scn, &desc)); - - OK(senc_descriptor_get_triangles_count(desc, &tcount)); - CHK(tcount == sizeof(media) / sizeof(*media)); + /* 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_descriptor_get_enclosure_count(desc, &ecount)); + 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_descriptor_get_enclosure(desc, i, &enclosure)); + OK(senc_scene_get_enclosure(scn, i, &enclosure)); OK(senc_enclosure_get_header(enclosure, &header)); CHK(header.enclosure_id == i); @@ -241,9 +292,9 @@ test(const int convention) CHK(header.vertices_count == nvertices); CHK(header.is_infinite == (i == 0)); - OK(senc_descriptor_get_enclosure_count_by_medium(desc, medium, &cc)); + OK(senc_scene_get_enclosure_count_by_medium(scn, medium, &cc)); CHK(cc == 1); - OK(senc_descriptor_get_enclosure_by_medium(desc, medium, 0, &ee)); + 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)); @@ -258,7 +309,6 @@ test(const int convention) SENC(scene_ref_put(scn)); SENC(device_ref_put(dev)); - SENC(descriptor_ref_put(desc)); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); diff --git a/src/test_senc_undefined_medium_attr.c b/src/test_senc_undefined_medium_attr.c @@ -1,376 +0,0 @@ -/* Copyright (C) |Meso|Star> 2016-2018 (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/>. */ - -#include "senc.h" -#include "senc_s3d_wrapper.h" -#include "test_senc_utils.h" - -#include <rsys/double3.h> -#include <limits.h> - -#define INVALID_INTFACE_ID UINT_MAX - -static FINLINE void -set_null_id(struct mem_allocator* alloc, unsigned* data) -{ - ASSERT(data); (void)alloc; - *data = INVALID_INTFACE_ID; -} - -#include <rsys/dynamic_array.h> -#define DARRAY_NAME intface_id -#define DARRAY_FUNCTOR_INIT set_null_id -#define DARRAY_DATA unsigned -#include <rsys/dynamic_array.h> - -/* Manage interface properties */ -struct merge_ctx { - struct darray_intface_id global_interf_data; - const unsigned* current_add_interf_data; -}; - -static res_T -add_trg - (const unsigned global_id, - const unsigned itri, - void* context) -{ - res_T res = RES_OK; - struct context* ctx = context; - struct merge_ctx* merge_ctx; - unsigned interf; - ASSERT(ctx); - merge_ctx = ctx->custom; - /* Get interface information from ctx */ - interf = merge_ctx->current_add_interf_data[itri]; - /* Keep data */ - res = darray_intface_id_resize(&merge_ctx->global_interf_data, global_id + 1); - if(res != RES_OK) return res; - darray_intface_id_data_get(&merge_ctx->global_interf_data)[global_id] = interf; - return res; -} - -static res_T -merge_trg - (const unsigned global_id, - const unsigned itri, - const int reversed_triangle, - const unsigned triangle_media[2], - const unsigned merge_media[2], - void* context) -{ - res_T res = RES_OK; - struct context* ctx = context; - struct merge_ctx* merge_ctx; - int need_merge; - unsigned interf; - unsigned* interf_data; - int i, compat; - ASSERT(ctx); (void)reversed_triangle; - /* Check media compatibility */ - compat = 1; - FOR_EACH(i, 0, 2) - compat &= (triangle_media[i] == SENC_UNDEFINED_MEDIUM - || merge_media[i] == SENC_UNDEFINED_MEDIUM - || triangle_media[i] == merge_media[i]); - if(!compat) return RES_BAD_ARG; - merge_ctx = ctx->custom; - res = darray_intface_id_resize(&merge_ctx->global_interf_data, global_id + 1); - if(res != RES_OK) return res; - /* Get interface information from ctx */ - interf = merge_ctx->current_add_interf_data[itri]; - - interf_data = darray_intface_id_data_get(&merge_ctx->global_interf_data); - - need_merge = (interf_data[global_id] != INVALID_INTFACE_ID); - if(need_merge) { - if(interf_data[global_id] != interf) - /* Previous interface id is different: no possible merge */ - return RES_BAD_ARG; - } else { - /* Triangle is known, but without interface information: create */ - interf_data[global_id] = interf; - } - return RES_OK; -} - -static void -test(const int convention) -{ - struct mem_allocator allocator; - struct descriptor* desc = NULL; - 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, vcount, tcount, scount; - unsigned media[12], interface_ids[12] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; - unsigned rev_box_indices[sizeof(box_indices) / sizeof(*box_indices)]; - struct merge_ctx merge_ctx; - const int conv_front = (convention & SENC_CONVENTION_NORMAL_FRONT) != 0; - - darray_intface_id_init(&allocator, &merge_ctx.global_interf_data); - merge_ctx.current_add_interf_data = interface_ids; - - /* Create a box with reversed triangles */ - FOR_EACH(i, 0, sizeof(rev_box_indices) / sizeof(*rev_box_indices)) { - switch (i % 3) { - case 0: rev_box_indices[i] = box_indices[i]; break; - case 1: rev_box_indices[i] = box_indices[i + 1]; break; - case 2: rev_box_indices[i] = box_indices[i - 1]; break; - } - } - OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator)); - OK(senc_device_create(NULL, &allocator, SENC_NTHREADS_DEFAULT, 1, &dev)); - - OK(senc_scene_create(dev, convention, &scn)); - - /* A 3D cube. - * 2 enclosures (inside, outside) sharing the same triangles, - * but opposite sides */ - ctx.positions = box_vertices; - ctx.indices = box_indices; - ctx.scale = 1; - ctx.reverse_vrtx = 0; - ctx.reverse_med = 0; - d3(ctx.offset, 0, 0, 0); - ctx.front_media = media; - ctx.back_media = medium1; - ctx.custom = &merge_ctx; - - /* Can add the same triangles again defined/undefined media in any order */ - - /* Add geometry with no media information on both sides */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = SENC_UNDEFINED_MEDIUM; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 2 * ntriangles); - - /* If merge fails, add geometry fails */ - interface_ids[0] = 6; - BA(senc_scene_add_geometry(scn, ntriangles, get_indices, NULL, - nvertices, get_position, add_trg, merge_trg, &ctx)); - interface_ids[0] = 0; - - /* Add geometry with no media information on the front sides */ - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles); - - /* Analyze with undefined media on the front sides */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_get_enclosure_count(desc, &ecount)); - CHK(ecount == 2); - - FOR_EACH(i, 0, ecount) { - struct senc_enclosure* ee; - struct senc_enclosure_header hh; - unsigned cc; - OK(senc_descriptor_get_enclosure(desc, 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_descriptor_get_enclosure_count_by_medium(desc, medium, &cc)); - CHK(cc == 1); - OK(senc_descriptor_get_enclosure_by_medium(desc, 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_descriptor_ref_put(desc)); - - /* Same geometry, front media are defined for odd triangles */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2) ? 0 : SENC_UNDEFINED_MEDIUM; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles / 2); - - /* Analyze with undefined media */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); - - /* Get the deduplicated geometry without (successful) analyze */ - OK(senc_scene_get_unique_vertices_count(scn, &vcount)); - CHK(vcount == nvertices); - OK(senc_scene_get_triangles_count(scn, &tcount)); - CHK(tcount == ntriangles); - FOR_EACH(i, 0, tcount) { - int j; - unsigned med[2], ids[3]; - OK(senc_scene_get_triangle(scn, i, ids)); - OK(senc_scene_get_triangle_media(scn, i, med)); - CHK(med[0] == ((i % 2) ? 0 : SENC_UNDEFINED_MEDIUM) && med[1] == 1); - FOR_EACH(j, 0, 3) { - double pos[3]; - CHK(ids[j] < vcount); - OK(senc_scene_get_vertex(scn, ids[j], pos)); - } - } - - /* Same information again, using a reversed box */ - ctx.indices = rev_box_indices; - SWAP(const unsigned*, ctx.front_media, ctx.back_media); - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == ntriangles / 2); - - /* Analyze with undefined media */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); - - /* Define media for remaining triangles, using reversed box */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2) ? SENC_UNDEFINED_MEDIUM : 0; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); - - /* Get the deduplicated geometry without (successful) analyze */ - OK(senc_scene_get_unique_vertices_count(scn, &vcount)); - CHK(vcount == nvertices); - OK(senc_scene_get_triangles_count(scn, &tcount)); - CHK(tcount == ntriangles); - FOR_EACH(i, 0, tcount) { - int j; - unsigned med[2], ids[3]; - OK(senc_scene_get_triangle(scn, i, ids)); - OK(senc_scene_get_triangle_media(scn, i, med)); - CHK(med[0] == 0 && med[1] == 1); - FOR_EACH(j, 0, 3) { - double pos[3]; - CHK(ids[j] < vcount); - OK(senc_scene_get_vertex(scn, ids[j], pos)); - } - } - - /* Analyze with all media defined */ - OK(senc_scene_analyze(scn, &desc)); - OK(senc_descriptor_ref_put(desc)); - - /* Define media for all triangles, nothing new here */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = 0; - OK(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); - - /* Define incoherent media for some triangles */ - for(i = 0; i < sizeof(media) / sizeof(*media); i++) - media[i] = (i % 2); - BA(senc_scene_add_geometry(scn, ntriangles, get_indices, get_media, - nvertices, get_position, add_trg, merge_trg, &ctx)); - OK(senc_scene_get_unique_sides_without_medium_count(scn, &scount)); - CHK(scount == 0); - - /* Scene is still OK and can be analyzed */ - OK(senc_scene_analyze(scn, &desc)); - - OK(senc_descriptor_get_triangles_count(desc, &tcount)); - CHK(tcount == sizeof(media) / sizeof(*media)); - - OK(senc_descriptor_get_enclosure_count(desc, &ecount)); - CHK(ecount == 2); - - FOR_EACH(i, 0, ecount) { - struct senc_enclosure* ee; - struct senc_enclosure_header hh; - unsigned cc; - OK(senc_descriptor_get_enclosure(desc, 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_descriptor_get_enclosure_count_by_medium(desc, medium, &cc)); - CHK(cc == 1); - OK(senc_descriptor_get_enclosure_by_medium(desc, 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)); - SENC(descriptor_ref_put(desc)); - darray_intface_id_release(&merge_ctx.global_interf_data); - - 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 @@ -149,19 +149,19 @@ dump_global ASSERT(scn && name); - CHK(senc_scene_get_vertices_count(scn, &vertices_count) == RES_OK); - CHK(senc_scene_get_triangles_count(scn, &triangles_count) == RES_OK); + OK(senc_scene_get_vertices_count(scn, &vertices_count)); + OK(senc_scene_get_triangles_count(scn, &triangles_count)); stream = fopen(name, "w"); CHK(stream); FOR_EACH(i, 0, vertices_count) { double tmp[3]; - CHK(senc_scene_get_vertex(scn, i, tmp) == RES_OK); + OK(senc_scene_get_vertex(scn, i, tmp)); fprintf(stream, "v %g %g %g\n", SPLIT3(tmp)); } FOR_EACH(i, 0, triangles_count) { unsigned indices[3]; - CHK(senc_scene_get_triangle(scn, i, indices) == RES_OK); + OK(senc_scene_get_triangle(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])); } @@ -183,23 +183,23 @@ dump_enclosure SENC(scene_get_enclosure_count(scn, &count)); ASSERT(enc < count); - CHK(senc_scene_get_enclosure(scn, enc, &enclosure) == RES_OK); - CHK(senc_enclosure_get_header(enclosure, &header) == RES_OK); + OK(senc_scene_get_enclosure(scn, enc, &enclosure)); + OK(senc_enclosure_get_header(enclosure, &header)); stream = fopen(name, "w"); CHK(stream); FOR_EACH(i, 0, header.vertices_count) { double tmp[3]; - CHK(senc_enclosure_get_vertex(enclosure, i, tmp) == RES_OK); + OK(senc_enclosure_get_vertex(enclosure, i, tmp)); fprintf(stream, "v %g %g %g\n", SPLIT3(tmp)); } FOR_EACH(i, 0, header.triangle_count) { unsigned indices[3]; - CHK(senc_enclosure_get_triangle(enclosure, i, indices) == RES_OK); + OK(senc_enclosure_get_triangle(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])); } - CHK(senc_enclosure_ref_put(enclosure) == RES_OK); + OK(senc_enclosure_ref_put(enclosure)); fclose(stream); } @@ -235,9 +235,9 @@ cmp_trg ASSERT(enclosure && trg2 && vertices2 && trg_eq && trg_reversed); - CHK(senc_enclosure_get_triangle(enclosure, itri, trg1) == RES_OK); + OK(senc_enclosure_get_triangle(enclosure, itri, trg1)); FOR_EACH(i, 0, 3) { - CHK(senc_enclosure_get_vertex(enclosure, trg1[i], t1[i]) == RES_OK); + OK(senc_enclosure_get_vertex(enclosure, trg1[i], t1[i])); d3_set(t2[i], vertices2 + (3 * trg2[i])); } FOR_EACH(i, 0, 3) { @@ -269,4 +269,3 @@ cmp_trg } #endif /* TEST_UTILS_H */ -