From 166dc651b49a784ed3f65ffe181a6efc05104e39 Mon Sep 17 00:00:00 2001 From: tonton th Date: Fri, 5 Jun 2020 10:57:43 +0200 Subject: [PATCH] more bugs --- .gitignore | 2 +- importobj.c | 36 +++++++++++++++++++++++++++++------- tools/read_obj.c | 6 ++---- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 0072ba4..74de672 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ tbb gmon.out dummy-file -tools/covid-19.obj +tools/*.obj tools/read_obj tools/xyz diff --git a/importobj.c b/importobj.c index ae7e1ad..b3c5ac3 100644 --- a/importobj.c +++ b/importobj.c @@ -21,7 +21,9 @@ int try_to_read_an_OBJ_file(char *fname, int notused) FILE *fpin; char line[LINE_SZ+1], *cptr; float x, y, z; -int foo; +int foo, nbre; +BBList *bublist; +Bubulle bubulle; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused); @@ -32,6 +34,14 @@ if (NULL==(fpin=fopen(fname, "r"))) { exit(1); } +bublist = alloc_bubulles(fname, 1000, 0); +if (NULL==bublist) { + fprintf(stderr, "err in %s, aborting...\n", __func__); + abort(); + } +print_bublist_desc(bublist, 0); + +nbre = 0; while(cptr=fgets(line, LINE_SZ, fpin)) { if (verbosity>1) fputs(line, stderr); @@ -46,16 +56,28 @@ while(cptr=fgets(line, LINE_SZ, fpin)) { cptr = strtok(NULL, " "); foo = sscanf(cptr, "%f", &z); - fprintf(stdout, "%16g %16g %16g\n", x, y, z); + memset(&bubulle, 0, sizeof(Bubulle)); + niceprint_bubulle(&bubulle, 0); + bubulle.p.x = x; + bubulle.p.y = y; + bubulle.p.z = z; + niceprint_bubulle(&bubulle, 0); + + foo = push_bubulle(bublist, &bubulle); + if (foo) { + fprintf(stderr, "err %d on push\n", foo); + break; + } + nbre++; } - - - - fclose(fpin); -return -7800; +if(verbosity) { + fprintf(stderr, "%s : %d vertices loaded\n", __func__, nbre); + } + +return 0; } /* --------------------------------------------------------------------- */ diff --git a/tools/read_obj.c b/tools/read_obj.c index 30436f2..a7744fa 100644 --- a/tools/read_obj.c +++ b/tools/read_obj.c @@ -18,12 +18,10 @@ if (2 != argc) { exit(0); } -verbosity = 0; +verbosity = 1; foo = try_to_read_an_OBJ_file(argv[1], 0); - - - +fprintf(stderr, "try to read -> %d\n", foo); return 0; }