700 |
|
return(f); |
701 |
|
} |
702 |
|
|
703 |
+ |
/* Callback for growBoundingBox() */ |
704 |
+ |
static int |
705 |
+ |
addBBox(Scene *sc, Face *f, void *p) |
706 |
+ |
{ |
707 |
+ |
double (*bbox)[3] = (double (*)[3])p; |
708 |
+ |
int i, j; |
709 |
+ |
|
710 |
+ |
for (i = f->nv; i-- > 0; ) { |
711 |
+ |
double *p3 = sc->vert[f->v[i].vid].p; |
712 |
+ |
for (j = 3; j--; ) { |
713 |
+ |
if (p3[j] < bbox[0][j]) |
714 |
+ |
bbox[0][j] = p3[j]; |
715 |
+ |
if (p3[j] > bbox[1][j]) |
716 |
+ |
bbox[1][j] = p3[j]; |
717 |
+ |
} |
718 |
+ |
} |
719 |
+ |
return(1); |
720 |
+ |
} |
721 |
+ |
|
722 |
+ |
/* Expand bounding box min & max (initialize bbox to all zeroes) */ |
723 |
+ |
int |
724 |
+ |
growBoundingBox(Scene *sc, double bbox[2][3], int flreq, int flexc) |
725 |
+ |
{ |
726 |
+ |
if (sc == NULL || sc->nfaces <= 0 || bbox == NULL) |
727 |
+ |
return(0); |
728 |
+ |
|
729 |
+ |
if (VABSEQ(bbox[0], bbox[1])) { /* first run */ |
730 |
+ |
bbox[0][0] = bbox[0][1] = bbox[0][2] = FHUGE; |
731 |
+ |
bbox[1][0] = bbox[1][1] = bbox[1][2] = -FHUGE; |
732 |
+ |
} |
733 |
+ |
return(foreachFace(sc, addBBox, flreq, flexc, bbox)); |
734 |
+ |
} |
735 |
+ |
|
736 |
|
/* Allocate an empty scene */ |
737 |
|
Scene * |
738 |
|
newScene(void) |