Compare commits

...

3 Commits

Author SHA1 Message Date
tTh d65d635577 expliquer... 2023-04-27 05:56:40 +02:00
tTh b04bf9e67a refactoring of export_evblob in progress 2023-04-26 08:33:05 +02:00
tTh 7dc4fae849 repair debug messages 2023-04-24 14:12:15 +02:00
3 changed files with 98 additions and 38 deletions

View File

@ -1,4 +1,3 @@
# Importer des fichiers .OBJ # Importer des fichiers .OBJ
* https://en.wikipedia.org/wiki/Wavefront_.obj_file * https://en.wikipedia.org/wiki/Wavefront_.obj_file
@ -20,9 +19,9 @@ en déduire les arètes (aka: edges).
Et à partir de cette analyse, nous allons générer un fichier Et à partir de cette analyse, nous allons générer un fichier
binaire contenant les points xyx, et les arêtes pointA-pointB. binaire contenant les points xyx, et les arêtes pointA-pointB.
Le format de ce fichier doit être considéré //opaque//. Le format de ce fichier doit être considéré *opaque*.
il sera généré dans le $PWD avec le nom du fichier .OBJ mais il sera généré dans le $PWD en utilisant le basename du fichier .OBJ mais
avec l'extension .evblob. avec l'extension `.evblob`.
Ce n'est qu'une première étape, d'autres formats de sortie Ce n'est qu'une première étape, d'autres formats de sortie
pourront être implémentés. pourront être implémentés.
@ -37,16 +36,28 @@ Deuxième étape : À partir du fichier .evblob généré à l'étape
précédente, nous allons créer (entre autres options ?) précédente, nous allons créer (entre autres options ?)
un fichier utilisable par Povray. La première option a été un fichier utilisable par Povray. La première option a été
la génération des arêtes, nous aurons donc sur `stdout` la génération des arêtes, nous aurons donc sur `stdout`
six nombres réels: xyz(pointA) et xyz(pointB). six nombres réels: xyz(pointA) et xyz(pointB) :
Et là, c'est trop facile, Unix le fait depuis quarante ans. ```
Un petit [script Awk](./edges2cylinders.awk) fera l'affaire. 25.2275466 19.5029792 -25.1227169 35.6406135 19.5029792 0.0166420
35.6406135 19.5029792 0.0166420 0.0881849 19.5029792 -35.5357818
0.0881849 19.5029792 -35.5357818 25.2275466 19.5029792 -25.1227169
```
Et là, c'est trop facile pour la suite, Unix sait le faire depuis
quarante ans.
Un petit [script Awk](./edges2cylinders.awk) fera l'affaire,
en toute simplicité.
Bien entendu, la même chose pourrait être faire pour les vertices,
ce qui nous remet dans la droite ligne orthodoxe des bubulles.
## TODO LIST ## TODO LIST
* Songer à un système d'auto-scaler et de recentrage * Songer à un système d'auto-scaler et de recentrage
* Comment générer un `.obj` à partir d'une image flottante ? * Comment générer un `.obj` à partir d'une image flottante ?
* Gérer les arêtes de longueur nulle (degenerated cylinder) * Gérer les arêtes de longueur nulle (degenerated cylinder)
* Que faire des vertices qui ne sont pas utilisées par des faces ?
## rendu final ## rendu final

View File

@ -17,22 +17,71 @@
int verbosity; int verbosity;
/* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */
int printf_the_vertices(EdgesAndVertices *eav)
{
int idx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
#endif
if (verbosity) fprintf(stderr, "fprinting %d vertices\n", eav->Blist->fidx);
for (idx=0; idx<eav->Blist->fidx; idx++) {
printf("%.9f %.9f %.9f\n",
eav->Blist->bbs[idx].p.x,
eav->Blist->bbs[idx].p.y,
eav->Blist->bbs[idx].p.z );
}
return 0;
}
/* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */
int printf_the_edges(EdgesAndVertices *eav)
{
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);
/*
* OK we have (maybe) all the data in da place
* and we can spit all the edges to stdout
*/
for (idx=0; idx<eav->Elist->fidx; idx++) {
a = eav->Elist->edges[idx].A;
b = eav->Elist->edges[idx].B;
// fprintf(stderr, "%7d %7d\n", a, b);
printf("%.9f %.9f %.9f %.9f %.9f %.9f\n",
eav->Blist->bbs[a].p.x,
eav->Blist->bbs[a].p.y,
eav->Blist->bbs[a].p.z,
eav->Blist->bbs[b].p.x,
eav->Blist->bbs[b].p.y,
eav->Blist->bbs[b].p.z );
}
return 0; /* allway success ? */
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */ /* EXPERIMENTAL GRUIK-CODE !!! */
int load_and_printf_evblob(char *filename, int mode) int load_and_printf_evblob(char *filename, int mode)
{ {
EdgesAndVertices eav; EdgesAndVertices eav;
int foo, idx, a, b; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode); fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode);
#endif #endif
if (mode) {
fprintf(stderr, "W: in %s 'mode' must be zero, and was %d\n",
__func__, mode);
}
memset(&eav, 0, sizeof(EdgesAndVertices)); memset(&eav, 0, sizeof(EdgesAndVertices));
foo = x_load_vertedges(filename, &eav); foo = x_load_vertedges(filename, &eav);
if (foo) { if (foo) {
@ -40,7 +89,7 @@ if (foo) {
return foo; return foo;
} }
if (verbosity) { if (verbosity > 1) {
fprintf(stderr, "vertices at %p\n", eav.Blist); fprintf(stderr, "vertices at %p\n", eav.Blist);
fprintf(stderr, "edges at %p\n", eav.Elist); fprintf(stderr, "edges at %p\n", eav.Elist);
fprintf(stderr, "status is %d\n", eav.status); fprintf(stderr, "status is %d\n", eav.status);
@ -49,24 +98,15 @@ if (verbosity) {
eav.Elist->fidx); eav.Elist->fidx);
} }
/* switch (mode) {
* OK we have (maybe) all the data in da place case 0:
* and we can spit all the edges to stdout printf_the_edges(&eav); break;
*/ case 1:
printf_the_vertices(&eav); break;
for (idx=0; idx<eav.Elist->fidx; idx++) { default:
fprintf(stderr, "no way to do %d\n", mode);
a = eav.Elist->edges[idx].A; exit(1);
b = eav.Elist->edges[idx].B; break;
// fprintf(stderr, "%7d %7d\n", a, b);
printf("%.9f %.9f %.9f %.9f %.9f %.9f\n",
eav.Blist->bbs[a].p.x,
eav.Blist->bbs[a].p.y,
eav.Blist->bbs[a].p.z,
eav.Blist->bbs[b].p.x,
eav.Blist->bbs[b].p.y,
eav.Blist->bbs[b].p.z );
} }
return 0; return 0;
@ -75,6 +115,7 @@ return 0;
void help(void) void help(void)
{ {
fprintf(stderr, "YOLO!\n"); fprintf(stderr, "YOLO!\n");
/* XXX */
exit(0); exit(0);
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -83,19 +124,27 @@ exit(0);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int opt, foo; int opt, foo;
int outmode = 0;
fprintf(stderr, "### EdgesAndVertices - %s %s\n", __DATE__, __TIME__); fprintf(stderr, "### Export EVblob (%s %s)\n", __DATE__, __TIME__);
verbosity = 0; verbosity = 0;
while ((opt = getopt(argc, argv, "hv")) != -1) { while ((opt = getopt(argc, argv, "ht:v")) != -1) {
switch(opt) { switch(opt) {
case 'h': case 'h':
help(); break; help(); break;
case 'v': case 'v':
verbosity++; break; verbosity++; break;
case 't':
// fprintf(stderr, "t -> %s\n", optarg);
switch(optarg[0]) {
case 'e': outmode=0; break;
case 'v': outmode=1; break;
}
break;
default: default:
fprintf(stderr, "gni(%c)?\n", opt); exit(1);
break; break;
} }
} }
@ -106,7 +155,7 @@ fprintf(stderr, "optind=%d argc=%d\n", optind, argc);
if (optind < argc) { if (optind < argc) {
// fprintf(stderr, "ARG = %s\n", argv[optind]); // fprintf(stderr, "ARG = %s\n", argv[optind]);
foo = load_and_printf_evblob(argv[optind], 0); foo = load_and_printf_evblob(argv[optind], outmode);
if (foo) { 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); exit(1);

View File

@ -111,7 +111,7 @@ int ix, foo, a, b;
int pts[3]; int pts[3];
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, cptr, phy); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, cptr);
#endif #endif
#if (0) #if (0)
@ -183,7 +183,7 @@ Bubulle bubulle;
char *outfname, *baseptr; char *outfname, *baseptr;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' ... %d )\n\n", __func__, infname, notused); fprintf(stderr, ">>> %s ( '%s' %d )\n\n", __func__, infname, outstyle);
#endif #endif
/* get memory for generated output filename(s) */ /* get memory for generated output filename(s) */