2023-04-15 09:56:48 +11:00
|
|
|
|
/*
|
|
|
|
|
* EdgesAndVertices
|
|
|
|
|
|
|
|
|
|
https://git.tetalab.org/tTh/libbubulle/src/branch/master/tools/
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "../bubulles.h"
|
|
|
|
|
#include "../edges.h"
|
|
|
|
|
|
|
|
|
|
#include "objtrucs.h"
|
|
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
/* EXPERIMENTAL GRUIK-CODE !!! */
|
2023-04-21 07:33:46 +11:00
|
|
|
|
int load_and_printf_evblob(char *filename, int mode)
|
2023-04-15 09:56:48 +11:00
|
|
|
|
{
|
|
|
|
|
EdgesAndVertices eav;
|
|
|
|
|
int foo, idx, a, b;
|
|
|
|
|
|
2023-04-21 07:33:46 +11:00
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
|
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode);
|
|
|
|
|
#endif
|
2023-04-15 09:56:48 +11:00
|
|
|
|
|
2023-04-21 07:33:46 +11:00
|
|
|
|
if (mode) {
|
|
|
|
|
fprintf(stderr, "W: in %s 'mode' must be zero, and was %d\n",
|
|
|
|
|
__func__, mode);
|
|
|
|
|
}
|
2023-04-15 09:56:48 +11:00
|
|
|
|
|
|
|
|
|
memset(&eav, 0, sizeof(EdgesAndVertices));
|
2023-04-21 07:33:46 +11:00
|
|
|
|
foo = x_load_vertedges(filename, &eav);
|
|
|
|
|
if (foo) {
|
|
|
|
|
fprintf(stderr, " load vertice & edges blob -> %d\n", foo);
|
|
|
|
|
return foo;
|
|
|
|
|
}
|
2023-04-15 09:56:48 +11:00
|
|
|
|
|
|
|
|
|
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);
|
2023-04-21 07:33:46 +11:00
|
|
|
|
fprintf(stderr, "got %d vertices and %d edges\n",
|
|
|
|
|
eav.Blist->fidx,
|
|
|
|
|
eav.Elist->fidx);
|
2023-04-15 09:56:48 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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);
|
|
|
|
|
|
2023-04-21 07:33:46 +11:00
|
|
|
|
printf("%.9f %.9f %.9f %.9f %.9f %.9f\n",
|
2023-04-15 09:56:48 +11:00
|
|
|
|
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 );
|
2023-04-21 07:33:46 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
void help(void)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "YOLO!\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
/* EXPERIMENTAL GRUIK-CODE !!! */
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
int opt, foo;
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "### EdgesAndVertices - %s %s\n", __DATE__, __TIME__);
|
2023-04-15 09:56:48 +11:00
|
|
|
|
|
2023-04-21 07:33:46 +11:00
|
|
|
|
verbosity = 0;
|
|
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|
|
|
|
switch(opt) {
|
|
|
|
|
case 'h':
|
|
|
|
|
help(); break;
|
|
|
|
|
case 'v':
|
|
|
|
|
verbosity++; break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "gni(%c)?\n", opt);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-04-15 09:56:48 +11:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-21 07:33:46 +11:00
|
|
|
|
#if DEBUG_LEVEL
|
|
|
|
|
fprintf(stderr, "optind=%d argc=%d\n", optind, argc);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (optind < argc) {
|
|
|
|
|
// fprintf(stderr, "ARG = %s\n", argv[optind]);
|
|
|
|
|
foo = load_and_printf_evblob(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);
|
|
|
|
|
}
|
2023-04-15 09:56:48 +11:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|