187 cout <<
"D2VEC_PART_QUICK_A - Fatal error!\n";
208 for ( i = 2; i <= n; i++ )
210 if (
dvec_gt ( 2, a+2*ll, key ) )
215 else if (
dvec_eq ( 2, a+2*ll, key ) )
221 else if (
dvec_lt ( 2, a+2*ll, key ) )
230 for ( i = 0; i < ll - m; i++ )
232 for ( j = 0; j < 2; j++ )
234 a[2*i+j] = a[2*(i+m)+j];
240 for ( i = ll; i < ll+m; i++ )
242 for ( j = 0; j < 2; j++ )
316 cout <<
"D2VEC_PERMUTE - Fatal error!\n";
317 cout <<
" The input array does not represent\n";
318 cout <<
" a proper permutation.\n";
324 for ( istart = 1; istart <= n; istart++ )
326 if ( p[istart-1] < 0 )
330 else if ( p[istart-1] == istart )
332 p[istart-1] = -p[istart-1];
337 a_temp[0] = a[0+(istart-1)*2];
338 a_temp[1] = a[1+(istart-1)*2];
348 p[iput-1] = -p[iput-1];
350 if ( iget < 1 || n < iget )
353 cout <<
"D2VEC_PERMUTE - Fatal error!\n";
357 if ( iget == istart )
359 a[0+(iput-1)*2] = a_temp[0];
360 a[1+(iput-1)*2] = a_temp[1];
363 a[0+(iput-1)*2] = a[0+(iget-1)*2];
364 a[1+(iput-1)*2] = a[1+(iget-1)*2];
371 for ( i = 0; i < n; i++ )
455 aval[0] = a[0+(indxt-1)*2];
456 aval[1] = a[1+(indxt-1)*2];
461 aval[0] = a[0+(indxt-1)*2];
462 aval[1] = a[1+(indxt-1)*2];
463 indx[ir-1] = indx[0];
481 if ( a[0+(indx[j-1]-1)*2] < a[0+(indx[j]-1)*2] ||
482 ( a[0+(indx[j-1]-1)*2] == a[0+(indx[j]-1)*2] &&
483 a[1+(indx[j-1]-1)*2] < a[1+(indx[j]-1)*2] ) )
489 if ( aval[0] < a[0+(indx[j-1]-1)*2] ||
490 ( aval[0] == a[0+(indx[j-1]-1)*2] &&
491 aval[1] < a[1+(indx[j-1]-1)*2] ) )
493 indx[i-1] = indx[j-1];
539 # define LEVEL_MAX 25
551 cout <<
"D2VEC_SORT_QUICK_A - Fatal error!\n";
562 rsave[level-1] = n + 1;
566 while ( 0 < n_segment )
580 cout <<
"D2VEC_SORT_QUICK_A - Fatal error!\n";
581 cout <<
" Exceeding recursion maximum of " <<
LEVEL_MAX <<
"\n";
586 n_segment = l_segment;
587 rsave[level-1] = r_segment + base - 1;
593 else if ( r_segment < n_segment )
595 n_segment = n_segment + 1 - r_segment;
596 base = base + r_segment - 1;
611 base = rsave[level-1];
612 n_segment = rsave[level-2] - rsave[level-1];
627 int diaedg (
double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
628 double x3,
double y3 )
700 tola = tol *
d_max ( fabs ( dx10 ),
701 d_max ( fabs ( dy10 ),
702 d_max ( fabs ( dx30 ), fabs ( dy30 ) ) ) );
704 tolb = tol *
d_max ( fabs ( dx12 ),
705 d_max ( fabs ( dy12 ),
706 d_max ( fabs ( dx32 ), fabs ( dy32 ) ) ) );
708 ca = dx10 * dx30 + dy10 * dy30;
709 cb = dx12 * dx32 + dy12 * dy32;
711 if ( tola < ca && tolb < cb )
715 else if ( ca < -tola && cb < -tolb )
721 tola =
d_max ( tola, tolb );
722 s = ( dx10 * dy30 - dx30 * dy10 ) * cb
723 + ( dx32 * dy12 - dx12 * dy32 ) * ca;
729 else if ( s < -tola )
776 int ihi,
int jhi,
const char *title )
819 cout << title <<
"\n";
822 for ( i2lo =
i_max ( ilo, 1 ); i2lo <=
i_min ( ihi, m ); i2lo = i2lo +
INCX )
824 i2hi = i2lo +
INCX - 1;
825 i2hi =
i_min ( i2hi, m );
826 i2hi =
i_min ( i2hi, ihi );
828 inc = i2hi + 1 - i2lo;
832 for ( i = i2lo; i <= i2hi; i++ )
834 cout <<
setw(7) << i <<
" ";
840 j2lo =
i_max ( jlo, 1 );
841 j2hi =
i_min ( jhi, n );
843 for ( j = j2lo; j <= j2hi; j++ )
845 cout <<
setw(5) << j <<
" ";
846 for ( i2 = 1; i2 <= inc; i2++ )
849 cout <<
setw(14) << a[(i-1)+(j-1)*m];
861 void dmat_uniform (
int m,
int n,
double b,
double c,
int *seed,
double r[] )
923 for ( j = 0; j < n; j++ )
925 for ( i = 0; i < m; i++ )
929 *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
933 *seed = *seed + 2147483647;
939 r[i+j*m] = b + ( c -
b ) *
double( *seed ) * 4.656612875E-10;
947 int dtris2 (
int point_num,
double point_xy[],
int *tri_num,
948 int tri_vert[],
int tri_nabe[] )
1027 stack =
new int[point_num];
1041 for ( i = 2; i <= point_num; i++ )
1048 for ( j = 0; j <= 1; j++ )
1050 cmax =
d_max ( fabs ( point_xy[2*(m-1)+j] ),
1051 fabs ( point_xy[2*(m1-1)+j] ) );
1053 if ( tol * ( cmax + 1.0 )
1054 < fabs ( point_xy[2*(m-1)+j] - point_xy[2*(m1-1)+j] ) )
1065 cout <<
"DTRIS2 - Fatal error!\n";
1066 cout <<
" Fails for point number I = " << i <<
"\n";
1067 cout <<
" M = " << m <<
"\n";
1068 cout <<
" M1 = " << m1 <<
"\n";
1069 cout <<
" X,Y(M) = " << point_xy[2*(m-1)+0] <<
" "
1070 << point_xy[2*(m-1)+1] <<
"\n";
1071 cout <<
" X,Y(M1) = " << point_xy[2*(m1-1)+0] <<
" "
1072 << point_xy[2*(m1-1)+1] <<
"\n";
1088 if ( point_num < j )
1091 cout <<
"DTRIS2 - Fatal error!\n";
1098 lr =
lrline ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1],
1099 point_xy[2*(m1-1)+0], point_xy[2*(m1-1)+1],
1100 point_xy[2*(m2-1)+0], point_xy[2*(m2-1)+1], 0.0 );
1118 tri_vert[3*0+0] = m1;
1119 tri_vert[3*0+1] = m2;
1120 tri_vert[3*0+2] = m;
1121 tri_nabe[3*0+2] = -3;
1123 for ( i = 2; i <= *tri_num; i++ )
1127 tri_vert[3*(i-1)+0] = m1;
1128 tri_vert[3*(i-1)+1] = m2;
1129 tri_vert[3*(i-1)+2] = m;
1130 tri_nabe[3*(i-1)+0] = -3 * i;
1131 tri_nabe[3*(i-1)+1] = i;
1132 tri_nabe[3*(i-1)+2] = i - 1;
1136 tri_nabe[3*(*tri_num-1)+0] = -3 * (*tri_num) - 1;
1137 tri_nabe[3*(*tri_num-1)+1] = -5;
1143 tri_vert[3*0+0] = m2;
1144 tri_vert[3*0+1] = m1;
1145 tri_vert[3*0+2] = m;
1146 tri_nabe[3*0+0] = -4;
1148 for ( i = 2; i <= *tri_num; i++ )
1152 tri_vert[3*(i-1)+0] = m2;
1153 tri_vert[3*(i-1)+1] = m1;
1154 tri_vert[3*(i-1)+2] = m;
1155 tri_nabe[3*(i-2)+2] = i;
1156 tri_nabe[3*(i-1)+0] = -3 * i - 3;
1157 tri_nabe[3*(i-1)+1] = i - 1;
1160 tri_nabe[3*(*tri_num-1)+2] = -3 * (*tri_num);
1161 tri_nabe[3*0+1] = -3 * (*tri_num) - 2;
1172 for ( i = j+1; i <= point_num; i++ )
1175 m1 = tri_vert[3*(ltri-1)+ledg-1];
1179 m2 = tri_vert[3*(ltri-1)+ledg];
1183 m2 = tri_vert[3*(ltri-1)+0];
1186 lr =
lrline ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1],
1187 point_xy[2*(m1-1)+0], point_xy[2*(m1-1)+1],
1188 point_xy[2*(m2-1)+0], point_xy[2*(m2-1)+1], 0.0 );
1198 l = -tri_nabe[3*(ltri-1)+ledg-1];
1203 vbedg ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1], point_num,
1204 point_xy, *tri_num, tri_vert, tri_nabe, <ri, &ledg, &rtri, &redg );
1207 l = -tri_nabe[3*(ltri-1)+ledg-1];
1213 l = -tri_nabe[3*(t-1)+e-1];
1214 m2 = tri_vert[3*(t-1)+e-1];
1218 m1 = tri_vert[3*(t-1)+e];
1222 m1 = tri_vert[3*(t-1)+0];
1225 *tri_num = *tri_num + 1;
1226 tri_nabe[3*(t-1)+e-1] = *tri_num;
1227 tri_vert[3*(*tri_num-1)+0] = m1;
1228 tri_vert[3*(*tri_num-1)+1] = m2;
1229 tri_vert[3*(*tri_num-1)+2] = m;
1230 tri_nabe[3*(*tri_num-1)+0] = t;
1231 tri_nabe[3*(*tri_num-1)+1] = *tri_num - 1;
1232 tri_nabe[3*(*tri_num-1)+2] = *tri_num + 1;
1235 if ( point_num < top )
1238 cout <<
"DTRIS2 - Fatal error!\n";
1239 cout <<
" Stack overflow.\n";
1244 stack[top-1] = *tri_num;
1246 if ( t == rtri && e == redg )
1253 tri_nabe[3*(ltri-1)+ledg-1] = -3 * n - 1;
1254 tri_nabe[3*(n-1)+1] = -3 * (*tri_num) - 2;
1255 tri_nabe[3*(*tri_num-1)+2] = -l;
1259 error =
swapec ( m, &top, <ri, &ledg, point_num, point_xy, *tri_num,
1260 tri_vert, tri_nabe, stack );
1265 cout <<
"DTRIS2 - Fatal error!\n";
1266 cout <<
" Error return from SWAPEC.\n";
1275 for ( i = 0; i < 3; i++ )
1277 for ( j = 0; j < *tri_num; j++ )
1279 tri_vert[i+j*3] = indx [ tri_vert[i+j*3] - 1 ];
1323 for ( i = 0; i < n; i++ )
1325 if ( a1[i] != a2[i] )
1371 for ( i = 0; i < n; i++ )
1374 if ( a2[i] < a1[i] )
1378 else if ( a1[i] < a2[i] )
1425 for ( i = 0; i < n; i++ )
1427 if ( a1[i] < a2[i] )
1431 else if ( a2[i] < a1[i] )
1473 cout << title <<
"\n";
1477 for ( i = 0; i <= n-1; i++ )
1479 cout <<
setw(6) << i + 1 <<
" "
1480 <<
setw(14) << a[i] <<
"\n";
1513 for ( i = 0; i < n; i++ )
1653 cout <<
"I_MODP - Fatal error!\n";
1654 cout <<
" I_MODP ( I, J ) called with J = " << j <<
"\n";
1662 value = value + abs ( j );
1762 jlo =
i_min ( ilo, ihi );
1763 jhi =
i_max ( ilo, ihi );
1765 wide = jhi + 1 - jlo;
1773 value = jlo +
i_modp ( ival - jlo, wide );
1814 int ihi,
int jhi,
const char *title )
1857 cout << title <<
"\n";
1862 for ( i2lo = ilo; i2lo <= ihi; i2lo = i2lo +
INCX )
1864 i2hi = i2lo +
INCX - 1;
1865 i2hi =
i_min ( i2hi, m );
1866 i2hi =
i_min ( i2hi, ihi );
1875 for ( i = i2lo; i <= i2hi; i++ )
1877 cout <<
setw(7) << i <<
" ";
1885 j2lo =
i_max ( jlo, 1 );
1886 j2hi =
i_min ( jhi, n );
1888 for ( j = j2lo; j <= j2hi; j++ )
1893 cout <<
setw(5) << j <<
" ";
1894 for ( i = i2lo; i <= i2hi; i++ )
1896 cout <<
setw(6) << a[i-1+(j-1)*m] <<
" ";
1965 for ( i = (n/2)-1; 0 <= i; i-- )
1999 if ( a[m] < a[m+1] )
2062 for ( i = 0; i < n; i++ )
2126 for ( n1 = n-1; 2 <= n1; n1-- )
2182 for ( i = 1; i < n; i++ )
2184 if ( a[i] != a[*nuniq] )
2186 *nuniq = *nuniq + 1;
2196 int lrline (
double xu,
double yu,
double xv1,
double yv1,
double xv2,
2197 double yv2,
double dv )
2248 double tol = 0.0000001;
2257 tolabs = tol *
d_max ( fabs ( dx ),
2258 d_max ( fabs ( dy ),
2259 d_max ( fabs ( dxu ),
2260 d_max ( fabs ( dyu ), fabs ( dv ) ) ) ) );
2262 t = dy * dxu - dx * dyu + dv *
sqrt ( dx * dx + dy * dy );
2268 else if ( -tolabs <= t )
2272 else if ( t < -tolabs )
2315 for ( seek = 1; seek <= n; seek++ )
2319 for ( i = 0; i < n; i++ )
2368 cout <<
"PERM_INV - Fatal error!\n";
2369 cout <<
" Input value of N = " << n <<
"\n";
2376 cout <<
"PERM_INV - Fatal error!\n";
2377 cout <<
" The input array does not represent\n";
2378 cout <<
" a proper permutation.\n";
2384 for ( i = 1; i <= n; i++ )
2395 is = -
i_sign ( p[i-1] );
2396 p[i-1] =
i_sign ( is ) * abs ( p[i-1] );
2399 for ( i = 1; i <= n; i++ )
2490 z =
new double [ n ];
2492 for ( i = 0; i < n; i++ )
2494 z[i] = p[0+i*2] * p[0+i*2] + p[1+i*2] * p[1+i*2];
2500 for ( pass = 1; pass <= 2; pass++ )
2504 tri =
new int[3*count];
2510 for ( i = 0; i < n - 2; i++ )
2512 for ( j = i+1; j < n; j++ )
2514 for ( k = i+1; k < n; k++ )
2518 xn = ( p[1+j*2] - p[1+i*2] ) * ( z[k] - z[i] )
2519 - ( p[1+k*2] - p[1+i*2] ) * ( z[j] - z[i] );
2520 yn = ( p[0+k*2] - p[0+i*2] ) * ( z[j] - z[i] )
2521 - ( p[0+j*2] - p[0+i*2] ) * ( z[k] - z[i] );
2522 zn = ( p[0+j*2] - p[0+i*2] ) * ( p[1+k*2] - p[1+i*2] )
2523 - ( p[0+k*2] - p[0+i*2] ) * ( p[1+j*2] - p[1+i*2] );
2529 for ( m = 0; m < n; m++ )
2531 flag = flag && ( ( p[0+m*2] - p[0+i*2] ) * xn
2532 + ( p[1+m*2] - p[1+i*2] ) * yn
2533 + ( z[m] - z[i] ) * zn <= 0 );
2589 t =
const_cast<char*
>(s) + n - 1;
2605 int swapec (
int i,
int *top,
int *btri,
int *bedg,
int point_num,
2606 double point_xy[],
int tri_num,
int tri_vert[],
int tri_nabe[],
2697 x = point_xy[2*(i-1)+0];
2698 y = point_xy[2*(i-1)+1];
2707 t = stack[(*top)-1];
2710 if ( tri_vert[3*(t-1)+0] == i )
2713 b = tri_vert[3*(t-1)+2];
2715 else if ( tri_vert[3*(t-1)+1] == i )
2718 b = tri_vert[3*(t-1)+0];
2723 b = tri_vert[3*(t-1)+1];
2726 a = tri_vert[3*(t-1)+e-1];
2727 u = tri_nabe[3*(t-1)+e-1];
2729 if ( tri_nabe[3*(u-1)+0] == t )
2732 c = tri_vert[3*(u-1)+2];
2734 else if ( tri_nabe[3*(u-1)+1] == t )
2737 c = tri_vert[3*(u-1)+0];
2742 c = tri_vert[3*(u-1)+1];
2746 point_xy[2*(a-1)+0], point_xy[2*(a-1)+1],
2747 point_xy[2*(c-1)+0], point_xy[2*(c-1)+1],
2748 point_xy[2*(b-1)+0], point_xy[2*(b-1)+1] );
2752 em1 =
i_wrap ( e - 1, 1, 3 );
2753 ep1 =
i_wrap ( e + 1, 1, 3 );
2754 fm1 =
i_wrap ( f - 1, 1, 3 );
2755 fp1 =
i_wrap ( f + 1, 1, 3 );
2757 tri_vert[3*(t-1)+ep1-1] = c;
2758 tri_vert[3*(u-1)+fp1-1] = i;
2759 r = tri_nabe[3*(t-1)+ep1-1];
2760 s = tri_nabe[3*(u-1)+fp1-1];
2761 tri_nabe[3*(t-1)+ep1-1] = u;
2762 tri_nabe[3*(u-1)+fp1-1] = t;
2763 tri_nabe[3*(t-1)+e-1] = s;
2764 tri_nabe[3*(u-1)+f-1] = r;
2766 if ( 0 < tri_nabe[3*(u-1)+fm1-1] )
2769 stack[(*top)-1] = u;
2774 if ( tri_nabe[3*(s-1)+0] == u )
2776 tri_nabe[3*(s-1)+0] = t;
2778 else if ( tri_nabe[3*(s-1)+1] == u )
2780 tri_nabe[3*(s-1)+1] = t;
2784 tri_nabe[3*(s-1)+2] = t;
2789 if ( point_num < *top )
2794 stack[(*top)-1] = t;
2798 if ( u == *btri && fp1 == *bedg )
2804 l = - ( 3 * t + e - 1 );
2808 while ( 0 < tri_nabe[3*(tt-1)+ee-1] )
2810 tt = tri_nabe[3*(tt-1)+ee-1];
2812 if ( tri_vert[3*(tt-1)+0] == a )
2816 else if ( tri_vert[3*(tt-1)+1] == a )
2827 tri_nabe[3*(tt-1)+ee-1] = l;
2833 if ( tri_nabe[3*(r-1)+0] == t )
2835 tri_nabe[3*(r-1)+0] = u;
2837 else if ( tri_nabe[3*(r-1)+1] == t )
2839 tri_nabe[3*(r-1)+1] = u;
2843 tri_nabe[3*(r-1)+2] = u;
2848 if ( t == *btri && ep1 == *bedg )
2854 l = - ( 3 * u + f - 1 );
2858 while ( 0 < tri_nabe[3*(tt-1)+ee-1] )
2860 tt = tri_nabe[3*(tt-1)+ee-1];
2862 if ( tri_vert[3*(tt-1)+0] ==
b )
2866 else if ( tri_vert[3*(tt-1)+1] ==
b )
2875 tri_nabe[3*(tt-1)+ee-1] = l;
2908 # define TIME_SIZE 29
2911 const struct tm *tm;
2915 now = time ( NULL );
2916 tm = localtime ( &now );
2918 len = strftime ( time_buffer,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
2922 cout << time_buffer <<
"\n";
2955 # define TIME_SIZE 29
2957 const struct tm *tm;
2962 now = time ( NULL );
2963 tm = localtime ( &now );
2967 len = strftime ( s,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
3025 asq = ( t[0+1*2] - t[0+0*2] ) * ( t[0+1*2] - t[0+0*2] )
3026 + ( t[1+1*2] - t[1+0*2] ) * ( t[1+1*2] - t[1+0*2] );
3028 csq = ( t[0+2*2] - t[0+0*2] ) * ( t[0+2*2] - t[0+0*2] )
3029 + ( t[1+2*2] - t[1+0*2] ) * ( t[1+2*2] - t[1+0*2] );
3031 top1 = ( t[1+1*2] - t[1+0*2] ) * csq - ( t[1+2*2] - t[1+0*2] ) * asq;
3032 top2 = ( t[0+1*2] - t[0+0*2] ) * csq - ( t[0+2*2] - t[0+0*2] ) * asq;
3034 bot = ( t[1+1*2] - t[1+0*2] ) * ( t[0+2*2] - t[0+0*2] )
3035 - ( t[1+2*2] - t[1+0*2] ) * ( t[0+1*2] - t[0+0*2] );
3037 center[0] = t[0+0*2] + 0.5 * top1 / bot;
3038 center[1] = t[1+0*2] + 0.5 * top2 / bot;
3047 int tri_num,
int nod_tri[] )
3098 int x_ps_max_clip = 594;
3100 int x_ps_min_clip = 18;
3105 int y_ps_max_clip = 684;
3107 int y_ps_min_clip = 108;
3111 x_max = g_xy[0+0*2];
3112 x_min = g_xy[0+0*2];
3113 y_max = g_xy[1+0*2];
3114 y_min = g_xy[1+0*2];
3116 for ( g = 0; g < g_num; g++ )
3118 x_max =
d_max ( x_max, g_xy[0+g*2] );
3119 x_min =
d_min ( x_min, g_xy[0+g*2] );
3120 y_max =
d_max ( y_max, g_xy[1+g*2] );
3121 y_min =
d_min ( y_min, g_xy[1+g*2] );
3129 file_out.open ( file_out_name );
3134 cout <<
"TRIANGULATION_PLOT_EPS - Fatal error!\n";
3135 cout <<
" Cannot open the output file \"" << file_out_name <<
"\".\n";
3139 file_out <<
"%!PS-Adobe-3.0 EPSF-3.0\n";
3140 file_out <<
"%%Creator: triangulation_plot_eps.cc\n";
3141 file_out <<
"%%Title: " << file_out_name <<
"\n";
3142 file_out <<
"%%CreationDate: " << date_time <<
"\n";
3143 file_out <<
"%%Pages: 1\n";
3144 file_out <<
"%%Bounding Box: " << x_ps_min <<
" " << y_ps_min <<
" "
3145 << x_ps_max <<
" " << y_ps_max <<
"\n";
3146 file_out <<
"%%Document-Fonts: Times-Roman\n";
3147 file_out <<
"%%LanguageLevel: 1\n";
3148 file_out <<
"%%EndComments\n";
3149 file_out <<
"%%BeginProlog\n";
3150 file_out <<
"/inch {72 mul} def\n";
3151 file_out <<
"%%EndProlog\n";
3152 file_out <<
"%%Page: 1 1\n";
3153 file_out <<
"save\n";
3155 file_out <<
"% Set the RGB line color to very light gray.\n";
3157 file_out <<
"0.900 0.900 0.900 setrgbcolor\n";
3159 file_out <<
"% Draw a gray border around the page.\n";
3161 file_out <<
"newpath\n";
3162 file_out <<
" " << x_ps_min <<
" " << y_ps_min <<
" moveto\n";
3163 file_out <<
" " << x_ps_max <<
" " << y_ps_min <<
" lineto\n";
3164 file_out <<
" " << x_ps_max <<
" " << y_ps_max <<
" lineto\n";
3165 file_out <<
" " << x_ps_min <<
" " << y_ps_max <<
" lineto\n";
3166 file_out <<
" " << x_ps_min <<
" " << y_ps_min <<
" lineto\n";
3167 file_out <<
"stroke\n";
3169 file_out <<
"% Set the RGB line color to black.\n";
3171 file_out <<
"0.000 0.000 0.000 setrgbcolor\n";
3173 file_out <<
"% Set the font and its size.\n";
3175 file_out <<
"/Times-Roman findfont\n";
3176 file_out <<
"0.50 inch scalefont\n";
3177 file_out <<
"setfont\n";
3179 file_out <<
"% Print a title.\n";
3181 file_out <<
"210 702 moveto\n";
3182 file_out <<
"(Triangulation) show\n";
3184 file_out <<
"% Define a clipping polygon.\n";
3186 file_out <<
"newpath\n";
3187 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_min_clip <<
" moveto\n";
3188 file_out <<
" " << x_ps_max_clip <<
" " << y_ps_min_clip <<
" lineto\n";
3189 file_out <<
" " << x_ps_max_clip <<
" " << y_ps_max_clip <<
" lineto\n";
3190 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_max_clip <<
" lineto\n";
3191 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_min_clip <<
" lineto\n";
3192 file_out <<
"clip newpath\n";
3194 file_out <<
"% Set the RGB line color to green.\n";
3196 file_out <<
"0.000 0.750 0.150 setrgbcolor\n";
3198 file_out <<
"% Draw the nodes.\n";
3201 for ( g = 0; g < g_num; g++ )
3204 ( ( x_max - g_xy[0+g*2] ) *
double( x_ps_min )
3205 + ( g_xy[0+g*2] - x_min ) *
double( x_ps_max ) )
3206 / ( x_max - x_min ) );
3209 ( ( y_max - g_xy[1+g*2] ) *
double( y_ps_min )
3210 + ( g_xy[1+g*2] - y_min ) *
double( y_ps_max ) )
3211 / ( y_max - y_min ) );
3213 file_out <<
"newpath " << x_ps <<
" "
3214 << y_ps <<
" 5 0 360 arc closepath fill\n";
3218 file_out <<
"% Set the RGB line color to red.\n";
3220 file_out <<
"0.900 0.200 0.100 setrgbcolor\n";
3222 file_out <<
"% Draw the triangles.\n";
3225 for ( t = 1; t <= tri_num; t++ )
3227 file_out <<
"newpath\n";
3229 for ( j = 1; j <= 4; j++ )
3233 k = nod_tri[3*(t-1)+e-1];
3236 ( ( x_max - g_xy[0+(k-1)*2] ) *
double( x_ps_min )
3237 + ( g_xy[0+(k-1)*2] - x_min ) *
double( x_ps_max ) )
3238 / ( x_max - x_min ) );
3241 ( ( y_max - g_xy[1+(k-1)*2] ) *
double( y_ps_min )
3242 + ( g_xy[1+(k-1)*2] - y_min ) *
double( y_ps_max ) )
3243 / ( y_max - y_min ) );
3247 file_out << x_ps <<
" " << y_ps <<
" moveto\n";
3251 file_out << x_ps <<
" " << y_ps <<
" lineto\n";
3256 file_out <<
"stroke\n";
3260 file_out <<
"restore showpage\n";
3262 file_out <<
"% End of page.\n";
3264 file_out <<
"%%Trailer\n";
3265 file_out <<
"%%EOF\n";
3274 int tri_vert[],
int tri_nabe[] )
3335 cout <<
"TRIANGULATION_PRINT\n";
3336 cout <<
" Information defining a triangulation.\n";
3338 cout <<
" The number of points is " << point_num <<
"\n";
3343 cout <<
" The number of triangles is " << tri_num <<
"\n";
3345 cout <<
" Sets of three points are used as vertices of\n";
3346 cout <<
" the triangles. For each triangle, the points\n";
3347 cout <<
" are listed in counterclockwise order.\n";
3352 cout <<
" On each side of a given triangle, there is either\n";
3353 cout <<
" another triangle, or a piece of the convex hull.\n";
3354 cout <<
" For each triangle, we list the indices of the three\n";
3355 cout <<
" neighbors, or (if negative) the codes of the\n";
3356 cout <<
" segments of the convex hull.\n";
3363 vertex_list =
new int[3*tri_num];
3366 for ( t = 0; t < tri_num; t++ )
3368 for ( s = 0; s < 3; s++ )
3370 vertex_list[
k] = tri_vert[s+t*3];
3379 delete [] vertex_list;
3383 boundary_num = 2 * vertex_num - tri_num - 2;
3386 cout <<
" The number of boundary points is " << boundary_num <<
"\n";
3388 cout <<
" The segments that make up the convex hull can be\n";
3389 cout <<
" determined from the negative entries of the triangle\n";
3390 cout <<
" neighbor list.\n";
3392 cout <<
" # Tri Side N1 N2\n";
3399 for ( i = 0; i < tri_num; i++ )
3401 for ( j = 0; j < 3; j++ )
3403 if ( tri_nabe[j+i*3] < 0 )
3405 s = -tri_nabe[j+i*3];
3408 if ( t < 1 || tri_num < t )
3411 cout <<
" Sorry, this data does not use the DTRIS2\n";
3412 cout <<
" convention for convex hull segments.\n";
3418 s2 =
i_wrap ( s1+1, 1, 3 );
3420 n1 = tri_vert[s1-1+(t-1)*3];
3421 n2 = tri_vert[s2-1+(t-1)*3];
3422 cout <<
setw(4) << k <<
" "
3423 <<
setw(4) << t <<
" "
3424 <<
setw(4) << s1 <<
" "
3425 <<
setw(4) << n1 <<
" "
3426 <<
setw(4) << n2 <<
"\n";
3443 void vbedg (
double x,
double y,
int point_num,
double point_xy[],
int tri_num,
3444 int tri_vert[],
int tri_nabe[],
int *ltri,
int *ledg,
int *rtri,
int *redg )
3537 l = -tri_nabe[3*((*rtri)-1)+(*redg)-1];
3540 a = tri_vert[3*(t-1)+e-1];
3544 b = tri_vert[3*(t-1)+e];
3548 b = tri_vert[3*(t-1)+0];
3551 ax = point_xy[2*(a-1)+0];
3552 ay = point_xy[2*(a-1)+1];
3554 bx = point_xy[2*(b-1)+0];
3555 by = point_xy[2*(b-1)+1];
3557 lr =
lrline ( x, y, ax, ay, bx, by, 0.0 );
3579 b = tri_vert[3*(t-1)+e-1];
3580 e =
i_wrap ( e-1, 1, 3 );
3582 while ( 0 < tri_nabe[3*(t-1)+e-1] )
3584 t = tri_nabe[3*(t-1)+e-1];
3586 if ( tri_vert[3*(t-1)+0] ==
b )
3590 else if ( tri_vert[3*(t-1)+1] ==
b )
3601 a = tri_vert[3*(t-1)+e-1];
3602 ax = point_xy[2*(a-1)+0];
3603 ay = point_xy[2*(a-1)+1];
3605 bx = point_xy[2*(b-1)+0];
3606 by = point_xy[2*(b-1)+1];
3608 lr =
lrline ( x, y, ax, ay, bx, by, 0.0 );