Compare commits
No commits in common. "166dc651b49a784ed3f65ffe181a6efc05104e39" and "0b5dd38b580d03e4b99f07f061c8dc7bdc6eecae" have entirely different histories.
166dc651b4
...
0b5dd38b58
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,7 +6,7 @@ tbb
|
|||||||
gmon.out
|
gmon.out
|
||||||
dummy-file
|
dummy-file
|
||||||
|
|
||||||
tools/*.obj
|
tools/covid-19.obj
|
||||||
tools/read_obj
|
tools/read_obj
|
||||||
tools/xyz
|
tools/xyz
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT
|
||||||
|
|
||||||
libbubulles.a: bubulles.o importobj.o
|
libbubulles.a: bubulles.o importobj.o
|
||||||
ar r $@ $?
|
ar r $@ $?
|
||||||
|
10
bubulles.c
10
bubulles.c
@ -45,7 +45,7 @@ Bubulle *array;
|
|||||||
fprintf(stderr, "+++ %s '%s' %d 0x%X\n", __func__, name, sz, unused);
|
fprintf(stderr, "+++ %s '%s' %d 0x%X\n", __func__, name, sz, unused);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NULL==(bblptr = calloc(1, sizeof(BBList)))) {
|
if (NULL==(bblptr = malloc(sizeof(BBList)))) {
|
||||||
fprintf(stderr, "no mem available in %s\n", __func__);
|
fprintf(stderr, "no mem available in %s\n", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -142,13 +142,17 @@ fprintf(stderr, "XYZ %f %f %f\n", what->p.x, what->p.y, what->p.z);
|
|||||||
if (where->fidx > where->size) {
|
if (where->fidx > where->size) {
|
||||||
/* this is a very bad fatal error */
|
/* this is a very bad fatal error */
|
||||||
fprintf(stderr, "%s : overflow in BBList at %p\n", __func__, where);
|
fprintf(stderr, "%s : overflow in BBList at %p\n", __func__, where);
|
||||||
#if MUST_ABORT
|
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (where->fidx > where->size) {
|
||||||
|
/* array is full */
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "%s : array of %p is full\n", __func__, where);
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));
|
memcpy(&where->bbs[where->fidx], what, sizeof(Bubulle));
|
||||||
|
|
||||||
where->fidx++;
|
where->fidx++;
|
||||||
|
36
importobj.c
36
importobj.c
@ -21,9 +21,7 @@ int try_to_read_an_OBJ_file(char *fname, int notused)
|
|||||||
FILE *fpin;
|
FILE *fpin;
|
||||||
char line[LINE_SZ+1], *cptr;
|
char line[LINE_SZ+1], *cptr;
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
int foo, nbre;
|
int foo;
|
||||||
BBList *bublist;
|
|
||||||
Bubulle bubulle;
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||||
@ -34,14 +32,6 @@ if (NULL==(fpin=fopen(fname, "r"))) {
|
|||||||
exit(1);
|
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)) {
|
while(cptr=fgets(line, LINE_SZ, fpin)) {
|
||||||
|
|
||||||
if (verbosity>1) fputs(line, stderr);
|
if (verbosity>1) fputs(line, stderr);
|
||||||
@ -56,28 +46,16 @@ while(cptr=fgets(line, LINE_SZ, fpin)) {
|
|||||||
cptr = strtok(NULL, " ");
|
cptr = strtok(NULL, " ");
|
||||||
foo = sscanf(cptr, "%f", &z);
|
foo = sscanf(cptr, "%f", &z);
|
||||||
|
|
||||||
memset(&bubulle, 0, sizeof(Bubulle));
|
fprintf(stdout, "%16g %16g %16g\n", x, y, z);
|
||||||
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);
|
fclose(fpin);
|
||||||
|
|
||||||
if(verbosity) {
|
return -7800;
|
||||||
fprintf(stderr, "%s : %d vertices loaded\n", __func__, nbre);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
BBFUNCS = ../libbubulles.a
|
BBFUNCS = ../libbubulles.a
|
||||||
|
|
||||||
OPT = -Wall -g -DDEBUG_LEVEL=1 -DMUST_ABORT
|
read_obj: read_obj.c Makefile ${BBFUNCS}
|
||||||
|
gcc -Wall -DDEBUG_LEVEL=1 $< ${BBFUNCS} -o $@
|
||||||
read_obj: read_obj.c Makefile $(BBFUNCS)
|
|
||||||
gcc $(OPT) $< $(BBFUNCS) -o $@
|
|
||||||
|
@ -18,10 +18,12 @@ if (2 != argc) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosity = 1;
|
verbosity = 0;
|
||||||
|
|
||||||
foo = try_to_read_an_OBJ_file(argv[1], 0);
|
foo = try_to_read_an_OBJ_file(argv[1], 0);
|
||||||
fprintf(stderr, "try to read -> %d\n", foo);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user