| 1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* text.c - functions for text patterns and mixtures. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
< |
#include "ray.h" |
| 8 |
> |
#include "copyright.h" |
| 9 |
|
|
| 10 |
+ |
#include "ray.h" |
| 11 |
+ |
#include "paths.h" |
| 12 |
|
#include "otypes.h" |
| 13 |
< |
|
| 13 |
> |
#include "rtotypes.h" |
| 14 |
|
#include "font.h" |
| 15 |
|
|
| 16 |
|
/* |
| 76 |
|
TLINE tl; /* line list */ |
| 77 |
|
} TEXT; |
| 78 |
|
|
| 79 |
< |
extern char *getlibpath(); |
| 79 |
> |
static TLINE * tlalloc(char *s); |
| 80 |
> |
static TEXT * gettext(OBJREC *tm); |
| 81 |
> |
static int intext(FVECT p, OBJREC *m); |
| 82 |
> |
static int inglyph(double x, double y, GLYPH *gl); |
| 83 |
|
|
| 82 |
– |
extern char *fgetword(); |
| 84 |
|
|
| 85 |
< |
TEXT *gettext(); |
| 86 |
< |
|
| 87 |
< |
TLINE *tlalloc(); |
| 88 |
< |
|
| 89 |
< |
|
| 89 |
< |
do_text(m, r) |
| 90 |
< |
register OBJREC *m; |
| 91 |
< |
RAY *r; |
| 85 |
> |
extern int |
| 86 |
> |
do_text( |
| 87 |
> |
register OBJREC *m, |
| 88 |
> |
RAY *r |
| 89 |
> |
) |
| 90 |
|
{ |
| 91 |
|
FVECT v; |
| 92 |
|
int foreground; |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
< |
TLINE * |
| 137 |
< |
tlalloc(s) /* allocate and assign text line */ |
| 138 |
< |
char *s; |
| 136 |
> |
static TLINE * |
| 137 |
> |
tlalloc( /* allocate and assign text line */ |
| 138 |
> |
char *s |
| 139 |
> |
) |
| 140 |
|
{ |
| 142 |
– |
extern char *strcpy(); |
| 141 |
|
register int siz; |
| 142 |
|
register TLINE *tl; |
| 143 |
|
|
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
|
| 154 |
< |
TEXT * |
| 155 |
< |
gettext(tm) /* get text structure for material */ |
| 156 |
< |
register OBJREC *tm; |
| 154 |
> |
static TEXT * |
| 155 |
> |
gettext( /* get text structure for material */ |
| 156 |
> |
register OBJREC *tm |
| 157 |
> |
) |
| 158 |
|
{ |
| 159 |
|
#define R (tm->oargs.farg+3) |
| 160 |
|
#define D (tm->oargs.farg+6) |
| 162 |
– |
extern char *strcpy(); |
| 161 |
|
FVECT DxR; |
| 162 |
|
double d; |
| 163 |
|
FILE *fp; |
| 201 |
|
tlp = tlp->next; |
| 202 |
|
} else { /* text file */ |
| 203 |
|
if ((s = getpath(tm->oargs.sarg[tndx(tm)], |
| 204 |
< |
getlibpath(), R_OK)) == NULL) { |
| 204 |
> |
getrlibpath(), R_OK)) == NULL) { |
| 205 |
|
sprintf(errmsg, "cannot find text file \"%s\"", |
| 206 |
|
tm->oargs.sarg[tndx(tm)]); |
| 207 |
|
error(USER, errmsg); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
|
| 248 |
< |
freetext(m) /* free text structures associated with m */ |
| 249 |
< |
OBJREC *m; |
| 248 |
> |
extern void |
| 249 |
> |
freetext( /* free text structures associated with m */ |
| 250 |
> |
OBJREC *m |
| 251 |
> |
) |
| 252 |
|
{ |
| 253 |
|
register TEXT *tp; |
| 254 |
|
register TLINE *tlp; |
| 258 |
|
return; |
| 259 |
|
while ((tlp = tp->tl.next) != NULL) { |
| 260 |
|
tp->tl.next = tlp->next; |
| 261 |
< |
free((char *)tlp->spc); |
| 262 |
< |
free((char *)tlp); |
| 261 |
> |
free((void *)tlp->spc); |
| 262 |
> |
free((void *)tlp); |
| 263 |
|
} |
| 264 |
< |
free((char *)tp); |
| 264 |
> |
freefont(tp->f); /* release font reference */ |
| 265 |
> |
free((void *)tp); |
| 266 |
|
m->os = NULL; |
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
|
| 270 |
< |
intext(p, m) /* check to see if p is in text glyph */ |
| 271 |
< |
FVECT p; |
| 272 |
< |
OBJREC *m; |
| 270 |
> |
static int |
| 271 |
> |
intext( /* check to see if p is in text glyph */ |
| 272 |
> |
FVECT p, |
| 273 |
> |
OBJREC *m |
| 274 |
> |
) |
| 275 |
|
{ |
| 276 |
|
register TEXT *tp; |
| 277 |
|
register TLINE *tlp; |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
|
| 312 |
< |
inglyph(x, y, gl) /* (x,y) within font glyph gl? */ |
| 313 |
< |
double x, y; /* real coordinates in range [0,255) */ |
| 314 |
< |
register GLYPH *gl; |
| 312 |
> |
static int |
| 313 |
> |
inglyph( /* (x,y) within font glyph gl? */ |
| 314 |
> |
double x, /* real coordinates in range [0,255) */ |
| 315 |
> |
double y, |
| 316 |
> |
register GLYPH *gl |
| 317 |
> |
) |
| 318 |
|
{ |
| 319 |
|
int n, ncross; |
| 320 |
|
int xlb, ylb; |
| 337 |
|
/* positive x axis cross test */ |
| 338 |
|
while (n--) { |
| 339 |
|
if ((p0[1]<<1 > ylb) ^ (p1[1]<<1 > ylb)) { |
| 340 |
< |
tv = p0[0]<<1 > xlb | (p1[0]<<1 > xlb) << 1; |
| 340 |
> |
tv = (p0[0]<<1 > xlb) | ((p1[0]<<1 > xlb) << 1); |
| 341 |
|
if (tv == 03) |
| 342 |
|
ncross++; |
| 343 |
|
else if (tv) |