Compare commits

...

5 Commits

Author SHA1 Message Date
tTh 895e61cbb6 frobnicate parameters handling 2023-04-28 00:02:04 +02:00
tTh 85f1867424 little tweak 2023-04-28 00:00:50 +02:00
tTh 9c336eed8c adding command line options 2023-04-27 23:59:59 +02:00
tTh a823bdae0c cosmetic 2023-04-27 20:29:39 +02:00
tTh 1f52a4c002 cosmetic 2023-04-27 19:34:58 +02:00
5 changed files with 60 additions and 27 deletions

View File

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

View File

@ -73,13 +73,13 @@ 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, char *outmode)
{ {
EdgesAndVertices eav; EdgesAndVertices eav;
int foo; int foo, mode;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode); fprintf(stderr, ">>> %s ( '%s' %s )\n", __func__, filename, outmode);
#endif #endif
memset(&eav, 0, sizeof(EdgesAndVertices)); memset(&eav, 0, sizeof(EdgesAndVertices));
@ -98,13 +98,17 @@ if (verbosity > 1) {
eav.Elist->fidx); eav.Elist->fidx);
} }
mode = 666;
if (! strcasecmp("edges", outmode)) { mode = 0; }
else if (! strcasecmp("vertices", outmode)) { mode = 1; }
switch (mode) { switch (mode) {
case 0: case 0:
printf_the_edges(&eav); break; printf_the_edges(&eav); break;
case 1: case 1:
printf_the_vertices(&eav); break; printf_the_vertices(&eav); break;
default: default:
fprintf(stderr, "no way to do %d\n", mode); fprintf(stderr, "no way to do '%s'\n", outmode);
exit(1); exit(1);
break; break;
} }
@ -124,7 +128,7 @@ exit(0);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int opt, foo; int opt, foo;
int outmode = 0; char *outmode = "vertices";
fprintf(stderr, "### Export EVblob (%s %s)\n", __DATE__, __TIME__); fprintf(stderr, "### Export EVblob (%s %s)\n", __DATE__, __TIME__);
@ -137,11 +141,8 @@ while ((opt = getopt(argc, argv, "ht:v")) != -1) {
case 'v': case 'v':
verbosity++; break; verbosity++; break;
case 't': case 't':
// fprintf(stderr, "t -> %s\n", optarg); fprintf(stderr, "type -> '%s'\n", optarg);
switch(optarg[0]) { outmode = optarg;
case 'e': outmode=0; break;
case 'v': outmode=1; break;
}
break; break;
default: default:
exit(1); exit(1);

View File

@ -49,7 +49,7 @@ Tokens TokenList[] = {
{ "vn", T_vt }, // c'est quoi ce truc ? { "vn", T_vt }, // c'est quoi ce truc ?
{ "l", T_line }, { "l", T_line },
{ "o", T_object }, { "o", T_object },
{ "s", T_smoothing }, { "s", T_smoothing }, // mmmm....
{ "usemtl", T_usemtl }, { "usemtl", T_usemtl },
{ "mtllib", T_mtllib }, { "mtllib", T_mtllib },
/* and more to come... */ /* and more to come... */
@ -149,7 +149,8 @@ if ( pts[0]==pts[1] || pts[0]==pts[2] || pts[2]==pts[1] ) {
for (ix=0; ix<3; ix++) { for (ix=0; ix<3; ix++) {
a = ix % 3; a = ix % 3;
b = (ix+1) % 3; b = (ix+1) % 3;
foo = push_a_missing_edge(edges, pts[a], pts[b]); // foo = push_a_missing_edge(edges, pts[a], pts[b]);
foo = push_an_edge(edges, pts[a], pts[b]);
if (foo) { if (foo) {
fprintf(stderr, "%s: disaster #%d line %d\n", fprintf(stderr, "%s: disaster #%d line %d\n",
__func__, foo, linenumber); __func__, foo, linenumber);
@ -162,7 +163,7 @@ if (dropped) {
// exit(1); // exit(1);
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL > 1
fprintf(stderr, "<<< %s\n", __func__); fprintf(stderr, "<<< %s\n", __func__);
#endif #endif
@ -198,14 +199,14 @@ if (NULL==(fpin=fopen(infname, "r"))) {
} }
linenumber = 0; linenumber = 0;
bublist = alloc_bubulles(infname, 600000, 0); bublist = alloc_bubulles(infname, 800000, 0);
if (NULL==bublist) { if (NULL==bublist) {
fprintf(stderr, "in %s, no mem for bubls, aborting...\n", __func__); fprintf(stderr, "in %s, no mem for bubls, aborting...\n", __func__);
abort(); abort();
} }
if (verbosity > 1) print_bublist_desc(bublist, 0); if (verbosity > 1) print_bublist_desc(bublist, 0);
edges = alloc_edgelist("krkrkr", 2200000, 0); edges = alloc_edgelist("krkrkr", 3000000, 0);
if (NULL==edges) { if (NULL==edges) {
fprintf(stderr, "no mem for edges in %s, aborting...\n", __func__); fprintf(stderr, "no mem for edges in %s, aborting...\n", __func__);
abort(); abort();
@ -299,7 +300,7 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
break; break;
default: default:
fprintf(stderr, "token %s -> %d ?\n", token, tokenid); fprintf(stderr, "W: token %s -> %d ?\n", token, tokenid);
break; break;
} }
} }

View File

@ -1,7 +1,8 @@
/* /*
* EXPERIMENTAL CODE ! * EXPERIMENTAL CODE !
* *
* see also 'rdwredges.c' & 'export_evblob.c' * see 'rdwredges.c' for source code
* & 'export_evblob.c' for a usecase.
*/ */
#define EVBLOB_MAGIC (65872139) #define EVBLOB_MAGIC (65872139)

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <libgen.h> // for basename(3) #include <libgen.h> // for basename(3)
#include <unistd.h>
#include "../bubulles.h" #include "../bubulles.h"
#include "../edges.h" #include "../edges.h"
@ -13,22 +14,51 @@
int verbosity = 0; int verbosity = 0;
/* --------------------------------------------------------------------- */
void help(void)
{
printf("nothing to say...\n");
exit(0);
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo; int foo, opt;
char *fname; /* see manpage basename(3) */ // char *fname; /* see manpage basename(3) */
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__); fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
if (2 != argc) { if (1 == argc) {
bubulles_version(1); bubulles_version(1);
exit(0); exit(0);
} }
verbosity = 0; while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'h':
help(); break;
case 'v':
verbosity++; break;
default:
exit(1);
break;
}
}
foo = try_to_read_an_OBJ_file(argv[1], 0);
fprintf(stderr, "try to read '%s' -> %d\n", argv [1], foo); if (optind < argc) {
// fprintf(stderr, "ARG = %s\n", argv[optind]);
foo = try_to_read_an_OBJ_file(argv[optind], 0);
if (foo) {
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
exit(1);
}
}
else {
fprintf(stderr, "%s need a input filename\n", argv[0]);
exit(1);
}
return 0; return 0;
} }