add sanity checks
This commit is contained in:
parent
f5de09b23a
commit
755eb65da3
@ -79,7 +79,7 @@ return 0;
|
||||
/* EXPERIMENTAL GRUIK-CODE !!! */
|
||||
int printf_the_edges(EdgesAndVertices *eav)
|
||||
{
|
||||
int idx, a, b;
|
||||
int idx, a, b, vmax;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
|
||||
@ -87,6 +87,9 @@ fprintf(stderr, ">>> %s ( %p )\n", __func__, eav);
|
||||
|
||||
if (verbosity) fprintf(stderr, " fprinting %d edges\n", eav->Elist->fidx);
|
||||
|
||||
vmax = eav->Blist->fidx;
|
||||
fprintf(stderr, " in %s, vmax was %d\n", __func__, vmax);
|
||||
|
||||
/*
|
||||
* OK we have (maybe) all the data in da place
|
||||
* and we can spit all the edges to stdout
|
||||
@ -95,7 +98,12 @@ 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);
|
||||
|
||||
/* this is a Molly-Guard */
|
||||
if ( (a<0) || (b<0) || (a>vmax) || (b>vmax) ) {
|
||||
fprintf(stderr, "ERROR: vmax=%d a=%d b=%d\n", vmax, a, b);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%.9f %.9f %.9f %.9f %.9f %.9f\n",
|
||||
eav->Blist->bbs[a].p.x,
|
||||
@ -142,25 +150,34 @@ else if (! strcasecmp("bbox", outmode)) { mode = 2; }
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
printf_the_edges(&eav); break;
|
||||
foo = printf_the_edges(&eav); break;
|
||||
case 1:
|
||||
printf_the_vertices(&eav); break;
|
||||
foo = printf_the_vertices(&eav); break;
|
||||
case 2:
|
||||
printf_the_boudingbox(&eav); break;
|
||||
foo = printf_the_boudingbox(&eav); break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "no way to do '%s'\n", outmode);
|
||||
fprintf(stderr, "%s: no way for '%s'\n", __func__, outmode);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: action '%s' -> %d\n", __func__, outmode, foo);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(void)
|
||||
{
|
||||
fprintf(stderr, "YOLO!\n");
|
||||
/* XXX */
|
||||
|
||||
puts("usage:\n $ export_evblob [opts] fichier.evblob");
|
||||
puts("\t-h\tsome short help...");
|
||||
puts("\t-t\tone of [edges vertices bbox]");
|
||||
puts("\t-v\tbe more verbose");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user