refactoring of export_evblob in progress

This commit is contained in:
tTh 2023-04-26 08:33:05 +02:00
parent 7dc4fae849
commit b04bf9e67a

View File

@ -17,22 +17,71 @@
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 !!! */
int load_and_printf_evblob(char *filename, int mode)
{
EdgesAndVertices eav;
int foo, idx, a, b;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, mode);
#endif
if (mode) {
fprintf(stderr, "W: in %s 'mode' must be zero, and was %d\n",
__func__, mode);
}
memset(&eav, 0, sizeof(EdgesAndVertices));
foo = x_load_vertedges(filename, &eav);
if (foo) {
@ -40,7 +89,7 @@ if (foo) {
return foo;
}
if (verbosity) {
if (verbosity > 1) {
fprintf(stderr, "vertices at %p\n", eav.Blist);
fprintf(stderr, "edges at %p\n", eav.Elist);
fprintf(stderr, "status is %d\n", eav.status);
@ -49,24 +98,15 @@ if (verbosity) {
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 );
switch (mode) {
case 0:
printf_the_edges(&eav); break;
case 1:
printf_the_vertices(&eav); break;
default:
fprintf(stderr, "no way to do %d\n", mode);
exit(1);
break;
}
return 0;
@ -75,6 +115,7 @@ return 0;
void help(void)
{
fprintf(stderr, "YOLO!\n");
/* XXX */
exit(0);
}
/* --------------------------------------------------------------------- */
@ -83,19 +124,27 @@ exit(0);
int main(int argc, char *argv[])
{
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;
while ((opt = getopt(argc, argv, "hv")) != -1) {
while ((opt = getopt(argc, argv, "ht:v")) != -1) {
switch(opt) {
case 'h':
help(); break;
case 'v':
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:
fprintf(stderr, "gni(%c)?\n", opt);
exit(1);
break;
}
}
@ -106,7 +155,7 @@ fprintf(stderr, "optind=%d argc=%d\n", optind, argc);
if (optind < argc) {
// 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) {
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
exit(1);