Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

zzclip.c File Reference

#include "f2c.h"

Go to the source code of this file.


Defines

#define zzzplt_1   zzzplt_
#define zzpltr_1   zzpltr_

Functions

int zzclip_ (real *x1in, real *y1in, real *x2in, real *y2in)

Variables

struct {
   real   xpgmin
   real   ypgmin
   real   xpgmax
   real   ypgmax
   real   xclbot
   real   yclbot
   real   xcltop
   real   ycltop
   real   xbot
   real   ybot
   real   xtop
   real   ytop
   real   xmin
   real   ymin
   real   xmax
   real   ymax
   integer   ixcoor
   integer   iycoor
   real   alphxx
   real   betaxx
   real   alphyy
   real   betayy
   real   tmajx
   real   tminx
   real   tmajy
   real   tminy
   integer   majrx
   integer   minrx
   integer   majry
   integer   minry
   integer   isizx
   integer   isizy
   real   xphold
   real   yphold
zzzplt_
struct {
   real   xphmax
   real   yphmax
   integer   ixpmax
   integer   iypmax
   real   xpscal
   real   ypscal
   integer   iflip
   integer   nplotr
   char   cfile [64]
zzpltr_

Define Documentation

#define zzpltr_1   zzpltr_
 

Definition at line 29 of file zzclip.c.

#define zzzplt_1   zzzplt_
 

Definition at line 19 of file zzclip.c.

Referenced by zzclip_().


Function Documentation

int zzclip_ real   x1in,
real   y1in,
real   x2in,
real   y2in
 

Definition at line 34 of file zzclip.c.

References dmax, dmin, x2, y1, and zzzplt_1.

Referenced by zzline_().

00035 {
00036     static real temp, slope, x1, x2, y1, y2, dx, dy;
00037     static logical linter;
00038 
00039 
00040 /*  Clip the input line to the predefined plotting region. */
00041 
00042 /*  INPUTS */
00043 /*  ------ */
00044 /*  X1IN   = start X-coordinate of line  (physical coordinates) */
00045 /*  Y1IN   = start Y-coordinate of line */
00046 /*  X2IN   = end X-coordinate of line */
00047 /*  Y2IN   = end Y-coordinate of line */
00048 
00049 /*  OUTPUTS */
00050 /*  ------- */
00051 /*  same as above but clipped so that the line fits into the plotting */
00052 /*  region defined by calling SETW. */
00053 
00054 /*  If the line falls entirely outside of the plotting region, then */
00055 /*  X1IN is returned as -1.E+38. */
00056 /* .......................................................................
00057  */
00058 
00059 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00060  */
00061 /*  Check to see if line can be thrown out as being totally out of */
00062 /*  the plotting region. */
00063 
00064 
00065 /*  Internal Data for PLOTPAK */
00066 
00067     if (dmax(*x1in,*x2in) < zzzplt_1.xclbot || dmin(*x1in,*x2in) > 
00068             zzzplt_1.xcltop || dmax(*y1in,*y2in) < zzzplt_1.yclbot || dmin(*
00069             y1in,*y2in) > zzzplt_1.ycltop) {
00070 
00071         *x1in = -1e38f;
00072         goto L8000;
00073     }
00074 
00075 /*  Copy input coordinates to local variables, making sure */
00076 /*  that X1 .LE. X2 by interchanging the points if necessary. */
00077 
00078     linter = *x1in > *x2in;
00079     if (linter) {
00080         x1 = *x2in;
00081         x2 = *x1in;
00082         y1 = *y2in;
00083         y2 = *y1in;
00084     } else {
00085         x1 = *x1in;
00086         x2 = *x2in;
00087         y1 = *y1in;
00088         y2 = *y2in;
00089     }
00090 
00091 /*  Clip line in X direction */
00092 
00093     dx = x2 - x1;
00094     if (dx > 0.f) {
00095 /*  only clip if line has some X range */
00096         slope = (y2 - y1) / dx;
00097         if (x1 < zzzplt_1.xclbot) {
00098 /*  intercept of line at left side */
00099             y1 += slope * (zzzplt_1.xclbot - x1);
00100             x1 = zzzplt_1.xclbot;
00101         }
00102         if (x2 > zzzplt_1.xcltop) {
00103 /*  intercept at right */
00104             y2 += slope * (zzzplt_1.xcltop - x2);
00105             x2 = zzzplt_1.xcltop;
00106         }
00107     }
00108 
00109 /*  Check line again to see if it falls outside of plot region. */
00110 
00111     if (dmax(y1,y2) < zzzplt_1.yclbot || dmin(y1,y2) > zzzplt_1.ycltop) {
00112         *x1in = -1e38f;
00113         goto L8000;
00114     }
00115 
00116 /*  Clip Y-direction.  To do this, must have Y1 .LE. Y2 */
00117 
00118     if (y1 > y2) {
00119         temp = x1;
00120         x1 = x2;
00121         x2 = temp;
00122         temp = y1;
00123         y1 = y2;
00124         y2 = temp;
00125 
00126         linter = ! linter;
00127     }
00128 
00129     dy = y2 - y1;
00130     if (dy > 0.f) {
00131 /*  only clip if line has some Y range */
00132         slope = (x2 - x1) / dy;
00133         if (y1 < zzzplt_1.yclbot) {
00134 /*  intercept of line at bottom */
00135             x1 += slope * (zzzplt_1.yclbot - y1);
00136             y1 = zzzplt_1.yclbot;
00137         }
00138         if (y2 > zzzplt_1.ycltop) {
00139 /*  intercept at top */
00140             x2 += slope * (zzzplt_1.ycltop - y2);
00141             y2 = zzzplt_1.ycltop;
00142         }
00143     }
00144 
00145 /*  Line is now guaranteed to be totally inside the plot region. */
00146 /*  Copy local clipped coordinates to output values and return. */
00147 /*  Note that we must restore points to original input order. */
00148 
00149     if (linter) {
00150         *x1in = x2;
00151         *x2in = x1;
00152         *y1in = y2;
00153         *y2in = y1;
00154     } else {
00155         *x1in = x1;
00156         *y1in = y1;
00157         *x2in = x2;
00158         *y2in = y2;
00159     }
00160 
00161 L8000:
00162     return 0;
00163 } /* zzclip_ */

Variable Documentation

real alphxx
 

Definition at line 14 of file zzclip.c.

real alphyy
 

Definition at line 14 of file zzclip.c.

real betaxx
 

Definition at line 14 of file zzclip.c.

real betayy
 

Definition at line 14 of file zzclip.c.

char cfile[64]
 

Definition at line 26 of file zzclip.c.

integer iflip
 

Definition at line 25 of file zzclip.c.

integer isizx
 

Definition at line 15 of file zzclip.c.

integer isizy
 

Definition at line 15 of file zzclip.c.

integer ixcoor
 

Definition at line 13 of file zzclip.c.

integer ixpmax
 

Definition at line 23 of file zzclip.c.

integer iycoor
 

Definition at line 13 of file zzclip.c.

integer iypmax
 

Definition at line 23 of file zzclip.c.

integer majrx
 

Definition at line 15 of file zzclip.c.

integer majry
 

Definition at line 15 of file zzclip.c.

integer minrx
 

Definition at line 15 of file zzclip.c.

integer minry
 

Definition at line 15 of file zzclip.c.

integer nplotr
 

Definition at line 25 of file zzclip.c.

real tmajx
 

Definition at line 14 of file zzclip.c.

real tmajy
 

Definition at line 14 of file zzclip.c.

real tminx
 

Definition at line 14 of file zzclip.c.

real tminy
 

Definition at line 14 of file zzclip.c.

real xbot
 

Definition at line 11 of file zzclip.c.

real xclbot
 

Definition at line 11 of file zzclip.c.

real xcltop
 

Definition at line 11 of file zzclip.c.

real xmax
 

Definition at line 11 of file zzclip.c.

real xmin
 

Definition at line 11 of file zzclip.c.

real xpgmax
 

Definition at line 11 of file zzclip.c.

real xpgmin
 

Definition at line 11 of file zzclip.c.

real xphmax
 

Definition at line 22 of file zzclip.c.

real xphold
 

Definition at line 16 of file zzclip.c.

real xpscal
 

Definition at line 24 of file zzclip.c.

real xtop
 

Definition at line 11 of file zzclip.c.

real ybot
 

Definition at line 11 of file zzclip.c.

real yclbot
 

Definition at line 11 of file zzclip.c.

real ycltop
 

Definition at line 11 of file zzclip.c.

real ymax
 

Definition at line 11 of file zzclip.c.

real ymin
 

Definition at line 11 of file zzclip.c.

real ypgmax
 

Definition at line 11 of file zzclip.c.

real ypgmin
 

Definition at line 11 of file zzclip.c.

real yphmax
 

Definition at line 22 of file zzclip.c.

real yphold
 

Definition at line 16 of file zzclip.c.

real ypscal
 

Definition at line 24 of file zzclip.c.

real ytop
 

Definition at line 11 of file zzclip.c.

struct { ... } zzpltr_
 

struct { ... } zzzplt_
 

 

Powered by Plone

This site conforms to the following standards: