Compare commits

...

2 Commits

Author SHA1 Message Date
0b5dd38b58 read .OBJ file, second step 2020-06-05 01:05:01 +02:00
5a6e98d034 read .OBJ file, first try 2020-06-05 00:17:17 +02:00
7 changed files with 105 additions and 2 deletions

5
.gitignore vendored
View File

@ -5,3 +5,8 @@ libbubulles.a
tbb
gmon.out
dummy-file
tools/covid-19.obj
tools/read_obj
tools/xyz

View File

@ -12,12 +12,15 @@ CC = gcc
OPT = -Wall -g -DDEBUG_LEVEL=0 -DMUST_ABORT
libbubulles.a: bubulles.o
libbubulles.a: bubulles.o importobj.o
ar r $@ $?
bubulles.o: bubulles.c bubulles.h Makefile
$(CC) $(OPT) -c $<
importobj.o: importobj.c bubulles.h Makefile
$(CC) $(OPT) -c $<
# ------------------------------------------------
# --- build some tests and tools

View File

@ -4,7 +4,7 @@
/* --------------------------------------------------------------------- */
#define LIBBB_VERSION 52
#define LIBBB_VERSION 53
#define SZ_BUBULLE_TEXT 51 /* arbitrary value */

0
doc/tricks.txt Normal file
View File

61
importobj.c Normal file
View File

@ -0,0 +1,61 @@
/*
LIBBUBULLES
some functions for importing bubulles from dot-OBJ files.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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", __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;
}
/* --------------------------------------------------------------------- */

5
tools/Makefile Normal file
View File

@ -0,0 +1,5 @@
BBFUNCS = ../libbubulles.a
read_obj: read_obj.c Makefile ${BBFUNCS}
gcc -Wall -DDEBUG_LEVEL=1 $< ${BBFUNCS} -o $@

29
tools/read_obj.c Normal file
View File

@ -0,0 +1,29 @@
/*
tentatives de lecture des OBJ
*/
#include <stdio.h>
#include <stdlib.h>
#include "../bubulles.h"
int try_to_read_an_OBJ_file(char *fname, int notused);
int verbosity;
int main(int argc, char *argv[])
{
int foo;
if (2 != argc) {
bubulles_version(1);
exit(0);
}
verbosity = 0;
foo = try_to_read_an_OBJ_file(argv[1], 0);
return 0;
}