Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
zzclip.c
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 #include "f2c.h"
00007 
00008 
00009 
00010 extern struct {
00011     real xpgmin, ypgmin, xpgmax, ypgmax, xclbot, yclbot, xcltop, ycltop, xbot,
00012              ybot, xtop, ytop, xmin, ymin, xmax, ymax;
00013     integer ixcoor, iycoor;
00014     real alphxx, betaxx, alphyy, betayy, tmajx, tminx, tmajy, tminy;
00015     integer majrx, minrx, majry, minry, isizx, isizy;
00016     real xphold, yphold;
00017 } zzzplt_;
00018 
00019 #define zzzplt_1 zzzplt_
00020 
00021 extern struct {
00022     real xphmax, yphmax;
00023     integer ixpmax, iypmax;
00024     real xpscal, ypscal;
00025     integer iflip, nplotr;
00026     char cfile[64];
00027 } zzpltr_;
00028 
00029 #define zzpltr_1 zzpltr_
00030 
00031 
00032 
00033 
00034  int zzclip_(real *x1in, real *y1in, real *x2in, real *y2in)
00035 {
00036     static real temp, slope, x1, x2, y1, y2, dx, dy;
00037     static logical linter;
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
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 
00076 
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 
00092 
00093     dx = x2 - x1;
00094     if (dx > 0.f) {
00095 
00096         slope = (y2 - y1) / dx;
00097         if (x1 < zzzplt_1.xclbot) {
00098 
00099             y1 += slope * (zzzplt_1.xclbot - x1);
00100             x1 = zzzplt_1.xclbot;
00101         }
00102         if (x2 > zzzplt_1.xcltop) {
00103 
00104             y2 += slope * (zzzplt_1.xcltop - x2);
00105             x2 = zzzplt_1.xcltop;
00106         }
00107     }
00108 
00109 
00110 
00111     if (dmax(y1,y2) < zzzplt_1.yclbot || dmin(y1,y2) > zzzplt_1.ycltop) {
00112         *x1in = -1e38f;
00113         goto L8000;
00114     }
00115 
00116 
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 
00132         slope = (x2 - x1) / dy;
00133         if (y1 < zzzplt_1.yclbot) {
00134 
00135             x1 += slope * (zzzplt_1.yclbot - y1);
00136             y1 = zzzplt_1.yclbot;
00137         }
00138         if (y2 > zzzplt_1.ycltop) {
00139 
00140             x2 += slope * (zzzplt_1.ycltop - y2);
00141             y2 = zzzplt_1.ycltop;
00142         }
00143     }
00144 
00145 
00146 
00147 
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 } 
00164