Compare commits

..

No commits in common. "5eaa64a6642b6d2142f2fcced0fa18c647e3667f" and "f5de09b23af6d1ec981a190e882d8d64cedb0ac6" have entirely different histories.

16 changed files with 68 additions and 219 deletions

View File

@ -122,15 +122,15 @@ int print_bublist_desc(BBList *bbl, int opts)
{
fprintf(stderr, "------- bblist at %p\n", bbl);
fprintf(stderr, "\tname\t\t'%s'\n", bbl->name);
fprintf(stderr, "\tname \t'%s'\n", bbl->name);
fprintf(stderr, "\tsize/fidx\t%d %d\n", bbl->size, bbl->fidx);
fprintf(stderr, "\tsize\t%6d\n\tfidx\t%6d\n", bbl->size, bbl->fidx);
if (opts & 0x01) {
fprintf(stderr, "\txyz\t\t%f %f %f\n",
fprintf(stderr, "\txyz\t%f %f %f\n",
bbl->position.x, bbl->position.y, bbl->position.z);
}
fprintf(stderr, "\tflags\t\t0x%08lX\n", bbl->flags);
fprintf(stderr, "\tarray@\t\t%p\n", bbl->bbs);
fprintf(stderr, "\tflags\t0x%08lX\n", bbl->flags);
fprintf(stderr, "\tarray\t%p\n", bbl->bbs);
fflush(stderr);

View File

@ -4,7 +4,7 @@
/* --------------------------------------------------------------------- */
#define LIBBB_VERSION 64
#define LIBBB_VERSION 63
#define SZ_BUBULLE_TEXT 81 /* arbitrary value */

24
edges.c
View File

@ -70,36 +70,28 @@ return 0;
*/
static int is_edge_in_list(EdgeList *list, int p0, int p1)
{
int idx, retval, place;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, list, p0, p1);
#endif
retval = 0; place = -1;
int idx;
for (idx=0; idx < list->fidx; idx++) {
if ( (list->edges[idx].A == p0) &&
(list->edges[idx].B == p1) ) {
retval = 1; place = idx; break; }
(list->edges[idx].B == p1) ) return 1;
if ( (list->edges[idx].A == p1) &&
(list->edges[idx].B == p0) ){
retval = 2; place = idx; break; }
(list->edges[idx].B == p0) ) return 2;
}
if (retval) fprintf(stderr, " edge %d %d found at %d\n", p0, p1, idx);
return retval;
return 0; /* NOT FOUND */
}
/* --------------------------------------------------------------------- */
/*
*
* we have two functions for adding an edge to a list
* the first one add unconditionnaly the edge to the
* (non full) list...
*/
int push_an_edge(EdgeList *list, int p0, int p1)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, list, p0, p1);
#endif
@ -138,12 +130,8 @@ if (list->fidx >= list->size) {
if ( ! is_edge_in_list(list, p0, p1) ) {
list->edges[list->fidx].A = p0;
list->edges[list->fidx].B = p1;
fprintf(stderr, "edge %d %d poked at %d\n", p0, p1, list->fidx);
list->fidx ++;
}
else {
fprintf(stderr, " %s: drop edge %d %d\n", __func__, p0, p1);
}
return 0;
}
/* --------------------------------------------------------------------- */

8
tbb.c
View File

@ -186,8 +186,7 @@ int main(int argc, char *argv[])
{
int foo;
fprintf(stderr, "***\n*** Bubulles Testing %s %s\n***\n",
__DATE__, __TIME__);
fprintf(stderr, "*** Bubulles Testing %s %s\n\n", __DATE__, __TIME__);
bubulles_version(0);
@ -201,9 +200,8 @@ foo = test_peek_poke(5000);
fprintf(stderr, "test peek/poke -> %d\n", foo);
#endif
foo = essai_des_edges_A(25);
fprintf(stderr, "test A des edges -> %d\n", foo);
// XXX foo = essai_des_edges_A(25);
// XXX fprintf(stderr, "test A des edges -> %d\n", foo);
foo = essai_des_edges_B(5000);
fprintf(stderr, "test B des edges -> %d\n", foo);

2
tools/.gitignore vendored
View File

@ -6,9 +6,7 @@ export_evblob
*.obj
! tools/minimal.obj
! tools/cube.obj
! overflowed.obj
read_obj
*.xyz
*.asc
toto

View File

@ -1,7 +1,7 @@
BBFUNCS = ../libbubulles.a
OPT = -Wall -Wextra -O1 -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
OPT = -Wall -Wextra -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0
all: read_obj export_evblob # essai_faces

View File

@ -58,7 +58,6 @@ ce qui nous remet dans la droite ligne orthodoxe des bubulles.
* Comment générer un `.obj` à partir d'une image flottante ?
* Gérer les arêtes de longueur nulle (degenerated cylinder)
* Que faire des vertices qui ne sont pas utilisées par des faces ?
* Plonger un peu dans la [technique](./technique.md).
## rendu final

View File

@ -32,10 +32,6 @@ printf(" -> %d\n", bar);
return 0;
}
/*
* GO !
*/
int main(int argc, char *argv[])
{
int foo, bar;

View File

@ -79,16 +79,13 @@ return 0;
/* EXPERIMENTAL GRUIK-CODE !!! */
int printf_the_edges(EdgesAndVertices *eav)
{
int idx, a, b, vmax;
int idx, a, b;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
#endif
if (verbosity) fprintf(stderr, " fprinting %d edges\n", eav->Elist->fidx);
vmax = eav->Blist->fidx;
fprintf(stderr, " %s: eav->Blist->fidx = %d\n", __func__, vmax);
if (verbosity) fprintf(stderr, "fprinting %d edges\n", eav->Elist->fidx);
/*
* OK we have (maybe) all the data in da place
@ -98,12 +95,7 @@ for (idx=0; idx<eav->Elist->fidx; idx++) {
a = eav->Elist->edges[idx].A;
b = eav->Elist->edges[idx].B;
/* this is a Molly-Guard */
if ( (a<0) || (b<0) || (a>vmax) || (b>vmax) ) {
fprintf(stderr, "ERROR: vmax=%d a=%d b=%d\n", vmax, a, b);
continue;
}
// fprintf(stderr, "%7d %7d\n", a, b);
printf("%.9f %.9f %.9f %.9f %.9f %.9f\n",
eav->Blist->bbs[a].p.x,
@ -150,38 +142,25 @@ else if (! strcasecmp("bbox", outmode)) { mode = 2; }
switch (mode) {
case 0:
foo = printf_the_edges(&eav); break;
printf_the_edges(&eav); break;
case 1:
foo = printf_the_vertices(&eav); break;
printf_the_vertices(&eav); break;
case 2:
foo = printf_the_boudingbox(&eav); break;
printf_the_boudingbox(&eav); break;
default:
fprintf(stderr, "%s: no way for '%s'\n", __func__, outmode);
fprintf(stderr, "no way to do '%s'\n", outmode);
exit(1);
break;
}
if (foo) {
fprintf(stderr, "%s: action '%s' -> %d\n", __func__, outmode, foo);
exit(1);
}
/* deallocate used memory for keep pinpin happy */
free_bubulles(eav.Blist, 1);
free_edgelist(eav.Elist, 1);
return 0;
}
/* --------------------------------------------------------------------- */
void help(void)
{
puts("usage:\n $ export_evblob [opts] fichier.evblob");
puts("\t-h\tsome short help...");
puts("\t-t\tone of [edges vertices bbox]");
puts("\t-v\tbe more verbose");
fprintf(stderr, "YOLO!\n");
/* XXX */
exit(0);
}
/* --------------------------------------------------------------------- */

View File

@ -104,14 +104,15 @@ return foo;
/* new Mon 27 Mar 2023 12:08:18 AM CEST
*
* mmmm... complex thing to do...
* and what is this "phy" parameter ?
*/
static int parse_face(char *cptr, int maxvert)
static int parse_face(char *cptr)
{
int ix, foo, a, b;
int pts[3], valid;
int pts[3];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, cptr, maxvert);
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, cptr);
#endif
#if (0)
@ -135,44 +136,36 @@ for (ix=0; ix<3; ix++) {
}
}
fprintf(stderr, " %s: pts %5d %5d %5d\n", __func__,
pts[0], pts[1], pts[2]);
valid = 1;
/**** check the freshly read datas ****/
/** check the freshly read datas **/
if ( pts[0]==pts[1] || pts[0]==pts[2] || pts[2]==pts[1] ) {
fprintf(stderr, "%s: degenerated face ( %d %d %d )\n", __func__,
pts[0], pts[1], pts[2]);
dropped++;
valid = 0;
}
if ( (pts[0]>maxvert) || (pts[1]>maxvert) || (pts[2]>maxvert) ) {
fprintf(stderr, "%s: out of bound ( %d %d %d )\n", __func__,
pts[0], pts[1], pts[2]);
valid = 0;
}
/*
* may be we can check the "degenerated cylinder" here ?
*/
if (valid) {
for (ix=0; ix<3; ix++) {
a = ix % 3;
b = (ix+1) % 3;
for (ix=0; ix<3; ix++) {
a = ix % 3;
b = (ix+1) % 3;
#if PSYCHOTIK
foo = push_a_missing_edge(edges, pts[a], pts[b]);
foo = push_a_missing_edge(edges, pts[a], pts[b]);
#else
foo = push_an_edge(edges, pts[a], pts[b]);
foo = push_an_edge(edges, pts[a], pts[b]);
#endif
if (foo) {
fprintf(stderr, "%s: disaster #%d line %d\n",
__func__, foo, linenumber);
return -2;
}
if (foo) {
fprintf(stderr, "%s: disaster #%d line %d\n",
__func__, foo, linenumber);
return -2;
}
}
if (dropped) fprintf(stderr, "%s: %d dropped\n", __func__, dropped);
if (dropped) {
fprintf(stderr, "%s: %d dropped...\n", __func__, dropped);
// exit(1);
}
#if DEBUG_LEVEL > 1
fprintf(stderr, "<<< %s\n", __func__);
@ -189,17 +182,15 @@ int try_to_read_an_OBJ_file(char *infname, char *ofname, int outstyle)
FILE *fpin;
char line[LINE_SZ+1], *cptr, *token;
float x, y, z;
int foo, bar, tokenid;
int foo, tokenid;
Bubulle bubulle;
char *outfname, *baseptr;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n\n", __func__,
infname, ofname, outstyle);
#endif
#if PSYCHOTIK
fprintf(stderr, " *** PSYCHOTIK MODE ENGAGED ***\n");
#endif
/* get memory for generated output filename(s) */
if (NULL==(outfname=malloc(strlen(infname)+33)) ) {
@ -227,7 +218,7 @@ if (NULL==edges) {
}
if (verbosity > 1) print_edgelist_desc(edges, 0);
fprintf(stderr, " +-----------------------------------------\n");
fprintf(stderr, "\n ***************************************\n");
while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
@ -267,27 +258,21 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
case T_vertice:
x = y = z = 0.0;
foo = parse_vertice(cptr, &x, &y, &z);
if (3 != foo) {
fprintf(stderr, "err %d parse vertice %s\n",
foo, cptr);
if (3!=foo) {
abort();
}
bubulle.p.x = x;
bubulle.p.y = y;
bubulle.p.z = z;
if (verbosity > 2) niceprint_bubulle(&bubulle, 0);
if (verbosity > 1) niceprint_bubulle(&bubulle, 0);
foo = push_bubulle(bublist, &bubulle);
if (foo) {
fprintf(stderr, "err %d push bubulle\n", foo);
abort();
}
fprintf(stderr, "pushed %f %f %f (%d)\n", x, y, z,
bublist->fidx);
break;
case T_face:
/* experimental code here */
bar = bublist->fidx - 1;
foo = parse_face(cptr, bar);
foo = parse_face(cptr);
if (foo) {
fprintf(stderr, "line %d '%s' parseface -> %d\n",
linenumber, cptr, foo);
@ -313,18 +298,10 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
break;
case T_line:
cptr = strtok(NULL, " ");
fprintf(stderr, "\tLine: %s\n", cptr);
break;
case T_smoothing:
cptr = strtok(NULL, " ");
if (verbosity)
fprintf(stderr, "\tSmoothing: %s\n", cptr);
break;
case T_vt:
cptr = strtok(NULL, " ");
if (verbosity)
fprintf(stderr, "\tvt ??? : %s\n", cptr);
break;
default:
@ -335,11 +312,11 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
fclose(fpin);
fprintf(stderr, " +-----------------------------------------\n");
fprintf(stderr, " ***************************************\n");
if(verbosity) {
fprintf(stderr, "%s: %d vertices and %d edges loaded.\n", __func__,
bublist->fidx, edges->fidx);
fprintf(stderr, "%s(): %9d vertices loaded\n", __func__, bublist->fidx);
fprintf(stderr, "%s(): %9d edges loaded\n", __func__, edges->fidx);
}
if (verbosity > 1) {
@ -378,7 +355,6 @@ else { /* one 'evblob' file */
}
// Cleanup
free(outfname);
free_bubulles(bublist, 0);
free_edgelist(edges, 0);

View File

@ -1,11 +1,7 @@
o minimal
v 0 0 0
v 1 0 0
v 0 2 0
v 0 0 3
f 0 1 2
f 1 2 3
f 3 1 0
f 0 2 3
v 0 1 0
v 0 0 1
f 1/2 2/3 3/1
f 0/1 0/1 0/2

View File

@ -1,11 +0,0 @@
o minimal
v 0 0 0
v 1 0 0
v 0 2 0
v 0 0 3
f 0 1 2
f 2 3 4
f 4 2 1
f 0 3 4

View File

@ -26,13 +26,9 @@ int idx;
unsigned char *cptr = (unsigned char *)ptr;
for (idx=0; idx<count; idx++) {
fprintf(stderr, "%02x ", cptr[idx]);
fprintf(stderr, "%02x", cptr[idx]);
}
fprintf(stderr, " ?\n");
for (idx=0; idx<count; idx++) {
fprintf(stderr, " %c ", isprint(cptr[idx]) ? cptr[idx] : 'X' );
}
fprintf(stderr, " ?\n");
fprintf(stderr, " ?\n");
}
/* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */
@ -116,7 +112,7 @@ if (1 != foo) {
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
return -1;
}
if (verbosity) fprintf(stderr, " %d vertices to be loaded\n", nbre);
fprintf(stderr, " %d vertices to be loaded\n", nbre);
/* allocate memory */
blst = alloc_bubulles(filename, nbre, 0);
@ -155,7 +151,7 @@ if (1 != foo) {
fprintf(stderr, " %s of '%s': short read %d\n", __func__, filename, foo);
return -1;
}
if (verbosity) fprintf(stderr, " %d edges to be loaded\n", nbre);
fprintf(stderr, " %d edges to be loaded\n", nbre);
/* allocate memory for edges list */
elst = alloc_edgelist("krkrkr", nbre, 0);

View File

@ -17,12 +17,7 @@ int verbosity = 0;
/* --------------------------------------------------------------------- */
void help(void)
{
printf("### READ_OBJ 0X%X TALKING\n", getpid());
puts("usage:");
puts("\t-h\t\tthis help (use -v -h for more");
puts("\t-o fname\tfix the output filename");
puts("\t-v\t\tincrease verbosity");
printf("nothing to say...\n");
exit(0);
}
/* --------------------------------------------------------------------- */
@ -32,7 +27,7 @@ int main(int argc, char *argv[])
int foo, opt;
char *ofname = NULL;
fprintf(stderr, "### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
if (1 == argc) {
bubulles_version(1);
@ -54,13 +49,12 @@ while ((opt = getopt(argc, argv, "ho:v")) != -1) {
}
}
if (optind < argc) {
if (verbosity) fprintf(stderr, " arg[%d] = %s\n",
optind, argv[optind]);
fprintf(stderr, "arg = %s\n", argv[optind]);
foo = try_to_read_an_OBJ_file(argv[optind], ofname, 0);
if (foo) {
fprintf(stderr, "Error number %d on '%s'\n",
foo, argv[optind]);
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
exit(1);
}
}

View File

@ -1,23 +0,0 @@
#!/bin/bash
set -e
make read_obj
make export_evblob
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
figlet 'a real WTF' | sed 's/^/XXX /'
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
./read_obj -v minimal.obj
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
./export_evblob -t edges minimal.evblob |
awk '{ printf "%4d | %.0f %.0f %.0f %.0f %.0f %.0f\n", \
NR, $1, $2, $3, $4, $5, $6 }'
echo
./export_evblob -t vertices minimal.evblob

View File

@ -1,37 +0,0 @@
# Technique
Les détails **gores**...
## Le parser
Je pense qu'il y a un bug sournois caché dedans
## L'exporteur
Conversion d'un `.evblob` en données tabulées exploitables par
des scripts `awk`.
## Tests
Pour le moment rien, à part ce fichier .OBJ vérolé :
```
o minimal
v 0 0 0
v 1 0 0
v 0 2 0
v 0 0 3
f 0 1 2
f 2 3 4
f 4 2 1
f 0 3 4
```
Ça va, vous avez capté le souci ?
## Conclusion
Rien ,'est simple, tout se complique...