This commit is contained in:
tTh 2022-05-21 13:41:20 +02:00
parent bcd64245d2
commit 9cbbb35cde
6 changed files with 16 additions and 13 deletions

2
.gitignore vendored
View File

@ -8,5 +8,5 @@ dummy-file
tools/*.obj
tools/read_obj
tools/xyz
tools/*.xyz

View File

@ -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 $@ $?

View File

@ -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__);
@ -148,7 +151,6 @@ if (where->fidx >= where->size) {
return -1;
}
memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));
where->fidx++;

View File

@ -4,7 +4,7 @@
/* --------------------------------------------------------------------- */
#define LIBBB_VERSION 56
#define LIBBB_VERSION 57
#define SZ_BUBULLE_TEXT 51 /* arbitrary value */

View File

@ -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;
}

View File

@ -6,7 +6,7 @@
#include <stdlib.h>
#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;