diff --git a/.gitignore b/.gitignore index 74de672..2ea0f84 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ dummy-file tools/*.obj tools/read_obj -tools/xyz +tools/*.xyz diff --git a/Makefile b/Makefile index e270699..8ad3a05 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CC = gcc -OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0 +OPT = -Wall -g -O3 -DDEBUG_LEVEL=0 -DMUST_ABORT=0 libbubulles.a: bubulles.o importobj.o ar r $@ $? diff --git a/bubulles.c b/bubulles.c index 0a6885d..586a3b8 100644 --- a/bubulles.c +++ b/bubulles.c @@ -75,6 +75,9 @@ return bblptr; /* --------------------------------------------------------------------- */ int free_bubulles(BBList *bbl, int k) { +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d )\n", __func__, bbl, k); +#endif if (NULL == bbl->bbs) { fprintf(stderr, "%s : array ptr is null\n", __func__); @@ -147,7 +150,6 @@ if (where->fidx >= where->size) { #endif return -1; } - memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle)); diff --git a/bubulles.h b/bubulles.h index 7a1ba48..2c95cde 100644 --- a/bubulles.h +++ b/bubulles.h @@ -4,7 +4,7 @@ /* --------------------------------------------------------------------- */ -#define LIBBB_VERSION 56 +#define LIBBB_VERSION 57 #define SZ_BUBULLE_TEXT 51 /* arbitrary value */ diff --git a/importobj.c b/importobj.c index 8912b7b..159d9df 100644 --- a/importobj.c +++ b/importobj.c @@ -69,7 +69,7 @@ if (3 == foo) { return foo; } /* --------------------------------------------------------------------- */ -int try_to_read_an_OBJ_file(char *fname, int notused) +int try_to_read_an_OBJ_file(char *infname, char *outfname, int notused) { FILE *fpin; char line[LINE_SZ+1], *cptr; @@ -82,12 +82,12 @@ Bubulle bubulle; fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused); #endif -if (NULL==(fpin=fopen(fname, "r"))) { - perror(fname); +if (NULL==(fpin=fopen(infname, "r"))) { + perror(infname); exit(1); } -bublist = alloc_bubulles(fname, 1000, 0); +bublist = alloc_bubulles(infname, 1000, 0); if (NULL==bublist) { fprintf(stderr, "err in %s, aborting...\n", __func__); abort(); @@ -110,7 +110,7 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) { continue; } tokenid = type_of_the_line(cptr); - fprintf(stderr, "tok '%s' --> %d\n", cptr, tokenid); + if (verbosity) fprintf(stderr, "token '%s' --> %d\n", cptr, tokenid); memset(&bubulle, 0, sizeof(Bubulle)); @@ -119,6 +119,7 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) { /* do nothing */ break; case T_vertice: + x = y = z = 0.0; foo = parse_vertice(cptr, &x, &y, &z); bubulle.p.x = x; bubulle.p.y = y; @@ -126,7 +127,7 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) { if (verbosity > 1) niceprint_bubulle(&bubulle, 0); break; default: - + // fprintf(stderr, "token %d ?\n", tokenid); continue; /* wtf ? */ } @@ -143,7 +144,7 @@ if(verbosity) { fprintf(stderr, "%s : %d vertices loaded\n", __func__, nbre); } -bubulles_to_data("xyz", NULL, bublist, 0); +bubulles_to_data(outfname, NULL, bublist, 0); return 0; } diff --git a/tools/read_obj.c b/tools/read_obj.c index cd645af..d78bbc9 100644 --- a/tools/read_obj.c +++ b/tools/read_obj.c @@ -6,7 +6,7 @@ #include #include "../bubulles.h" -int try_to_read_an_OBJ_file(char *fname, int notused); +int try_to_read_an_OBJ_file(char *fname, char *outfname, int notused); int verbosity; int main(int argc, char *argv[]) @@ -20,7 +20,7 @@ if (2 != argc) { verbosity = 2; -foo = try_to_read_an_OBJ_file(argv[1], 0); +foo = try_to_read_an_OBJ_file(argv[1], "bulles.xyz", 0); fprintf(stderr, "try to read -> %d\n", foo); return 0;