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 014908213d57220cdf6803703527211d552f37c7
parent 60d7023decc610df689a8aa6c5807a7bc33fd4c4
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Fri, 16 Mar 2018 13:42:28 +0100

Add an utility fn to dump an obj of the whole scene

Remove unused code too

Diffstat:
Msrc/test_senc_utils.h | 39+++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/test_senc_utils.h b/src/test_senc_utils.h @@ -118,25 +118,32 @@ get_global_id(const unsigned itri, unsigned* gid, void* context) * Miscellaneous ******************************************************************************/ static INLINE void -dump_mesh - (FILE* stream, - const double* pos, - const size_t npos, - const size_t* ids, - const size_t nids) +dump_global + (struct senc_descriptor* desc, + const char* name) { - size_t i; - CHK(pos != NULL && npos != 0); - CHK(ids != NULL && nids != 0); - FOR_EACH(i, 0, npos) { - fprintf(stream, "v %g %g %g\n", SPLIT3(pos+i*3)); + FILE* stream; + unsigned triangles_count, vertices_count, i; + + ASSERT(desc && name); + + CHK(senc_descriptor_get_global_vertices_count(desc, &vertices_count) == RES_OK); + CHK(senc_descriptor_get_global_triangles_count(desc, &triangles_count) == RES_OK); + + stream = fopen(name, "w"); + CHK(stream); + FOR_EACH(i, 0, vertices_count) { + double tmp[3]; + CHK(senc_descriptor_get_global_vertex(desc, i, tmp) == RES_OK); + fprintf(stream, "v %g %g %g\n", SPLIT3(tmp)); } - FOR_EACH(i, 0, nids) { - fprintf(stream, "f %lu %lu %lu\n", - (unsigned long)(ids[i*3+0] + 1), - (unsigned long)(ids[i*3+1] + 1), - (unsigned long)(ids[i*3+2] + 1)); + FOR_EACH(i, 0, triangles_count) { + unsigned indices[3]; + CHK(senc_descriptor_get_global_triangle(desc, i, indices) == RES_OK); + fprintf(stream, "f %lu %lu %lu\n", (unsigned long)(1 + indices[0]), + (unsigned long)(1 + indices[1]), (unsigned long)(1 + indices[2])); } + fclose(stream); } static INLINE void