1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
51 |
|
if (o->oargs.nfargs < 9 || o->oargs.nfargs % 3) |
52 |
|
objerror(o, USER, "bad # arguments"); |
53 |
|
|
54 |
+ |
o->os = (char *)f; /* save face */ |
55 |
+ |
|
56 |
|
f->va = o->oargs.farg; |
57 |
|
f->nv = o->oargs.nfargs / 3; |
58 |
|
/* compute area and normal */ |
71 |
|
f->area = normalize(f->norm); |
72 |
|
if (f->area == 0.0) { |
73 |
|
objerror(o, WARNING, "zero area"); /* used to be fatal */ |
74 |
< |
f->const = 0.0; |
74 |
> |
f->offset = 0.0; |
75 |
|
f->ax = 0; |
76 |
|
return(f); |
77 |
|
} |
78 |
|
f->area *= 0.5; |
79 |
< |
/* compute constant */ |
79 |
> |
/* compute offset */ |
80 |
|
badvert = 0; |
81 |
< |
f->const = DOT(f->norm, VERTEX(f,0)); |
81 |
> |
f->offset = DOT(f->norm, VERTEX(f,0)); |
82 |
|
for (i = 1; i < f->nv; i++) { |
83 |
|
d1 = DOT(f->norm, VERTEX(f,i)); |
84 |
< |
badvert += fabs(d1 - f->const/i) > VERTEPS; |
85 |
< |
f->const += d1; |
84 |
> |
badvert += fabs(d1 - f->offset/i) > VERTEPS; |
85 |
> |
f->offset += d1; |
86 |
|
} |
87 |
< |
f->const /= f->nv; |
87 |
> |
f->offset /= (double)f->nv; |
88 |
|
if (badvert) |
89 |
|
objerror(o, WARNING, "non-planar vertex"); |
90 |
|
/* find axis */ |
92 |
|
if (fabs(f->norm[2]) > fabs(f->norm[f->ax])) |
93 |
|
f->ax = 2; |
94 |
|
|
93 |
– |
(FACE *)o->os = f; /* save face */ |
95 |
|
return(f); |
96 |
|
} |
97 |
|
|
99 |
|
freeface(o) /* free memory associated with face */ |
100 |
|
OBJREC *o; |
101 |
|
{ |
102 |
+ |
if (o->os == NULL) |
103 |
+ |
return; |
104 |
|
free(o->os); |
105 |
|
o->os = NULL; |
106 |
|
} |
113 |
|
int ncross, n; |
114 |
|
double x, y; |
115 |
|
register int xi, yi; |
116 |
< |
register double *p0, *p1; |
116 |
> |
register FLOAT *p0, *p1; |
117 |
|
|
118 |
|
xi = (f->ax+1)%3; |
119 |
|
yi = (f->ax+2)%3; |