diff --git a/.gitignore b/.gitignore index f7d9566..0072ba4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ dummy-file tools/covid-19.obj tools/read_obj +tools/xyz diff --git a/importobj.c b/importobj.c index 94496c7..ae7e1ad 100644 --- a/importobj.c +++ b/importobj.c @@ -10,16 +10,51 @@ #include "bubulles.h" +extern int verbosity; + /* --------------------------------------------------------------------- */ +#define LINE_SZ 666 + 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; #if DEBUG_LEVEL -fprintf(stderr, ">>> %s ( '%s' %d)\n", fname, notused); +fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused); #endif +if (NULL==(fpin=fopen(fname, "r"))) { + perror(fname); + exit(1); + } + +while(cptr=fgets(line, LINE_SZ, fpin)) { + + if (verbosity>1) fputs(line, stderr); + + cptr = strtok(line, " "); + if (strcmp(cptr, "v")) continue; + + cptr = strtok(NULL, " "); + foo = sscanf(cptr, "%f", &x); + cptr = strtok(NULL, " "); + foo = sscanf(cptr, "%f", &y); + cptr = strtok(NULL, " "); + foo = sscanf(cptr, "%f", &z); + + fprintf(stdout, "%16g %16g %16g\n", x, y, z); + + } + + + + +fclose(fpin); + return -7800; } diff --git a/tools/Makefile b/tools/Makefile index 1cb716b..4c29a5a 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -2,4 +2,4 @@ BBFUNCS = ../libbubulles.a read_obj: read_obj.c Makefile ${BBFUNCS} - gcc -Wall $< ${BBFUNCS} -o $@ + gcc -Wall -DDEBUG_LEVEL=1 $< ${BBFUNCS} -o $@ diff --git a/tools/read_obj.c b/tools/read_obj.c index a5cc6c3..30436f2 100644 --- a/tools/read_obj.c +++ b/tools/read_obj.c @@ -6,6 +6,9 @@ #include #include "../bubulles.h" +int try_to_read_an_OBJ_file(char *fname, int notused); +int verbosity; + int main(int argc, char *argv[]) { int foo; @@ -15,8 +18,9 @@ if (2 != argc) { exit(0); } +verbosity = 0; -// foo = try_to_read_an_OBJ_file(argv[1], 0); +foo = try_to_read_an_OBJ_file(argv[1], 0);