From 02bbdc724941aa97f40777df6cae848e9126440b Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 15 Apr 2023 00:56:48 +0200 Subject: [PATCH] commit du soir, espoir --- tools/Makefile | 10 ++++++- tools/export_evblob.c | 70 +++++++++++++++++++++++++++++++++++++++++++ tools/importobj.c | 4 +-- tools/rdwredges.c | 4 ++- 4 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 tools/export_evblob.c diff --git a/tools/Makefile b/tools/Makefile index a2d8c5a..d28e489 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -3,10 +3,18 @@ BBFUNCS = ../libbubulles.a OPT = -Wall -Wextra -g -DDEBUG_LEVEL=0 -DMUST_ABORT=0 -read_obj: read_obj.c Makefile importobj.o rdwredges.o \ +# --------- + +read_obj: read_obj.c Makefile importobj.o rdwredges.o \ $(BBFUNCS) gcc $(OPT) $< importobj.o rdwredges.o $(BBFUNCS) -o $@ +export_evblob: export_evblob.c Makefile importobj.o rdwredges.o \ + $(BBFUNCS) + gcc $(OPT) $< importobj.o rdwredges.o $(BBFUNCS) -o $@ + +# --------- + importobj.o: importobj.c ../bubulles.h ../edges.h Makefile $(CC) $(OPT) -c $< diff --git a/tools/export_evblob.c b/tools/export_evblob.c new file mode 100644 index 0000000..b41bca2 --- /dev/null +++ b/tools/export_evblob.c @@ -0,0 +1,70 @@ +/* + * EdgesAndVertices + + https://git.tetalab.org/tTh/libbubulle/src/branch/master/tools/ + + */ + +#include +#include +#include +#include + +#include "../bubulles.h" +#include "../edges.h" + +#include "objtrucs.h" + +int verbosity; + +/* --------------------------------------------------------------------- */ +/* EXPERIMENTAL GRUIK-CODE !!! */ + +int main(int argc, char *argv[]) +{ +EdgesAndVertices eav; +int foo, idx, a, b; + +fprintf(stderr, "### EdgesAndVertices - %s %s\n", __DATE__, __TIME__); + +verbosity = 0; + +memset(&eav, 0, sizeof(EdgesAndVertices)); +foo = x_load_vertedges("foo.evblob", &eav); +fprintf(stderr, " load vertice & edges blob -> %d\n", foo); + +if (verbosity) { + fprintf(stderr, "vertices at %p\n", eav.Blist); + fprintf(stderr, "edges at %p\n", eav.Elist); + fprintf(stderr, "status is %d\n", eav.status); + } + +/* + * OK we have (maybe) all the data in da place + * and we can spit all the edges to stdout + */ +fprintf(stderr, "got %d vertices and %d edges\n", + eav.Blist->fidx, + eav.Elist->fidx); + +for (idx=0; idxfidx; idx++) { + + a = eav.Elist->edges[idx].A; + b = eav.Elist->edges[idx].B; + // fprintf(stderr, "%7d %7d\n", a, b); + + printf("%.9f %f %f %f %f %f\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; +} +/* --------------------------------------------------------------------- */ + diff --git a/tools/importobj.c b/tools/importobj.c index cd37e4d..c629f7f 100644 --- a/tools/importobj.c +++ b/tools/importobj.c @@ -158,7 +158,7 @@ for (ix=0; ix<3; ix++) { if (dropped) { fprintf(stderr, "%s: %d dropped...\n", __func__, dropped); - exit(1); + // exit(1); } #if DEBUG_LEVEL @@ -309,7 +309,7 @@ bubulles_to_data(file_vert, NULL, bublist, 0); edges_to_data(file_edges, edges, 0); -foo = x_write_vertedges("foo.blob", bublist, edges); +foo = x_write_vertedges("foo.evblob", bublist, edges); // Cleanup free_bubulles(bublist, 0); diff --git a/tools/rdwredges.c b/tools/rdwredges.c index 0a0f7cd..e827871 100644 --- a/tools/rdwredges.c +++ b/tools/rdwredges.c @@ -39,8 +39,10 @@ int idx, edg[2]; double coo[3]; int nbre; +#if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__, filename, bblist, edges); +#endif if (NULL==(fp=fopen(filename, "w"))) { perror(filename); @@ -52,7 +54,7 @@ fwrite("VERTICES", 8, 1, fp); nbre = bblist->fidx; fwrite(&nbre, sizeof(int), 1, fp); for (idx=0; idxfidx; idx++) { - fprintf(stderr, "vertice %d\n", idx); + // fprintf(stderr, "vertice %d\n", idx); coo[0] = bblist->bbs[idx].p.x; coo[1] = bblist->bbs[idx].p.y; coo[2] = bblist->bbs[idx].p.z;