commit du bug rebelle
This commit is contained in:
@@ -104,15 +104,14 @@ return foo;
|
||||
/* new Mon 27 Mar 2023 12:08:18 AM CEST
|
||||
*
|
||||
* mmmm... complex thing to do...
|
||||
* and what is this "phy" parameter ?
|
||||
*/
|
||||
static int parse_face(char *cptr)
|
||||
static int parse_face(char *cptr, int maxvert)
|
||||
{
|
||||
int ix, foo, a, b;
|
||||
int pts[3];
|
||||
int pts[3], valid;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, cptr);
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, cptr, maxvert);
|
||||
#endif
|
||||
|
||||
#if (0)
|
||||
@@ -136,36 +135,44 @@ for (ix=0; ix<3; ix++) {
|
||||
}
|
||||
}
|
||||
|
||||
/** check the freshly read datas **/
|
||||
fprintf(stderr, " %s: pts %5d %5d %5d\n", __func__,
|
||||
pts[0], pts[1], pts[2]);
|
||||
|
||||
valid = 1;
|
||||
|
||||
/**** check the freshly read datas ****/
|
||||
if ( pts[0]==pts[1] || pts[0]==pts[2] || pts[2]==pts[1] ) {
|
||||
fprintf(stderr, "%s: degenerated face ( %d %d %d )\n", __func__,
|
||||
pts[0], pts[1], pts[2]);
|
||||
dropped++;
|
||||
valid = 0;
|
||||
}
|
||||
if ( (pts[0]>maxvert) || (pts[1]>maxvert) || (pts[2]>maxvert) ) {
|
||||
fprintf(stderr, "%s: out of bound ( %d %d %d )\n", __func__,
|
||||
pts[0], pts[1], pts[2]);
|
||||
valid = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* may be we can check the "degenerated cylinder" here ?
|
||||
*/
|
||||
|
||||
for (ix=0; ix<3; ix++) {
|
||||
a = ix % 3;
|
||||
b = (ix+1) % 3;
|
||||
if (valid) {
|
||||
for (ix=0; ix<3; ix++) {
|
||||
a = ix % 3;
|
||||
b = (ix+1) % 3;
|
||||
#if PSYCHOTIK
|
||||
foo = push_a_missing_edge(edges, pts[a], pts[b]);
|
||||
foo = push_a_missing_edge(edges, pts[a], pts[b]);
|
||||
#else
|
||||
foo = push_an_edge(edges, pts[a], pts[b]);
|
||||
foo = push_an_edge(edges, pts[a], pts[b]);
|
||||
#endif
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: disaster #%d line %d\n",
|
||||
__func__, foo, linenumber);
|
||||
return -2;
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: disaster #%d line %d\n",
|
||||
__func__, foo, linenumber);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dropped) {
|
||||
fprintf(stderr, "%s: %d dropped...\n", __func__, dropped);
|
||||
// exit(1);
|
||||
}
|
||||
if (dropped) fprintf(stderr, "%s: %d dropped\n", __func__, dropped);
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "<<< %s\n", __func__);
|
||||
@@ -182,15 +189,17 @@ int try_to_read_an_OBJ_file(char *infname, char *ofname, int outstyle)
|
||||
FILE *fpin;
|
||||
char line[LINE_SZ+1], *cptr, *token;
|
||||
float x, y, z;
|
||||
int foo, tokenid;
|
||||
int foo, bar, tokenid;
|
||||
Bubulle bubulle;
|
||||
|
||||
char *outfname, *baseptr;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n\n", __func__,
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n", __func__,
|
||||
infname, ofname, outstyle);
|
||||
#endif
|
||||
#if PSYCHOTIK
|
||||
fprintf(stderr, " *** PSYCHOTIK MODE ENGAGED ***\n");
|
||||
#endif
|
||||
|
||||
/* get memory for generated output filename(s) */
|
||||
if (NULL==(outfname=malloc(strlen(infname)+33)) ) {
|
||||
@@ -218,7 +227,7 @@ if (NULL==edges) {
|
||||
}
|
||||
if (verbosity > 1) print_edgelist_desc(edges, 0);
|
||||
|
||||
fprintf(stderr, "\n ***************************************\n");
|
||||
fprintf(stderr, " +-----------------------------------------\n");
|
||||
|
||||
while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
|
||||
@@ -258,21 +267,27 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
case T_vertice:
|
||||
x = y = z = 0.0;
|
||||
foo = parse_vertice(cptr, &x, &y, &z);
|
||||
if (3!=foo) {
|
||||
if (3 != foo) {
|
||||
fprintf(stderr, "err %d parse vertice %s\n",
|
||||
foo, cptr);
|
||||
abort();
|
||||
}
|
||||
bubulle.p.x = x;
|
||||
bubulle.p.y = y;
|
||||
bubulle.p.z = z;
|
||||
if (verbosity > 1) niceprint_bubulle(&bubulle, 0);
|
||||
if (verbosity > 2) niceprint_bubulle(&bubulle, 0);
|
||||
foo = push_bubulle(bublist, &bubulle);
|
||||
if (foo) {
|
||||
fprintf(stderr, "err %d push bubulle\n", foo);
|
||||
abort();
|
||||
}
|
||||
fprintf(stderr, "pushed %f %f %f (%d)\n", x, y, z,
|
||||
bublist->fidx);
|
||||
break;
|
||||
case T_face:
|
||||
/* experimental code here */
|
||||
foo = parse_face(cptr);
|
||||
bar = bublist->fidx - 1;
|
||||
foo = parse_face(cptr, bar);
|
||||
if (foo) {
|
||||
fprintf(stderr, "line %d '%s' parseface -> %d\n",
|
||||
linenumber, cptr, foo);
|
||||
@@ -298,10 +313,18 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
break;
|
||||
|
||||
case T_line:
|
||||
cptr = strtok(NULL, " ");
|
||||
fprintf(stderr, "\tLine: %s\n", cptr);
|
||||
break;
|
||||
case T_smoothing:
|
||||
cptr = strtok(NULL, " ");
|
||||
if (verbosity)
|
||||
fprintf(stderr, "\tSmoothing: %s\n", cptr);
|
||||
break;
|
||||
case T_vt:
|
||||
cptr = strtok(NULL, " ");
|
||||
if (verbosity)
|
||||
fprintf(stderr, "\tvt ??? : %s\n", cptr);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -312,11 +335,11 @@ while(NULL!=(cptr=fgets(line, LINE_SZ, fpin))) {
|
||||
|
||||
fclose(fpin);
|
||||
|
||||
fprintf(stderr, " ***************************************\n");
|
||||
fprintf(stderr, " +-----------------------------------------\n");
|
||||
|
||||
if(verbosity) {
|
||||
fprintf(stderr, "%s(): %9d vertices loaded\n", __func__, bublist->fidx);
|
||||
fprintf(stderr, "%s(): %9d edges loaded\n", __func__, edges->fidx);
|
||||
fprintf(stderr, "%s: %d vertices and %d edges loaded.\n", __func__,
|
||||
bublist->fidx, edges->fidx);
|
||||
}
|
||||
|
||||
if (verbosity > 1) {
|
||||
@@ -355,6 +378,7 @@ else { /* one 'evblob' file */
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
free(outfname);
|
||||
free_bubulles(bublist, 0);
|
||||
free_edgelist(edges, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user