1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
14 |
|
|
15 |
|
#include "plocate.h" |
16 |
|
|
17 |
+ |
#define MAXITER 6 /* maximum possible number of iterations */ |
18 |
|
|
19 |
+ |
|
20 |
|
clip(ep1, ep2, min, max) /* clip a line segment to a box */ |
21 |
|
FLOAT *ep1, *ep2; |
22 |
|
FVECT min, max; |
23 |
|
{ |
24 |
+ |
int itlim = MAXITER; |
25 |
|
int loc1, loc2; |
26 |
|
int accept; |
27 |
|
FLOAT *dp; |
44 |
|
|
45 |
|
while (!((accept = !(loc1 | loc2)) || (loc1 & loc2))) { |
46 |
|
|
47 |
+ |
if (itlim-- <= 0) /* past theoretical limit? */ |
48 |
+ |
return(0); /* quit fooling around */ |
49 |
+ |
|
50 |
|
if (!loc1) { /* make sure first point is outside */ |
51 |
|
dp = ep1; ep1 = ep2; ep2 = dp; |
52 |
|
i = loc1; loc1 = loc2; loc2 = i; |