add bouding-box export

This commit is contained in:
tTh 2023-04-29 23:44:56 +02:00
parent 992c98cfa8
commit 7cefa36d62

View File

@ -17,6 +17,43 @@
int verbosity;
/* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */
int printf_the_boudingbox(EdgesAndVertices *eav)
{
int idx;
double x, y, z;
double minX, minY, minZ;
double maxX, maxY, maxZ;
minX = minY = minZ = 1e35;
maxX = maxY = maxZ = -1e35;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
#endif
fprintf(stderr, "====== %s is not fully implemented ======\n", __func__);
for (idx=0; idx<eav->Blist->fidx; idx++) {
x = eav->Blist->bbs[idx].p.x;
y = eav->Blist->bbs[idx].p.y;
z = eav->Blist->bbs[idx].p.z;
if (x < minX) minX = x;
else if (x > maxX) maxX = x;
if (y < minY) minY = y;
else if (y > maxY) maxY = y;
if (z < minZ) minZ = z;
else if (z > maxZ) maxZ = z;
}
printf( "%.9f %.9f %.9f %.9f %.9f %.9f\n",
minX, minY, minZ, maxX, maxY, maxZ);
return -1;
}
/* --------------------------------------------------------------------- */
/* EXPERIMENTAL GRUIK-CODE !!! */
int printf_the_vertices(EdgesAndVertices *eav)
@ -101,12 +138,16 @@ if (verbosity > 1) {
mode = 666;
if (! strcasecmp("edges", outmode)) { mode = 0; }
else if (! strcasecmp("vertices", outmode)) { mode = 1; }
else if (! strcasecmp("bbox", outmode)) { mode = 2; }
switch (mode) {
case 0:
printf_the_edges(&eav); break;
case 1:
printf_the_vertices(&eav); break;
case 2:
printf_the_boudingbox(&eav); break;
default:
fprintf(stderr, "no way to do '%s'\n", outmode);
exit(1);
@ -141,10 +182,11 @@ while ((opt = getopt(argc, argv, "ht:v")) != -1) {
case 'v':
verbosity++; break;
case 't':
fprintf(stderr, "type -> '%s'\n", optarg);
// fprintf(stderr, "type -> '%s'\n", optarg);
outmode = optarg;
break;
default:
fprintf(stderr, "'%c' EBADOPT\n", opt);
exit(1);
break;
}