30 #define BINC 50 // Block size for memory allocation
170 PLFLT *in, *T[3], *TT = NULL;
176 in = (
PLFLT *) malloc(
sizeof (
PLFLT ) * (size_t) Ni );
177 TT = (
PLFLT *) malloc( 3 *
sizeof (
PLFLT ) * (size_t) Ni );
179 if ( in == NULL || TT == NULL )
181 plexit(
"plP_clip_poly: insufficient memory for large polygon" );
196 for ( i = 0; i < Ni; i++ )
198 in[i] = Vi[axis][i] * dir +
offset;
214 for ( i = 0; i < 3; i++ )
216 for ( j = 0; j < Ni; j++ )
222 for ( i = 0; i < Ni; i++ )
226 if ( in[i] >= 0 && in[j] >= 0 )
228 for ( k = 0; k < 3; k++ )
232 else if ( in[i] >= 0 && in[j] < 0 )
234 PLFLT u = in[i] / ( in[i] - in[j] );
235 for ( k = 0; k < 3; k++ )
236 Vi[k][No] = T[k][i] * ( 1 - u ) + T[k][j] * u;
239 else if ( in[i] < 0 && in[j] >= 0 )
241 PLFLT u = in[i] / ( in[i] - in[j] );
242 for ( k = 0; k < 3; k++ )
243 Vi[k][No] = T[k][i] * ( 1 - u ) + T[k][j] * u;
245 for ( k = 0; k < 3; k++ )
269 PLFLT x[6], y[6], z[6];
271 PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale;
274 plP_gdom( &xmin, &xmax, &ymin, &ymax );
277 x[0] = x0; x[1] = x1; x[2] = x2;
278 y[0] = y0; y[1] = y1; y[2] = y2;
279 z[0] = z0; z[1] = z1; z[2] = z2;
282 V[0] = x; V[1] = y; V[2] = z;
298 for ( i = 0; i < n; i++ )
306 #ifdef SHADE_DEBUG // show triangles
308 x[3] = x[0]; y[3] = y[0]; z[3] = z[0];
310 #else // fill triangles
330 opt, clevel, nlevel );
341 if ( !indexymin || !indexymax )
342 plexit(
"plsurf3d: Out of memory." );
343 for ( i = 0; i < nx; i++ )
348 plfsurf3dl( x, y, zops, zp, nx, ny, opt, clevel, nlevel,
349 0, nx, indexymin, indexymax );
394 opt, clevel, nlevel, indexxmin, indexxmax, indexymin, indexymax );
402 PLFLT cxx, cxy, cyx, cyy, cyz;
404 PLINT ixDir, ixOrigin, iyDir, iyOrigin, nFast, nSlow;
405 PLINT ixFast, ixSlow, iyFast, iySlow;
407 PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale;
409 PLINT ixmin = 0, ixmax = nx, iymin = 0, iymax = ny;
410 PLFLT xx[3], yy[3], zz[3];
411 PLFLT px[4], py[4], pz[4];
414 int ct, ix, iy, iftriangle;
415 PLINT color = plsc->icol0;
416 PLFLT width = plsc->width;
419 if ( plsc->level < 3 )
421 myabort(
"plsurf3dl: Please set up window first" );
425 if ( nx <= 0 || ny <= 0 )
427 myabort(
"plsurf3dl: Bad array dimensions." );
442 plwarn(
"plsurf3dl: Maximum and minimum Z values are equal! \"fixing\"..." );
451 plP_gdom( &xmin, &xmax, &ymin, &ymax );
462 for ( i = 0; i < nx - 1; i++ )
464 if ( x[i] >= x[i + 1] )
466 myabort(
"plsurf3dl: X array must be strictly increasing" );
469 if ( x[i] < xmin && x[i + 1] >= xmin )
471 if ( x[i + 1] > xmax && x[i] <= xmax )
474 for ( i = 0; i < ny - 1; i++ )
476 if ( y[i] >= y[i + 1] )
478 myabort(
"plsurf3dl: Y array must be strictly increasing" );
481 if ( y[i] < ymin && y[i + 1] >= ymin )
483 if ( y[i + 1] > ymax && y[i] <= ymax )
488 plP_gw3wc( &cxx, &cxy, &cyx, &cyy, &cyz );
507 ixOrigin = ixmax - 1;
513 iyOrigin = iymax - 1;
521 if ( fabs( cxx ) > fabs( cxy ) )
524 nFast = ixmax - ixmin;
525 nSlow = iymax - iymin;
527 ixFast = ixDir; ixSlow = 0;
528 iyFast = 0; iySlow = iyDir;
532 nFast = iymax - iymin;
533 nSlow = ixmax - ixmin;
535 ixFast = 0; ixSlow = ixDir;
536 iyFast = iyDir; iySlow = 0;
542 PLFLT bx[3], by[3], bz[3];
550 bx[0] = ( ixOrigin != ixmin && ixFast == 0 ) || ixFast > 0 ? xmax : xmin;
551 by[0] = ( iyOrigin != iymin && iyFast == 0 ) || iyFast > 0 ? ymax : ymin;
552 bx[1] = ixOrigin != ixmin ? xmax : xmin;
553 by[1] = iyOrigin != iymin ? ymax : ymin;
554 bx[2] = ( ixOrigin != ixmin && ixSlow == 0 ) || ixSlow > 0 ? xmax : xmin;
555 by[2] = ( iyOrigin != iymin && iySlow == 0 ) || iySlow > 0 ? ymax : ymin;
559 for ( tp = tick * floor( zmin / tick ) + tick; tp <= zmax; tp += tick )
561 bz[0] = bz[1] = bz[2] = tp;
588 plexit(
"plsurf3dl: Insufficient memory" );
599 for ( i = indexxmin; i < indexxmax; i++ )
601 for ( j = 0; j < indexymin[i]; j++ )
603 cgrid2.
xg[i][j] = x[i];
604 cgrid2.
yg[i][j] = y[indexymin[i]];
605 zstore[i][j] = getz( zp, i, indexymin[i] );
607 for ( j = indexymin[i]; j < indexymax[i]; j++ )
609 cgrid2.
xg[i][j] = x[i];
610 cgrid2.
yg[i][j] = y[j];
611 zstore[i][j] = getz( zp, i, j );
613 for ( j = indexymax[i]; j < ny; j++ )
615 cgrid2.
xg[i][j] = x[i];
616 cgrid2.
yg[i][j] = y[indexymax[i] - 1];
617 zstore[i][j] = getz( zp, i, indexymax[i] - 1 );
622 clevel, nlevel,
pltr2, (
void *) &cgrid2, &cont );
636 if ( cline->
npts > np )
639 if ( ( zzloc = (
PLFLT *) realloc( zzloc, (
size_t) np *
sizeof (
PLFLT ) ) ) == NULL )
641 plexit(
"plsurf3dl: Insufficient memory" );
644 for ( j = 0; j < cline->
npts; j++ )
645 zzloc[j] = plsc->ranmi;
646 if ( cline->
npts > 0 )
653 while ( cline != NULL );
656 while ( clev != NULL );
663 for ( iSlow = 0; iSlow < nSlow - 1; iSlow++ )
665 for ( iFast = 0; iFast < nFast - 1; iFast++ )
677 for ( i = 0; i < 2; i++ )
679 for ( j = 0; j < 2; j++ )
683 ix = ixFast * ( iFast + i ) + ixSlow * ( iSlow + j ) + ixOrigin;
684 iy = iyFast * ( iFast + i ) + iySlow * ( iSlow + j ) + iyOrigin;
686 if ( indexxmin <= ix && ix < indexxmax &&
687 indexymin[ix] <= iy && iy < indexymax[ix] )
689 xm += px[2 * i + j] = x[ix];
690 ym += py[2 * i + j] = y[iy];
691 zm += pz[2 * i + j] = getz( zp, ix, iy );
699 if ( iftriangle == 0 )
703 if ( iftriangle == 0 )
708 xm /= 4.; ym /= 4.; zm /= 4.;
712 for ( i = 1; i < 3; i++ )
714 for ( j = 0; j < 4; j += 3 )
716 shade_triangle( px[j], py[j], pz[j], xm, ym, zm, px[i], py[i], pz[i] );
721 if ( clevel != NULL && ( opt &
SURF_CONT ) )
723 for ( i = 1; i < 3; i++ )
725 for ( j = 0; j < 4; j += 3 )
726 #define
min3( a, b, c ) (
MIN( (
MIN( a, b ) ), c ) )
727 #define
max3( a, b, c ) (
MAX( (
MAX( a, b ) ), c ) )
730 for ( k = 0; k < nlevel; k++ )
732 if ( clevel[k] >=
min3( pz[i], zm, pz[j] ) && clevel[k] <
max3( pz[i], zm, pz[j] ) )
735 if ( clevel[k] >=
MIN( pz[i], zm ) && clevel[k] <
MAX( pz[i], zm ) )
737 xx[ct] = ( ( clevel[k] - pz[i] ) * ( xm - px[i] ) ) / ( zm - pz[i] ) + px[i];
738 yy[ct] = ( ( clevel[k] - pz[i] ) * ( ym - py[i] ) ) / ( zm - pz[i] ) + py[i];
742 if ( clevel[k] >=
MIN( pz[i], pz[j] ) && clevel[k] <
MAX( pz[i], pz[j] ) )
744 xx[ct] = ( ( clevel[k] - pz[i] ) * ( px[j] - px[i] ) ) / ( pz[j] - pz[i] ) + px[i];
745 yy[ct] = ( ( clevel[k] - pz[i] ) * ( py[j] - py[i] ) ) / ( pz[j] - pz[i] ) + py[i];
749 if ( clevel[k] >=
MIN( pz[j], zm ) && clevel[k] <
MAX( pz[j], zm ) )
751 xx[ct] = ( ( clevel[k] - pz[j] ) * ( xm - px[j] ) ) / ( zm - pz[j] ) + px[j];
752 yy[ct] = ( ( clevel[k] - pz[j] ) * ( ym - py[j] ) ) / ( zm - pz[j] ) + py[j];
764 zz[0] = zz[1] = clevel[k];
770 plwarn(
"plsurf3dl: ***ERROR***\n" );
783 indexxmin, indexxmax, indexymin, indexymax );
792 for ( iFast = 0; iFast < nFast - 1; iFast++ )
794 for ( i = 0; i < 2; i++ )
796 ix = ixFast * ( iFast + i ) + ixSlow * iSlow + ixOrigin;
797 iy = iyFast * ( iFast + i ) + iySlow * iSlow + iyOrigin;
798 if ( indexxmin <= ix && ix < indexxmax &&
799 indexymin[ix] <= iy && iy < indexymax[ix] )
803 pz[2 * i] = getz( zp, ix, iy );
811 if ( iftriangle == 0 )
815 shade_triangle( px[0], py[0], pz[0], px[2], py[2], pz[2], px[0], py[0], zmin );
816 shade_triangle( px[2], py[2], pz[2], px[2], py[2], zmin, px[0], py[0], zmin );
821 for ( iSlow = 0; iSlow < nSlow - 1; iSlow++ )
823 for ( i = 0; i < 2; i++ )
825 ix = ixFast * iFast + ixSlow * ( iSlow + i ) + ixOrigin;
826 iy = iyFast * iFast + iySlow * ( iSlow + i ) + iyOrigin;
827 if ( indexxmin <= ix && ix < indexxmax &&
828 indexymin[ix] <= iy && iy < indexymax[ix] )
832 pz[2 * i] = getz( zp, ix, iy );
840 if ( iftriangle == 0 )
844 shade_triangle( px[0], py[0], pz[0], px[2], py[2], pz[2], px[0], py[0], zmin );
845 shade_triangle( px[2], py[2], pz[2], px[2], py[2], zmin, px[0], py[0], zmin );
887 plfplot3dcl( x, y,
plf2ops_c(), (
PLPointer) z, nx, ny, opt, clevel, nlevel, 0, 0, NULL, NULL );
894 plfplot3dcl( x, y, zops, zp, nx, ny, opt, clevel, nlevel, 0, 0, NULL, NULL );
927 opt, clevel, nlevel, indexxmin, indexxmax, indexymin, indexymax );
975 PLFLT cxx, cxy, cyx, cyy, cyz;
976 PLINT init, ix, iy, color;
978 PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale;
979 PLINT ixmin = 0, ixmax = nx - 1, iymin = 0, iymax = ny - 1;
980 PLINT clipped = 0, base_cont = 0, side = 0;
982 PLFLT *_x = NULL, *_y = NULL, **_z = NULL;
988 if ( plsc->level < 3 )
990 myabort(
"plot3dcl: Please set up window first" );
994 if ( ( opt & 3 ) == 0 )
996 myabort(
"plot3dcl: Bad option" );
1000 if ( nx <= 0 || ny <= 0 )
1002 myabort(
"plot3dcl: Bad array dimensions." );
1006 plP_gdom( &xmin, &xmax, &ymin, &ymax );
1017 for ( i = 0; i < nx - 1; i++ )
1019 if ( x[i] >= x[i + 1] )
1021 myabort(
"plot3dcl: X array must be strictly increasing" );
1025 for ( i = 0; i < ny - 1; i++ )
1027 if ( y[i] >= y[i + 1] )
1029 myabort(
"plot3dcl: Y array must be strictly increasing" );
1043 if ( xmax > x[nx - 1] )
1047 if ( ymax > y[ny - 1] )
1049 for ( ixmin = 0; ixmin < nx - 1 && x[ixmin + 1] < xmin; ixmin++ )
1052 for ( ixmax = nx - 1; ixmax > 0 && x[ixmax - 1] > xmax; ixmax-- )
1055 for ( iymin = 0; iymin < ny - 1 && y[iymin + 1] < ymin; iymin++ )
1058 for ( iymax = ny - 1; iymax > 0 && y[iymax - 1] > ymax; iymax-- )
1063 if ( ixmin > 0 || ixmax < nx - 1 || iymin > 0 || iymax < ny - 1 )
1066 int _nx = ixmax - ixmin + 1;
1067 int _ny = iymax - iymin + 1;
1068 PLFLT ty0, ty1, tx0, tx1;
1071 if ( _nx <= 1 || _ny <= 1 )
1073 myabort(
"plot3dcl: selected x or y range has no data" );
1078 if ( ( ( _x = (
PLFLT *) malloc( (
size_t) _nx *
sizeof (
PLFLT ) ) ) == NULL ) ||
1079 ( ( _y = (
PLFLT *) malloc( (
size_t) _ny *
sizeof (
PLFLT ) ) ) == NULL ) ||
1080 ( ( _z = (
PLFLT **) malloc( (
size_t) _nx *
sizeof (
PLFLT* ) ) ) == NULL ) )
1082 plexit(
"c_plot3dcl: Insufficient memory" );
1090 for ( i = 1; i < _nx - 1; i++ )
1091 _x[i] = x[ixmin + i];
1094 for ( i = 1; i < _ny - 1; i++ )
1095 _y[i] = y[iymin + i];
1098 for ( i = 0; i < _nx; i++ )
1100 if ( ( _z[i] = (
PLFLT *) malloc( (
size_t) _ny *
sizeof (
PLFLT ) ) ) == NULL )
1102 plexit(
"c_plot3dcl: Insufficient memory" );
1107 ty0 = ( _y[0] - y[iymin] ) / ( y[iymin + 1] - y[iymin] );
1108 ty1 = ( _y[_ny - 1] - y[iymax - 1] ) / ( y[iymax] - y[iymax - 1] );
1109 tx0 = ( _x[0] - x[ixmin] ) / ( x[ixmin + 1] - x[ixmin] );
1110 tx1 = ( _x[_nx - 1] - x[ixmax - 1] ) / ( x[ixmax] - x[ixmax - 1] );
1111 for ( i = 0; i < _nx; i++ )
1115 _z[i][0] = getz( zp, ixmin, iymin ) * ( 1 - ty0 ) * ( 1 - tx0 ) + getz( zp, ixmin, iymin + 1 ) * ( 1 - tx0 ) * ty0
1116 + getz( zp, ixmin + 1, iymin ) * tx0 * ( 1 - ty0 ) + getz( zp, ixmin + 1, iymin + 1 ) * tx0 * ty0;
1117 for ( j = 1; j < _ny - 1; j++ )
1118 _z[i][j] = getz( zp, ixmin, iymin + j ) * ( 1 - tx0 ) + getz( zp, ixmin + 1, iymin + j ) * tx0;
1119 _z[i][_ny - 1] = getz( zp, ixmin, iymax - 1 ) * ( 1 - tx0 ) * ( 1 - ty1 ) + getz( zp, ixmin, iymax ) * ( 1 - tx0 ) * ty1
1120 + getz( zp, ixmin + 1, iymax - 1 ) * tx0 * ( 1 - ty1 ) + getz( zp, ixmin + 1, iymax ) * tx0 * ty1;
1122 else if ( i == _nx - 1 )
1124 _z[i][0] = getz( zp, ixmax - 1, iymin ) * ( 1 - tx1 ) * ( 1 - ty0 ) + getz( zp, ixmax - 1, iymin + 1 ) * ( 1 - tx1 ) * ty0
1125 + getz( zp, ixmax, iymin ) * tx1 * ( 1 - ty0 ) + getz( zp, ixmax, iymin + 1 ) * tx1 * ty0;
1126 for ( j = 1; j < _ny - 1; j++ )
1127 _z[i][j] = getz( zp, ixmax - 1, iymin + j ) * ( 1 - tx1 ) + getz( zp, ixmax, iymin + j ) * tx1;
1128 _z[i][_ny - 1] = getz( zp, ixmax - 1, iymax - 1 ) * ( 1 - tx1 ) * ( 1 - ty1 ) + getz( zp, ixmax, iymax ) * ( 1 - tx1 ) * ty1
1129 + getz( zp, ixmax, iymax - 1 ) * tx1 * ( 1 - ty1 ) + getz( zp, ixmax, iymax ) * tx1 * ty1;
1133 _z[i][0] = getz( zp, ixmin + i, iymin ) * ( 1 - ty0 ) + getz( zp, ixmin + i, iymin + 1 ) * ty0;
1134 for ( j = 1; j < _ny - 1; j++ )
1135 _z[i][j] = getz( zp, ixmin + i, iymin + j );
1136 _z[i][_ny - 1] = getz( zp, ixmin + i, iymax - 1 ) * ( 1 - ty1 ) + getz( zp, ixmin + i, iymax ) * ty1;
1138 for ( j = 0; j < _ny; j++ )
1140 if ( _z[i][j] < zmin )
1142 else if ( _z[i][j] > zmax )
1177 plwarn(
"plot3dcl: Maximum and minimum Z values are equal! \"fixing\"..." );
1182 if ( opt & BASE_CONT )
1184 if ( clevel != NULL && nlevel != 0 )
1193 if ( opt & MAG_COLOR )
1195 if ( (
ctmp = (
PLFLT *) malloc( (
size_t) ( 2 *
MAX( nx, ny ) ) *
sizeof (
PLFLT ) ) ) == NULL )
1197 plexit(
"c_plot3dcl: Insufficient memory" );
1208 utmp = (PLINT *) malloc( (
size_t) ( 2 *
MAX( nx, ny ) ) *
sizeof ( PLINT ) );
1209 vtmp = (PLINT *) malloc( (
size_t) ( 2 *
MAX( nx, ny ) ) *
sizeof ( PLINT ) );
1212 myexit(
"plot3dcl: Out of memory." );
1214 plP_gw3wc( &cxx, &cxy, &cyx, &cyy, &cyz );
1218 if ( cxx >= 0.0 && cxy <= 0.0 )
1221 plt3zz( 1, ny, 1, -1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1224 for ( iy = 2; iy <= ny; iy++ )
1225 plt3zz( 1, iy, 1, -1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1228 plt3zz( 1, ny, 1, -1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1231 for ( ix = 1; ix <= nx - 1; ix++ )
1232 plt3zz( ix, ny, 1, -1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1236 else if ( cxx <= 0.0 && cxy <= 0.0 )
1239 plt3zz( nx, ny, -1, -1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1242 for ( ix = 2; ix <= nx; ix++ )
1243 plt3zz( ix, ny, -1, -1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1246 plt3zz( nx, ny, -1, -1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1249 for ( iy = ny; iy >= 2; iy-- )
1250 plt3zz( nx, iy, -1, -1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1254 else if ( cxx <= 0.0 && cxy >= 0.0 )
1257 plt3zz( nx, 1, -1, 1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1260 for ( iy = ny - 1; iy >= 1; iy-- )
1261 plt3zz( nx, iy, -1, 1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1264 plt3zz( nx, 1, -1, 1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1267 for ( ix = nx; ix >= 2; ix-- )
1268 plt3zz( ix, 1, -1, 1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1272 else if ( cxx >= 0.0 && cxy >= 0.0 )
1275 plt3zz( 1, 1, 1, 1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1278 for ( ix = nx - 1; ix >= 1; ix-- )
1279 plt3zz( ix, 1, 1, 1, opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1282 plt3zz( 1, 1, 1, 1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1285 for ( iy = 1; iy <= ny - 1; iy++ )
1286 plt3zz( 1, iy, 1, 1, -opt, &init, x_modified, y_modified, zops, zp, nx, ny,
utmp,
vtmp,
ctmp );
1298 PLINT *uu = (PLINT *) malloc( (
size_t)
NPTS *
sizeof (
PLINT ) );
1299 PLINT *vv = (PLINT *) malloc( (
size_t)
NPTS *
sizeof (
PLINT ) );
1304 if ( ( uu == NULL ) || ( vv == NULL ) )
1306 plexit(
"c_plot3dcl: Insufficient memory" );
1315 for ( i = 0; i < nx; i++ )
1317 for ( j = 0; j < ny; j++ )
1319 cgrid2.
xg[i][j] = x_modified[i];
1320 cgrid2.
yg[i][j] = y_modified[j];
1321 zstore[i][j] = getz( zp, i, j );
1329 clevel, nlevel,
pltr2, (
void *) &cgrid2, &cont );
1343 int cx, k, l, m, start, end;
1345 if ( cline->
npts > np )
1348 if ( ( ( uu = (PLINT *) realloc( uu, (
size_t) np *
sizeof ( PLINT ) ) ) == NULL ) ||
1349 ( ( vv = (PLINT *) realloc( vv, (
size_t) np *
sizeof ( PLINT ) ) ) == NULL ) )
1351 plexit(
"c_plot3dcl: Insufficient memory" );
1359 if ( cline->
npts > 0 )
1365 for ( j = i; j < cline->
npts; j++ )
1374 plnxtv( &uu[i], &vv[i], NULL, j - i, 0 );
1376 if ( j < cline->npts )
1379 for ( i = start; i < cline->
npts; i++ )
1389 for ( k = 0; k < ( end - start + 1 ) / 2; k++ )
1395 cline->
x[l] = cline->
x[m];
1396 cline->
y[l] = cline->
y[m];
1402 for ( j = start; j <= end; j++ )
1407 plnxtv( &uu[start], &vv[start], NULL, end - start + 1, 0 );
1409 cline->
x[end] = cline->
x[start];
1410 cline->
y[end] = cline->
y[start];
1413 }
while ( j < cline->npts && i < cline->npts );
1415 cline = cline->
next;
1417 while ( cline != NULL );
1420 while ( clev != NULL );
1431 plside3( x_modified, y_modified, zops, zp, nx, ny, opt );
1435 color = plsc->icol0;
1436 width = plsc->width;
1450 for ( i = 0; i < nx; i++ )
1570 PLFLT vx1, vx2, vy1, vy2, vz1, vz2;
1572 PLFLT vlx, vly, vlz;
1584 px = vy1 * vz2 - vz1 * vy2;
1585 py = vz1 * vx2 - vx1 * vz2;
1586 pz = vx1 * vy2 - vy1 * vx2;
1587 mag1 = px * px + py * py + pz * pz;
1596 mag2 = vlx * vlx + vly * vly + vlz * vlz;
1601 cosangle = fabs( ( vlx * px + vly * py + vlz * pz ) / sqrt( mag1 * mag2 ) );
1630 while ( 1 <= x0 && x0 <= nx && 1 <= y0 && y0 <= ny )
1632 x2d =
plP_w3wcx( x[x0 - 1], y[y0 - 1], getz( zp, x0 - 1, y0 - 1 ) );
1633 y2d =
plP_w3wcy( x[x0 - 1], y[y0 - 1], getz( zp, x0 - 1, y0 - 1 ) );
1667 if ( flag == 1 || flag == -2 )
1674 else if ( flag == -2 )
1679 if ( 1 <= x0 && x0 <= nx && 1 <= y0 && y0 <= ny )
1681 x2d =
plP_w3wcx( x[x0 - 1], y[y0 - 1], getz( zp, x0 - 1, y0 - 1 ) );
1682 y2d =
plP_w3wcy( x[x0 - 1], y[y0 - 1], getz( zp, x0 - 1, y0 - 1 ) );
1693 plnxtv( u, v, c, n, *init );
1708 PLFLT cxx, cxy, cyx, cyy, cyz;
1709 PLFLT xmin, ymin, zmin, xmax, ymax, zmax, zscale;
1710 PLFLT tx, ty, ux, uy;
1713 plP_gw3wc( &cxx, &cxy, &cyx, &cyy, &cyz );
1714 plP_gdom( &xmin, &xmax, &ymin, &ymax );
1719 if ( cxx >= 0.0 && cxy <= 0.0 )
1723 for ( i = 0; i < nx; i++ )
1727 ux =
plP_w3wcx( x[i], y[0], getz( zp, i, 0 ) );
1728 uy =
plP_w3wcy( x[i], y[0], getz( zp, i, 0 ) );
1729 pljoin( tx, ty, ux, uy );
1734 for ( i = 0; i < ny; i++ )
1738 ux =
plP_w3wcx( x[0], y[i], getz( zp, 0, i ) );
1739 uy =
plP_w3wcy( x[0], y[i], getz( zp, 0, i ) );
1740 pljoin( tx, ty, ux, uy );
1744 else if ( cxx <= 0.0 && cxy <= 0.0 )
1748 for ( i = 0; i < nx; i++ )
1750 tx =
plP_w3wcx( x[i], y[ny - 1], zmin );
1751 ty =
plP_w3wcy( x[i], y[ny - 1], zmin );
1752 ux =
plP_w3wcx( x[i], y[ny - 1], getz( zp, i, ny - 1 ) );
1753 uy =
plP_w3wcy( x[i], y[ny - 1], getz( zp, i, ny - 1 ) );
1754 pljoin( tx, ty, ux, uy );
1759 for ( i = 0; i < ny; i++ )
1763 ux =
plP_w3wcx( x[0], y[i], getz( zp, 0, i ) );
1764 uy =
plP_w3wcy( x[0], y[i], getz( zp, 0, i ) );
1765 pljoin( tx, ty, ux, uy );
1769 else if ( cxx <= 0.0 && cxy >= 0.0 )
1773 for ( i = 0; i < nx; i++ )
1775 tx =
plP_w3wcx( x[i], y[ny - 1], zmin );
1776 ty =
plP_w3wcy( x[i], y[ny - 1], zmin );
1777 ux =
plP_w3wcx( x[i], y[ny - 1], getz( zp, i, ny - 1 ) );
1778 uy =
plP_w3wcy( x[i], y[ny - 1], getz( zp, i, ny - 1 ) );
1779 pljoin( tx, ty, ux, uy );
1784 for ( i = 0; i < ny; i++ )
1786 tx =
plP_w3wcx( x[nx - 1], y[i], zmin );
1787 ty =
plP_w3wcy( x[nx - 1], y[i], zmin );
1788 ux =
plP_w3wcx( x[nx - 1], y[i], getz( zp, nx - 1, i ) );
1789 uy =
plP_w3wcy( x[nx - 1], y[i], getz( zp, nx - 1, i ) );
1790 pljoin( tx, ty, ux, uy );
1794 else if ( cxx >= 0.0 && cxy >= 0.0 )
1798 for ( i = 0; i < nx; i++ )
1802 ux =
plP_w3wcx( x[i], y[0], getz( zp, i, 0 ) );
1803 uy =
plP_w3wcy( x[i], y[0], getz( zp, i, 0 ) );
1804 pljoin( tx, ty, ux, uy );
1809 for ( i = 0; i < ny; i++ )
1811 tx =
plP_w3wcx( x[nx - 1], y[i], zmin );
1812 ty =
plP_w3wcy( x[nx - 1], y[i], zmin );
1813 ux =
plP_w3wcx( x[nx - 1], y[i], getz( zp, nx - 1, i ) );
1814 uy =
plP_w3wcy( x[nx - 1], y[i], getz( zp, nx - 1, i ) );
1815 pljoin( tx, ty, ux, uy );
1831 PLFLT xmin, ymin, zmin, xmax, ymax, zmax, zscale;
1832 PLFLT cxx, cxy, cyx, cyy, cyz, zmin_in, zmax_in;
1837 plP_gw3wc( &cxx, &cxy, &cyx, &cyy, &cyz );
1838 plP_gdom( &xmin, &xmax, &ymin, &ymax );
1840 zmin = ( zmax_in > zmin_in ) ? zmin_in : zmax_in;
1841 zmax = ( zmax_in > zmin_in ) ? zmax_in : zmin_in;
1844 tp = tick * floor( zmin / tick ) + tick;
1847 if ( cxx >= 0.0 && cxy <= 0.0 )
1849 while ( tp <= zmax )
1867 else if ( cxx <= 0.0 && cxy <= 0.0 )
1869 while ( tp <= zmax )
1887 else if ( cxx <= 0.0 && cxy >= 0.0 )
1889 while ( tp <= zmax )
1907 else if ( cxx >= 0.0 && cxy >= 0.0 )
1909 while ( tp <= zmax )
1972 myexit(
"plnxtvhi: Out of memory." );
1977 for ( i = 1; i < n; i++ )
2016 myexit(
"plnxtvhi: Out of memory." );
2037 PLINT i = 0, j = 0, first = 1;
2038 PLINT sx1 = 0, sx2 = 0, sy1 = 0, sy2 = 0;
2039 PLINT su1, su2, sv1, sv2;
2040 PLINT cx, cy, px, py;
2041 PLINT seg, ptold, lstold = 0, pthi, pnewhi = 0, newhi, change, ochange = 0;
2054 while ( i <
mhi || j < n )
2065 ptold = ( j >= n || ( i <
mhi &&
oldhiview[2 * i] < u[j] ) );
2070 seg = j > 0 && j < n;
2083 seg = i > 0 && i <
mhi;
2100 pthi =
plabv( px, py, sx1, sy1, sx2, sy2 );
2104 newhi = ( ptold && !pthi ) || ( !ptold && pthi );
2109 change = ( newhi && !pnewhi ) || ( !newhi && pnewhi );
2130 if (
pl3upv == 0 && ( ( !ptold && j == 0 ) || ( ptold && i == 0 ) ) )
2138 ( ( !ptold && i >=
mhi ) || ( ptold && j >= n ) ) )
2159 else if ( i >=
mhi )
2198 pl3cut( sx1, sy1, sx2, sy2, su1, sv1, su2, sv2, &cx, &cy );
2199 if ( cx == px && cy == py )
2201 if ( lstold && !ochange )
2212 if ( lstold && !ochange )
2228 if ( lstold && ptold )
2275 PLINT sx1 = 0, sx2 = 0, sy1 = 0, sy2 = 0;
2276 PLINT su1, su2, sv1, sv2;
2277 PLINT cx, cy, px, py;
2278 PLINT seg, ptold, lstold = 0, ptlo, pnewlo, newlo, change, ochange = 0;
2291 myexit(
"\nplnxtvlo: Out of memory." );
2296 for ( i = 1; i < n; i++ )
2337 myexit(
"plnxtvlo: Out of memory." );
2344 while ( i <
mlo || j < n )
2354 ptold = ( j >= n || ( i <
mlo &&
oldloview[2 * i] < u[j] ) );
2359 seg = j > 0 && j < n;
2372 seg = i > 0 && i <
mlo;
2389 ptlo = !
plabv( px, py, sx1, sy1, sx2, sy2 );
2393 newlo = ( ptold && !ptlo ) || ( !ptold && ptlo );
2394 change = ( newlo && !pnewlo ) || ( !newlo && pnewlo );
2415 if (
pl3upv == 0 && ( ( !ptold && j == 0 ) || ( ptold && i == 0 ) ) )
2423 ( ( !ptold && i >=
mlo ) || ( ptold && j >= n ) ) )
2445 else if ( i >=
mlo )
2484 pl3cut( sx1, sy1, sx2, sy2, su1, sv1, su2, sv2, &cx, &cy );
2485 if ( cx == px && cy == py )
2487 if ( lstold && !ochange )
2498 if ( lstold && !ochange )
2514 if ( lstold && ptold )
2557 myexit(
"savehipoint: Out of memory." );
2578 myexit(
"savelopoint: Out of memory." );
2680 if ( py >= sy1 && py >= sy2 )
2682 else if ( py < sy1 && py < sy2 )
2684 else if ( (
double) ( sx2 - sx1 ) * ( py - sy1 ) >=
2685 (
double) ( px - sx1 ) * ( sy2 - sy1 ) )
2704 PLINT x21, y21, u21, v21, yv1, xu1, a, b;
2714 a = x21 * v21 - y21 * u21;
2732 b = yv1 * u21 - xu1 * v21;
2734 *cx = (
PLINT) ( sx1 + ( fb * x21 ) / fa + .5 );
2735 *cy = (
PLINT) ( sy1 + ( fb * y21 ) / fa + .5 );
2770 *stride = sqrt( xFormMatrix[0] * xFormMatrix[0] + xFormMatrix[2] * xFormMatrix[2] );
2773 *rotation = atan2( xFormMatrix[2], xFormMatrix[0] );
2776 smr = atan2( xFormMatrix[1], xFormMatrix[3] );
2779 *shear = smr + *rotation;
2784 else if ( *shear >
PI )
static PLFLT plGetAngleToLight(PLFLT *x, PLFLT *y, PLFLT *z)
static void plnxtv(PLINT *, PLINT *, PLFLT *, PLINT, PLINT)
static void savelopoint(PLINT, PLINT)
static int plabv(PLINT, PLINT, PLINT, PLINT, PLINT, PLINT)
void plexit(PLCHAR_VECTOR errormsg)
void c_plmeshc(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
static void shade_triangle(PLFLT x0, PLFLT y0, PLFLT z0, PLFLT x1, PLFLT y1, PLFLT z1, PLFLT x2, PLFLT y2, PLFLT z2)
PLFLT(* get)(PLPointer p, PLINT ix, PLINT iy)
void plfmesh(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt)
void c_plot3dcl(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel, PLINT indexxmin, PLINT indexxmax, PLINT_VECTOR indexymin, PLINT_VECTOR indexymax)
static void swaploview(void)
const PLFLT *const * PLFLT_MATRIX
void c_plsurf3d(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
void plP_grange(PLFLT *p_zscl, PLFLT *p_zmin, PLFLT *p_zmax)
const char * PLCHAR_VECTOR
static void savehipoint(PLINT, PLINT)
static void plt3zz(PLINT x0, PLINT y0, PLINT dx, PLINT dy, PLINT flag, PLINT *init, PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT *u, PLINT *v, PLFLT *c)
void c_plot3dc(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
static void swaphiview(void)
void c_plot3d(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLBOOL side)
void c_plsurf3dl(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel, PLINT indexxmin, PLINT indexxmax, PLINT_VECTOR indexymin, PLINT_VECTOR indexymax)
void plabort(PLCHAR_VECTOR errormsg)
static void myexit(PLCHAR_VECTOR)
void c_plmesh(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_MATRIX z, PLINT nx, PLINT ny, PLINT opt)
static void plnxtvlo(PLINT *, PLINT *, PLFLT *, PLINT, PLINT)
void pldtik(PLFLT vmin, PLFLT vmax, PLFLT *tick, PLINT *nsubt, PLBOOL ld)
void plfplot3dc(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
int plP_clip_poly(int Ni, PLFLT *Vi[3], int axis, PLFLT dir, PLFLT offset)
static void plP_draw3d(PLINT x, PLINT y, PLFLT *c, PLINT j, PLINT move)
void plfplot3d(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLBOOL side)
void plP_gzback(PLINT **zbf, PLINT **zbc, PLFLT **zbt, PLFLT **zbw)
void plfsurf3d(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
void c_pllightsource(PLFLT x, PLFLT y, PLFLT z)
void plfplot3dcl(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel, PLINT PL_UNUSED(indexxmin), PLINT PL_UNUSED(indexxmax), PLINT_VECTOR PL_UNUSED(indexymin), PLINT_VECTOR PL_UNUSED(indexymax))
void plFree2dGrid(PLFLT **f, PLINT nx, PLINT PL_UNUSED(ny))
static void plnxtvhi(PLINT *, PLINT *, PLFLT *, PLINT, PLINT)
const PLINT * PLINT_VECTOR
static void plnxtvhi_draw(PLINT *u, PLINT *v, PLFLT *c, PLINT n)
PLFLT plP_w3wcy(PLFLT x, PLFLT y, PLFLT z)
void plfsurf3dl(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel, PLINT indexxmin, PLINT indexxmax, PLINT_VECTOR indexymin, PLINT_VECTOR indexymax)
static void pl3cut(PLINT, PLINT, PLINT, PLINT, PLINT, PLINT, PLINT, PLINT, PLINT *, PLINT *)
static void myabort(PLCHAR_VECTOR)
void plRotationShear(PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride)
void plP_draphy(PLINT x, PLINT y)
void plP_fill(short *x, short *y, PLINT npts)
PLFLT plP_w3wcx(PLFLT x, PLFLT y, PLFLT PL_UNUSED(z))
void cont_clean_store(CONT_LEVEL *ct)
void plP_movphy(PLINT x, PLINT y)
void plAlloc2dGrid(PLFLT ***f, PLINT nx, PLINT ny)
void plP_gw3wc(PLFLT *p_dxx, PLFLT *p_dxy, PLFLT *p_dyx, PLFLT *p_dyy, PLFLT *p_dyz)
static void freework(void)
void plwarn(PLCHAR_VECTOR errormsg)
static void plgrid3(PLFLT)
void cont_store(PLFLT_MATRIX f, PLINT nx, PLINT ny, PLINT kx, PLINT lx, PLINT ky, PLINT ly, PLFLT_VECTOR clevel, PLINT nlevel, PLTRANSFORM_callback pltr, PLPointer pltr_data, CONT_LEVEL **contour)
static void plside3(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt)
void plfmeshc(PLFLT_VECTOR x, PLFLT_VECTOR y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, PLFLT_VECTOR clevel, PLINT nlevel)
const PLFLT * PLFLT_VECTOR
void plP_gdom(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)