Jspice3
mfblclip.c File Reference
#include "mfb.h"
Include dependency graph for mfblclip.c:

Go to the source code of this file.

Macros

#define CODELEFT   1
 
#define CODEBOTTOM   2
 
#define CODERIGHT   4
 
#define CODETOP   8
 
#define CODE(x, y, c)
 

Functions

void MFB_Y_Intercept (long x1, long y1, long x2, long y2, long e, long *yi)
 
void MFB_X_Intercept (long x1, long y1, long x2, long y2, long e, long *xi)
 
Bool MFBLineClip (long *pX1, long *pY1, long *pX2, long *pY2, long l, long b, long r, long t)
 

Macro Definition Documentation

#define CODE (   x,
  y,
  c 
)
Value:
c = 0;\
if(x < l)\
else if(x > r)\
if(y < b)\
else if(y > t)\
#define CODERIGHT
Definition: mfblclip.c:19
if(TDesc==NULL)
Definition: cd.c:1326
Definition: cddefs.h:312
#define CODETOP
Definition: mfblclip.c:20
static double c
Definition: vectors.c:16
Definition: cddefs.h:177
#define CODEBOTTOM
Definition: mfblclip.c:18
#define CODELEFT
Definition: mfblclip.c:17
Definition: cddefs.h:162
Definition: cddefs.h:192

Definition at line 21 of file mfblclip.c.

#define CODEBOTTOM   2

Definition at line 18 of file mfblclip.c.

#define CODELEFT   1

Definition at line 17 of file mfblclip.c.

#define CODERIGHT   4

Definition at line 19 of file mfblclip.c.

#define CODETOP   8

Definition at line 20 of file mfblclip.c.

Function Documentation

void MFB_X_Intercept ( long  x1,
long  y1,
long  x2,
long  y2,
long  e,
long *  xi 
)

Definition at line 50 of file mfblclip.c.

55 {
56  /*
57  * MFB_X_Intercept will return the value 'xi' where the the coordinate
58  * (xi,e) is the intersection of the horizontal line y = e and the line
59  * determined by the coordinates (x1,y1) and (x2,y2).
60  */
61  *xi = x1;
62  if (y1 == y2) return; /* horizontal line */
63  *xi = x1 + ((e - y1) * (x2 - x1))/(y2 - y1);
64 }
static double e
Definition: vectors.c:17
void MFB_Y_Intercept ( long  x1,
long  y1,
long  x2,
long  y2,
long  e,
long *  yi 
)

Definition at line 32 of file mfblclip.c.

37 {
38  /*
39  * MFB_Y_Intercept will return the value 'yi' where the the coordinate
40  * (e,yi) is the intersection of the vertical line x = e and the line
41  * determined by the coordinates (x1,y1) and (x2,y2).
42  */
43  *yi = y1;
44  if (x1 == x2) return; /* vertical line */
45  *yi = y1 + ((e - x1) * (y2 - y1))/(x2 - x1);
46 }
static double e
Definition: vectors.c:17
Bool MFBLineClip ( long *  pX1,
long*  pY1,
long*  pX2,
long*  pY2,
long  l,
long  b,
long  r,
long  t 
)

Definition at line 68 of file mfblclip.c.

71 {
72  /*
73  * MFBLineClip will clip a line to a rectangular area. The returned
74  * value is 'true' if the line is out of the AOI (therefore does not
75  * need to be displayed) and 'false' if the line is in the AOI.
76  */
77  long x1 = *pX1;
78  long y1 = *pY1;
79  long x2 = *pX2;
80  long y2 = *pY2;
81  long x,y;
82  int c,c1,c2;
83 
84  CODE(x1,y1,c1)
85  CODE(x2,y2,c2)
86  while (c1 != 0 || c2 != 0) {
87  if ((c1 & c2) != 0) return (true); /* Line is invisible. */
88  if ((c = c1) == 0) c = c2;
89  if (c & CODELEFT) {
90  y = y1+(y2-y1)*(l-x1)/(x2-x1);
91  x = l;
92  }
93  else if (c & CODERIGHT) {
94  y = y1+(y2-y1)*(r-x1)/(x2-x1);
95  x = r;
96  }
97  else if (c & CODEBOTTOM) {
98  x = x1+(x2-x1)*(b-y1)/(y2-y1);
99  y = b;
100  }
101  else if (c & CODETOP) {
102  x = x1+(x2-x1)*(t-y1)/(y2-y1);
103  y = t;
104  }
105  if (c == c1) {
106  x1 = x; y1 = y; CODE(x,y,c1)
107  }
108  else {
109  x2 = x; y2 = y; CODE(x,y,c2)
110  }
111  }
112  *pX1 = x1; *pY1 = y1;
113  *pX2 = x2; *pY2 = y2;
114  return (false); /* Line is at least partially visible. */
115 }
#define CODERIGHT
Definition: mfblclip.c:19
Definition: cddefs.h:312
#define CODETOP
Definition: mfblclip.c:20
static double c
Definition: vectors.c:16
while(TDesc->tSucc!=NULL)
Definition: cd.c:1335
#define CODEBOTTOM
Definition: mfblclip.c:18
#define CODELEFT
Definition: mfblclip.c:17
#define CODE(x, y, c)
Definition: mfblclip.c:21
Definition: cddefs.h:162
Definition: cddefs.h:192