Compare commits
2 Commits
457afac7c0
...
ce2154d9c1
Author | SHA1 | Date | |
---|---|---|---|
|
ce2154d9c1 | ||
|
f4d5557b4f |
8
Makefile
8
Makefile
@ -12,19 +12,19 @@ CC = gcc
|
||||
|
||||
OPT = -Wall -g -O3 -DDEBUG_LEVEL=0 -DMUST_ABORT=0
|
||||
|
||||
libbubulles.a: bubulles.o importobj.o
|
||||
libbubulles.a: bubulles.o edges.o
|
||||
ar r $@ $?
|
||||
|
||||
bubulles.o: bubulles.c bubulles.h Makefile
|
||||
$(CC) $(OPT) -c $<
|
||||
|
||||
importobj.o: importobj.c bubulles.h Makefile
|
||||
edges.o: edges.c bubulles.h edges.h Makefile
|
||||
$(CC) $(OPT) -c $<
|
||||
|
||||
# ------------------------------------------------
|
||||
# --- build some tests and tools
|
||||
|
||||
tbb: tbb.c bubulles.h bubulles.o Makefile
|
||||
$(CC) $(OPT) $< bubulles.o -o tbb
|
||||
tbb: tbb.c bubulles.h libbubulles.a Makefile
|
||||
$(CC) $(OPT) $< libbubulles.a -o tbb
|
||||
|
||||
#############################################
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "bubulles.h"
|
||||
#include "edges.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
@ -32,6 +33,8 @@ printf("%-15s %4lu\n", "XYZ", sizeof(XYZ));
|
||||
printf("%-15s %4lu\n", "RGBA", sizeof(RGBA));
|
||||
printf("%-15s %4lu\n", "Bubulle", sizeof(Bubulle));
|
||||
printf("%-15s %4lu\n", "BBList", sizeof(BBList));
|
||||
printf("%-15s %4lu\n", "AnEdge", sizeof(AnEdge));
|
||||
printf("%-15s %4lu\n", "EdgeList", sizeof(EdgeList));
|
||||
puts("");
|
||||
}
|
||||
|
||||
@ -228,10 +231,8 @@ fprintf(stderr, "*** %s : array at %p, sz %d\n", __func__, ar, bbl->size);
|
||||
for (idx=0; idx<bbl->fidx; idx++) {
|
||||
fprintf(fp, "%12.6f %12.6f %12.6f",
|
||||
ar[idx].p.x, ar[idx].p.y, ar[idx].p.z);
|
||||
|
||||
if (opts & 0x01) fprintf(fp, " %12.6f", ar[idx].d);
|
||||
if (opts & 0x02) fprintf(fp, " %6d", ar[idx].gray);
|
||||
|
||||
fputs("\n", fp);
|
||||
}
|
||||
fflush(fp);
|
||||
@ -248,7 +249,6 @@ printf("xyzd %11.6f %11.6f %11.6f %11.6f\n",
|
||||
printf("diam %11.6f gray %5d\n", what->d, what->gray);
|
||||
printf("rgba %11.6f %11.6f %11.6f %11.6f\n",
|
||||
what->col.r, what->col.g, what->col.b, what->col.a);
|
||||
|
||||
puts("----------------------------------------------------------");
|
||||
|
||||
return 0;
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define LIBBB_VERSION 57
|
||||
#define LIBBB_VERSION 60
|
||||
|
||||
#define SZ_BUBULLE_TEXT 51 /* arbitrary value */
|
||||
#define SZ_BUBULLE_TEXT 81 /* arbitrary value */
|
||||
|
||||
/* a 3d space coordinate */
|
||||
typedef struct {
|
||||
@ -77,7 +77,7 @@ int fprint_bubulles(FILE *fp, char *title, BBList *bbl, int flags);
|
||||
int niceprint_bubulle(Bubulle *what, int unused);
|
||||
|
||||
/* this is just a wtf function * see tbb.c */
|
||||
int bubulles_to_data(char *fname, char *title, BBList *bbl, int k);
|
||||
int bubulles_to_data(char *fname, char *title, BBList *bbl, int flags);
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* sometime we want to look at the bounding box */
|
||||
|
23
edges.c
Normal file
23
edges.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* edges.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bubulles.h"
|
||||
#include "edges.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int print_edgelist_desc(EdgeList *list, int k)
|
||||
{
|
||||
|
||||
printf("edgelist addr: %p\n", list);
|
||||
|
||||
if (k) {
|
||||
fprintf(stderr, "%s: k must be 0, was %d\n", __func__, k);
|
||||
return k;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
19
edges.h
Normal file
19
edges.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* edges.h
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
int A, B;
|
||||
} AnEdge;
|
||||
|
||||
typedef struct {
|
||||
char name[SZ_BUBULLE_TEXT+1];
|
||||
int size; /* max number of edges */
|
||||
int fidx; /* next free slot */
|
||||
AnEdge *edges;
|
||||
unsigned long flags;
|
||||
} EdgeList;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
@ -3,5 +3,8 @@ BBFUNCS = ../libbubulles.a
|
||||
|
||||
OPT = -Wall -g -DDEBUG_LEVEL=1 -DMUST_ABORT
|
||||
|
||||
read_obj: read_obj.c Makefile $(BBFUNCS)
|
||||
gcc $(OPT) $< $(BBFUNCS) -o $@
|
||||
read_obj: read_obj.c Makefile importobj.o $(BBFUNCS)
|
||||
gcc $(OPT) $< importobj.o $(BBFUNCS) -o $@
|
||||
|
||||
importobj.o: importobj.c ../bubulles.h Makefile
|
||||
$(CC) $(OPT) -c $<
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bubulles.h"
|
||||
#include "../bubulles.h"
|
||||
#include "../edges.h"
|
||||
|
||||
extern int verbosity;
|
||||
|
||||
@ -22,18 +23,19 @@ typedef struct {
|
||||
int id;
|
||||
} Tokens;
|
||||
|
||||
enum token_id { T_comment=1, T_vertice };
|
||||
enum token_id { T_comment=1, T_vertice, T_group, T_face };
|
||||
|
||||
Tokens TokenList[] = {
|
||||
{ "#", T_comment },
|
||||
{ "v", T_vertice },
|
||||
{ "g", T_group }, // to be verified
|
||||
{ "f", T_face },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static int type_of_the_line(char *text)
|
||||
{
|
||||
Tokens *token;
|
||||
int id;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s is searching '%s'\n", __func__, text);
|
||||
@ -74,12 +76,12 @@ int try_to_read_an_OBJ_file(char *infname, char *outfname, int notused)
|
||||
FILE *fpin;
|
||||
char line[LINE_SZ+1], *cptr;
|
||||
float x, y, z;
|
||||
int foo, nbre, tokenid;
|
||||
int foo, nbre, tokenid, fa, fb, ix;
|
||||
BBList *bublist;
|
||||
Bubulle bubulle;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, notused);
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, infname, notused);
|
||||
#endif
|
||||
|
||||
if (NULL==(fpin=fopen(infname, "r"))) {
|
||||
@ -112,7 +114,8 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
continue;
|
||||
}
|
||||
tokenid = type_of_the_line(cptr);
|
||||
if (verbosity > 1) fprintf(stderr, "token '%s' --> %d\n", cptr, tokenid);
|
||||
if (verbosity > 1)
|
||||
fprintf(stderr, "token '%s' --> %d\n", cptr, tokenid);
|
||||
|
||||
memset(&bubulle, 0, sizeof(Bubulle));
|
||||
|
||||
@ -120,6 +123,7 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
case T_comment:
|
||||
/* do nothing */
|
||||
break;
|
||||
|
||||
case T_vertice:
|
||||
x = y = z = 0.0;
|
||||
foo = parse_vertice(cptr, &x, &y, &z);
|
||||
@ -128,6 +132,24 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
bubulle.p.z = z;
|
||||
if (verbosity > 1) niceprint_bubulle(&bubulle, 0);
|
||||
break;
|
||||
|
||||
case T_group:
|
||||
cptr = strtok(NULL, " ");
|
||||
fprintf(stderr, "Group: %s\n", cptr);
|
||||
break;
|
||||
|
||||
case T_face:
|
||||
fprintf(stderr, "Face A: %s\n", cptr);
|
||||
for (ix=0; ix<3; ix++) {
|
||||
cptr = strtok(NULL, " ");
|
||||
fprintf(stderr, "Piste %d: %s\n", ix, cptr);
|
||||
if (2==sscanf(cptr, "%d/%d", &fa, &fb))
|
||||
fprintf(stderr, " %d %d %d\n", foo, fa, fb);
|
||||
else
|
||||
return -3;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// fprintf(stderr, "token %d ?\n", tokenid);
|
||||
continue; /* wtf ? */
|
||||
@ -135,7 +157,8 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
|
||||
foo = push_bubulle(bublist, &bubulle);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d on push\n", __func__, foo);
|
||||
fprintf(stderr, "*** %s: error %d on push\n", __func__, foo);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
nbre++;
|
@ -20,8 +20,13 @@ if (2 != argc) {
|
||||
|
||||
verbosity = 1;
|
||||
|
||||
<<<<<<< HEAD
|
||||
foo = try_to_read_an_OBJ_file(argv[1], "bulles.xyz", 0);
|
||||
fprintf(stderr, "try to read '%s' --> %d\n", argv[1], foo);
|
||||
=======
|
||||
foo = try_to_read_an_OBJ_file(argv[1], "bubulles.asc", 0);
|
||||
fprintf(stderr, "try to read -> %d\n", foo);
|
||||
>>>>>>> 457afac7c0a208413ff6a7f1d0932da76ecf685b
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user