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++ )
456 aval[0] = a[0+(indxt-1)*2];
457 aval[1] = a[1+(indxt-1)*2];
462 aval[0] = a[0+(indxt-1)*2];
463 aval[1] = a[1+(indxt-1)*2];
464 indx[ir-1] = indx[0];
482 if ( a[0+(indx[j-1]-1)*2] < a[0+(indx[j]-1)*2] ||
483 ( a[0+(indx[j-1]-1)*2] == a[0+(indx[j]-1)*2] &&
484 a[1+(indx[j-1]-1)*2] < a[1+(indx[j]-1)*2] ) )
490 if ( aval[0] < a[0+(indx[j-1]-1)*2] ||
491 ( aval[0] == a[0+(indx[j-1]-1)*2] &&
492 aval[1] < a[1+(indx[j-1]-1)*2] ) )
494 indx[i-1] = indx[j-1];
540 # define LEVEL_MAX 25 552 cout <<
"D2VEC_SORT_QUICK_A - Fatal error!\n";
563 rsave[level-1] = n + 1;
567 while ( 0 < n_segment )
581 cout <<
"D2VEC_SORT_QUICK_A - Fatal error!\n";
582 cout <<
" Exceeding recursion maximum of " <<
LEVEL_MAX <<
"\n";
587 n_segment = l_segment;
588 rsave[level-1] = r_segment + base - 1;
594 else if ( r_segment < n_segment )
596 n_segment = n_segment + 1 - r_segment;
597 base = base + r_segment - 1;
612 base = rsave[level-1];
613 n_segment = rsave[level-2] - rsave[level-1];
628 int diaedg (
double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
629 double x3,
double y3 )
701 tola = tol *
d_max ( fabs ( dx10 ),
702 d_max ( fabs ( dy10 ),
703 d_max ( fabs ( dx30 ), fabs ( dy30 ) ) ) );
705 tolb = tol *
d_max ( fabs ( dx12 ),
706 d_max ( fabs ( dy12 ),
707 d_max ( fabs ( dx32 ), fabs ( dy32 ) ) ) );
709 ca = dx10 * dx30 + dy10 * dy30;
710 cb = dx12 * dx32 + dy12 * dy32;
712 if ( tola < ca && tolb < cb )
716 else if ( ca < -tola && cb < -tolb )
722 tola =
d_max ( tola, tolb );
723 s = ( dx10 * dy30 - dx30 * dy10 ) * cb
724 + ( dx32 * dy12 - dx12 * dy32 ) * ca;
730 else if ( s < -tola )
777 int ihi,
int jhi,
const char *title )
820 cout << title <<
"\n";
823 for ( i2lo =
i_max ( ilo, 1 ); i2lo <=
i_min ( ihi, m ); i2lo = i2lo +
INCX )
825 i2hi = i2lo +
INCX - 1;
826 i2hi =
i_min ( i2hi, m );
827 i2hi =
i_min ( i2hi, ihi );
829 inc = i2hi + 1 - i2lo;
833 for ( i = i2lo; i <= i2hi; i++ )
835 cout <<
setw(7) << i <<
" ";
841 j2lo =
i_max ( jlo, 1 );
842 j2hi =
i_min ( jhi, n );
844 for ( j = j2lo; j <= j2hi; j++ )
846 cout <<
setw(5) << j <<
" ";
847 for ( i2 = 1; i2 <= inc; i2++ )
850 cout <<
setw(14) << a[(i-1)+(j-1)*m];
925 for ( j = 0; j <
n; j++ )
927 for ( i = 0; i < m; i++ )
931 *seed = 16807 * ( *seed - k * 127773 ) - k * 2836;
935 *seed = *seed + 2147483647;
941 r[i+j*m] = b + ( c -
b ) *
double( *seed ) * 4.656612875E-10;
949 int dtris2 (
int point_num,
double point_xy[],
int *tri_num,
950 int tri_vert[],
int tri_nabe[] )
1030 stack =
new int[point_num];
1044 for ( i = 2; i <= point_num; i++ )
1051 for ( j = 0; j <= 1; j++ )
1053 cmax =
d_max ( fabs ( point_xy[2*(m-1)+j] ),
1054 fabs ( point_xy[2*(m1-1)+j] ) );
1056 if ( tol * ( cmax + 1.0 )
1057 < fabs ( point_xy[2*(m-1)+j] - point_xy[2*(m1-1)+j] ) )
1068 cout <<
"DTRIS2 - Fatal error!\n";
1069 cout <<
" Fails for point number I = " << i <<
"\n";
1070 cout <<
" M = " << m <<
"\n";
1071 cout <<
" M1 = " << m1 <<
"\n";
1072 cout <<
" X,Y(M) = " << point_xy[2*(m-1)+0] <<
" " 1073 << point_xy[2*(m-1)+1] <<
"\n";
1074 cout <<
" X,Y(M1) = " << point_xy[2*(m1-1)+0] <<
" " 1075 << point_xy[2*(m1-1)+1] <<
"\n";
1091 if ( point_num < j )
1094 cout <<
"DTRIS2 - Fatal error!\n";
1101 lr =
lrline ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1],
1102 point_xy[2*(m1-1)+0], point_xy[2*(m1-1)+1],
1103 point_xy[2*(m2-1)+0], point_xy[2*(m2-1)+1], 0.0 );
1121 tri_vert[3*0+0] = m1;
1122 tri_vert[3*0+1] = m2;
1123 tri_vert[3*0+2] = m;
1124 tri_nabe[3*0+2] = -3;
1126 for ( i = 2; i <= *tri_num; i++ )
1130 tri_vert[3*(i-1)+0] = m1;
1131 tri_vert[3*(i-1)+1] = m2;
1132 tri_vert[3*(i-1)+2] = m;
1133 tri_nabe[3*(i-2)+0] = -3 * i;
1134 tri_nabe[3*(i-2)+1] = i;
1135 tri_nabe[3*(i-1)+2] = i - 1;
1139 tri_nabe[3*(*tri_num-1)+0] = -3 * (*tri_num) - 1;
1140 tri_nabe[3*(*tri_num-1)+1] = -5;
1146 tri_vert[3*0+0] = m2;
1147 tri_vert[3*0+1] = m1;
1148 tri_vert[3*0+2] = m;
1149 tri_nabe[3*0+0] = -4;
1151 for ( i = 2; i <= *tri_num; i++ )
1155 tri_vert[3*(i-1)+0] = m2;
1156 tri_vert[3*(i-1)+1] = m1;
1157 tri_vert[3*(i-1)+2] = m;
1158 tri_nabe[3*(i-2)+2] = i;
1159 tri_nabe[3*(i-1)+0] = -3 * i - 3;
1160 tri_nabe[3*(i-1)+1] = i - 1;
1163 tri_nabe[3*(*tri_num-1)+2] = -3 * (*tri_num);
1164 tri_nabe[3*0+1] = -3 * (*tri_num) - 2;
1175 for ( i = j+1; i <= point_num; i++ )
1178 m1 = tri_vert[3*(ltri-1)+ledg-1];
1182 m2 = tri_vert[3*(ltri-1)+ledg];
1186 m2 = tri_vert[3*(ltri-1)+0];
1189 lr =
lrline ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1],
1190 point_xy[2*(m1-1)+0], point_xy[2*(m1-1)+1],
1191 point_xy[2*(m2-1)+0], point_xy[2*(m2-1)+1], 0.0 );
1201 l = -tri_nabe[3*(ltri-1)+ledg-1];
1206 vbedg ( point_xy[2*(m-1)+0], point_xy[2*(m-1)+1], point_num,
1207 point_xy, *tri_num, tri_vert, tri_nabe, <ri, &ledg, &rtri, &redg );
1210 l = -tri_nabe[3*(ltri-1)+ledg-1];
1216 l = -tri_nabe[3*(t-1)+e-1];
1217 m2 = tri_vert[3*(t-1)+e-1];
1221 m1 = tri_vert[3*(t-1)+e];
1225 m1 = tri_vert[3*(t-1)+0];
1228 *tri_num = *tri_num + 1;
1229 tri_nabe[3*(t-1)+e-1] = *tri_num;
1230 tri_vert[3*(*tri_num-1)+0] = m1;
1231 tri_vert[3*(*tri_num-1)+1] = m2;
1232 tri_vert[3*(*tri_num-1)+2] = m;
1233 tri_nabe[3*(*tri_num-1)+0] = t;
1234 tri_nabe[3*(*tri_num-1)+1] = *tri_num - 1;
1235 tri_nabe[3*(*tri_num-1)+2] = *tri_num + 1;
1238 if ( point_num < top )
1241 cout <<
"DTRIS2 - Fatal error!\n";
1242 cout <<
" Stack overflow.\n";
1247 stack[top-1] = *tri_num;
1249 if ( t == rtri && e == redg )
1256 tri_nabe[3*(ltri-1)+ledg-1] = -3 * n - 1;
1257 tri_nabe[3*(n-1)+1] = -3 * (*tri_num) - 2;
1258 tri_nabe[3*(*tri_num-1)+2] = -l;
1262 error =
swapec ( m, &top, <ri, &ledg, point_num, point_xy, *tri_num,
1263 tri_vert, tri_nabe, stack );
1268 cout <<
"DTRIS2 - Fatal error!\n";
1269 cout <<
" Error return from SWAPEC.\n";
1278 for ( i = 0; i < 3; i++ )
1280 for ( j = 0; j < *tri_num; j++ )
1282 tri_vert[i+j*3] = indx [ tri_vert[i+j*3] - 1 ];
1326 for ( i = 0; i <
n; i++ )
1328 if ( a1[i] != a2[i] )
1374 for ( i = 0; i <
n; i++ )
1377 if ( a2[i] < a1[i] )
1381 else if ( a1[i] < a2[i] )
1428 for ( i = 0; i <
n; i++ )
1430 if ( a1[i] < a2[i] )
1434 else if ( a2[i] < a1[i] )
1476 cout << title <<
"\n";
1480 for ( i = 0; i <= n-1; i++ )
1482 cout <<
setw(6) << i + 1 <<
" " 1483 <<
setw(14) << a[i] <<
"\n";
1516 for ( i = 0; i <
n; i++ )
1656 cout <<
"I_MODP - Fatal error!\n";
1657 cout <<
" I_MODP ( I, J ) called with J = " << j <<
"\n";
1665 value = value + abs ( j );
1765 jlo =
i_min ( ilo, ihi );
1766 jhi =
i_max ( ilo, ihi );
1768 wide = jhi + 1 - jlo;
1776 value = jlo +
i_modp ( ival - jlo, wide );
1817 int ihi,
int jhi,
const char *title )
1860 cout << title <<
"\n";
1865 for ( i2lo = ilo; i2lo <= ihi; i2lo = i2lo +
INCX )
1867 i2hi = i2lo +
INCX - 1;
1868 i2hi =
i_min ( i2hi, m );
1869 i2hi =
i_min ( i2hi, ihi );
1878 for ( i = i2lo; i <= i2hi; i++ )
1880 cout <<
setw(7) << i <<
" ";
1888 j2lo =
i_max ( jlo, 1 );
1889 j2hi =
i_min ( jhi, n );
1891 for ( j = j2lo; j <= j2hi; j++ )
1896 cout <<
setw(5) << j <<
" ";
1897 for ( i = i2lo; i <= i2hi; i++ )
1899 cout <<
setw(6) << a[i-1+(j-1)*m] <<
" ";
1968 for ( i = (n/2)-1; 0 <= i; i-- )
2002 if ( a[m] < a[m+1] )
2065 for ( i = 0; i <
n; i++ )
2129 for ( n1 = n-1; 2 <= n1; n1-- )
2185 for ( i = 1; i <
n; i++ )
2187 if ( a[i] != a[*nuniq] )
2189 *nuniq = *nuniq + 1;
2199 int lrline (
double xu,
double yu,
double xv1,
double yv1,
double xv2,
2200 double yv2,
double dv )
2251 double tol = 0.0000001;
2260 tolabs = tol *
d_max ( fabs ( dx ),
2261 d_max ( fabs ( dy ),
2262 d_max ( fabs ( dxu ),
2263 d_max ( fabs ( dyu ), fabs ( dv ) ) ) ) );
2265 t = dy * dxu - dx * dyu + dv *
sqrt ( dx * dx + dy * dy );
2271 else if ( -tolabs <= t )
2275 else if ( t < -tolabs )
2318 for ( seek = 1; seek <=
n; seek++ )
2322 for ( i = 0; i <
n; i++ )
2371 cout <<
"PERM_INV - Fatal error!\n";
2372 cout <<
" Input value of N = " << n <<
"\n";
2379 cout <<
"PERM_INV - Fatal error!\n";
2380 cout <<
" The input array does not represent\n";
2381 cout <<
" a proper permutation.\n";
2387 for ( i = 1; i <=
n; i++ )
2398 is = -
i_sign ( p[i-1] );
2399 p[i-1] =
i_sign ( is ) * abs ( p[i-1] );
2402 for ( i = 1; i <=
n; i++ )
2493 z =
new double [
n ];
2495 for ( i = 0; i <
n; i++ )
2497 z[i] = p[0+i*2] * p[0+i*2] + p[1+i*2] * p[1+i*2];
2503 for ( pass = 1; pass <= 2; pass++ )
2507 tri =
new int[3*
count];
2513 for ( i = 0; i < n - 2; i++ )
2515 for ( j = i+1; j <
n; j++ )
2517 for ( k = i+1; k <
n; k++ )
2521 xn = ( p[1+j*2] - p[1+i*2] ) * ( z[k] - z[i] )
2522 - ( p[1+k*2] - p[1+i*2] ) * ( z[j] - z[i] );
2523 yn = ( p[0+k*2] - p[0+i*2] ) * ( z[j] - z[i] )
2524 - ( p[0+j*2] - p[0+i*2] ) * ( z[k] - z[i] );
2525 zn = ( p[0+j*2] - p[0+i*2] ) * ( p[1+k*2] - p[1+i*2] )
2526 - ( p[0+k*2] - p[0+i*2] ) * ( p[1+j*2] - p[1+i*2] );
2532 for ( m = 0; m <
n; m++ )
2534 flag = flag && ( ( p[0+m*2] - p[0+i*2] ) * xn
2535 + ( p[1+m*2] - p[1+i*2] ) * yn
2536 + ( z[m] - z[i] ) * zn <= 0 );
2592 t =
const_cast<char*
>(
s) + n - 1;
2608 int swapec (
int i,
int *top,
int *btri,
int *bedg,
int point_num,
2609 double point_xy[],
int tri_num,
int tri_vert[],
int tri_nabe[],
2700 x = point_xy[2*(i-1)+0];
2701 y = point_xy[2*(i-1)+1];
2710 t = stack[(*top)-1];
2713 if ( tri_vert[3*(t-1)+0] == i )
2716 b = tri_vert[3*(t-1)+2];
2718 else if ( tri_vert[3*(t-1)+1] == i )
2721 b = tri_vert[3*(t-1)+0];
2726 b = tri_vert[3*(t-1)+1];
2729 a = tri_vert[3*(t-1)+e-1];
2730 u = tri_nabe[3*(t-1)+e-1];
2732 if ( tri_nabe[3*(u-1)+0] == t )
2735 c = tri_vert[3*(u-1)+2];
2737 else if ( tri_nabe[3*(u-1)+1] == t )
2740 c = tri_vert[3*(u-1)+0];
2745 c = tri_vert[3*(u-1)+1];
2749 point_xy[2*(a-1)+0], point_xy[2*(a-1)+1],
2750 point_xy[2*(c-1)+0], point_xy[2*(c-1)+1],
2751 point_xy[2*(b-1)+0], point_xy[2*(b-1)+1] );
2755 em1 =
i_wrap ( e - 1, 1, 3 );
2756 ep1 =
i_wrap ( e + 1, 1, 3 );
2757 fm1 =
i_wrap ( f - 1, 1, 3 );
2758 fp1 =
i_wrap ( f + 1, 1, 3 );
2760 tri_vert[3*(t-1)+ep1-1] = c;
2761 tri_vert[3*(u-1)+fp1-1] = i;
2762 r = tri_nabe[3*(t-1)+ep1-1];
2763 s = tri_nabe[3*(u-1)+fp1-1];
2764 tri_nabe[3*(t-1)+ep1-1] = u;
2765 tri_nabe[3*(u-1)+fp1-1] = t;
2766 tri_nabe[3*(t-1)+e-1] = s;
2767 tri_nabe[3*(u-1)+f-1] = r;
2769 if ( 0 < tri_nabe[3*(u-1)+fm1-1] )
2772 stack[(*top)-1] = u;
2777 if ( tri_nabe[3*(s-1)+0] == u )
2779 tri_nabe[3*(s-1)+0] = t;
2781 else if ( tri_nabe[3*(s-1)+1] == u )
2783 tri_nabe[3*(s-1)+1] = t;
2787 tri_nabe[3*(s-1)+2] = t;
2792 if ( point_num < *top )
2797 stack[(*top)-1] = t;
2801 if ( u == *btri && fp1 == *bedg )
2807 l = - ( 3 * t + e - 1 );
2811 while ( 0 < tri_nabe[3*(tt-1)+ee-1] )
2813 tt = tri_nabe[3*(tt-1)+ee-1];
2815 if ( tri_vert[3*(tt-1)+0] == a )
2819 else if ( tri_vert[3*(tt-1)+1] == a )
2830 tri_nabe[3*(tt-1)+ee-1] = l;
2836 if ( tri_nabe[3*(r-1)+0] == t )
2838 tri_nabe[3*(r-1)+0] = u;
2840 else if ( tri_nabe[3*(r-1)+1] == t )
2842 tri_nabe[3*(r-1)+1] = u;
2846 tri_nabe[3*(r-1)+2] = u;
2851 if ( t == *btri && ep1 == *bedg )
2857 l = - ( 3 * u + f - 1 );
2861 while ( 0 < tri_nabe[3*(tt-1)+ee-1] )
2863 tt = tri_nabe[3*(tt-1)+ee-1];
2865 if ( tri_vert[3*(tt-1)+0] ==
b )
2869 else if ( tri_vert[3*(tt-1)+1] ==
b )
2878 tri_nabe[3*(tt-1)+ee-1] = l;
2911 # define TIME_SIZE 29 2914 const struct tm *tm;
2918 now = time ( NULL );
2919 tm = localtime ( &now );
2921 len = strftime ( time_buffer,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
2925 cout << time_buffer <<
"\n";
2958 # define TIME_SIZE 29 2960 const struct tm *tm;
2964 now = time ( NULL );
2965 tm = localtime ( &now );
2969 strftime ( s,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
3028 asq = ( t[0+1*2] - t[0+0*2] ) * ( t[0+1*2] - t[0+0*2] )
3029 + ( t[1+1*2] - t[1+0*2] ) * ( t[1+1*2] - t[1+0*2] );
3031 csq = ( t[0+2*2] - t[0+0*2] ) * ( t[0+2*2] - t[0+0*2] )
3032 + ( t[1+2*2] - t[1+0*2] ) * ( t[1+2*2] - t[1+0*2] );
3034 top1 = ( t[1+1*2] - t[1+0*2] ) * csq - ( t[1+2*2] - t[1+0*2] ) * asq;
3035 top2 = ( t[0+1*2] - t[0+0*2] ) * csq - ( t[0+2*2] - t[0+0*2] ) * asq;
3037 bot = ( t[1+1*2] - t[1+0*2] ) * ( t[0+2*2] - t[0+0*2] )
3038 - ( t[1+2*2] - t[1+0*2] ) * ( t[0+1*2] - t[0+0*2] );
3040 center[0] = t[0+0*2] + 0.5 * top1 / bot;
3041 center[1] = t[1+0*2] + 0.5 * top2 / bot;
3050 double g_xy[],
int tri_num,
int nod_tri[] )
3101 int x_ps_max_clip = 594;
3103 int x_ps_min_clip = 18;
3108 int y_ps_max_clip = 684;
3110 int y_ps_min_clip = 108;
3114 x_max = g_xy[0+0*2];
3115 x_min = g_xy[0+0*2];
3116 y_max = g_xy[1+0*2];
3117 y_min = g_xy[1+0*2];
3119 for ( g = 0; g < g_num; g++ )
3121 x_max =
d_max ( x_max, g_xy[0+g*2] );
3122 x_min =
d_min ( x_min, g_xy[0+g*2] );
3123 y_max =
d_max ( y_max, g_xy[1+g*2] );
3124 y_min =
d_min ( y_min, g_xy[1+g*2] );
3132 file_out.open ( file_out_name );
3137 cout <<
"TRIANGULATION_PLOT_EPS - Fatal error!\n";
3138 cout <<
" Cannot open the output file \"" << file_out_name <<
"\".\n";
3142 file_out <<
"%!PS-Adobe-3.0 EPSF-3.0\n";
3143 file_out <<
"%%Creator: triangulation_plot_eps.cc\n";
3144 file_out <<
"%%Title: " << file_out_name <<
"\n";
3145 file_out <<
"%%CreationDate: " << date_time <<
"\n";
3146 file_out <<
"%%Pages: 1\n";
3147 file_out <<
"%%Bounding Box: " << x_ps_min <<
" " << y_ps_min <<
" " 3148 << x_ps_max <<
" " << y_ps_max <<
"\n";
3149 file_out <<
"%%Document-Fonts: Times-Roman\n";
3150 file_out <<
"%%LanguageLevel: 1\n";
3151 file_out <<
"%%EndComments\n";
3152 file_out <<
"%%BeginProlog\n";
3153 file_out <<
"/inch {72 mul} def\n";
3154 file_out <<
"%%EndProlog\n";
3155 file_out <<
"%%Page: 1 1\n";
3156 file_out <<
"save\n";
3158 file_out <<
"% Set the RGB line color to very light gray.\n";
3160 file_out <<
"0.900 0.900 0.900 setrgbcolor\n";
3162 file_out <<
"% Draw a gray border around the page.\n";
3164 file_out <<
"newpath\n";
3165 file_out <<
" " << x_ps_min <<
" " << y_ps_min <<
" moveto\n";
3166 file_out <<
" " << x_ps_max <<
" " << y_ps_min <<
" lineto\n";
3167 file_out <<
" " << x_ps_max <<
" " << y_ps_max <<
" lineto\n";
3168 file_out <<
" " << x_ps_min <<
" " << y_ps_max <<
" lineto\n";
3169 file_out <<
" " << x_ps_min <<
" " << y_ps_min <<
" lineto\n";
3170 file_out <<
"stroke\n";
3172 file_out <<
"% Set the RGB line color to black.\n";
3174 file_out <<
"0.000 0.000 0.000 setrgbcolor\n";
3176 file_out <<
"% Set the font and its size.\n";
3178 file_out <<
"/Times-Roman findfont\n";
3179 file_out <<
"0.50 inch scalefont\n";
3180 file_out <<
"setfont\n";
3182 file_out <<
"% Print a title.\n";
3184 file_out <<
"210 702 moveto\n";
3185 file_out <<
"(Triangulation) show\n";
3187 file_out <<
"% Define a clipping polygon.\n";
3189 file_out <<
"newpath\n";
3190 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_min_clip <<
" moveto\n";
3191 file_out <<
" " << x_ps_max_clip <<
" " << y_ps_min_clip <<
" lineto\n";
3192 file_out <<
" " << x_ps_max_clip <<
" " << y_ps_max_clip <<
" lineto\n";
3193 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_max_clip <<
" lineto\n";
3194 file_out <<
" " << x_ps_min_clip <<
" " << y_ps_min_clip <<
" lineto\n";
3195 file_out <<
"clip newpath\n";
3197 file_out <<
"% Set the RGB line color to green.\n";
3199 file_out <<
"0.000 0.750 0.150 setrgbcolor\n";
3201 file_out <<
"% Draw the nodes.\n";
3204 for ( g = 0; g < g_num; g++ )
3207 ( ( x_max - g_xy[0+g*2] ) *
double( x_ps_min )
3208 + ( g_xy[0+g*2] - x_min ) *
double( x_ps_max ) )
3209 / ( x_max - x_min ) );
3212 ( ( y_max - g_xy[1+g*2] ) *
double( y_ps_min )
3213 + ( g_xy[1+g*2] - y_min ) *
double( y_ps_max ) )
3214 / ( y_max - y_min ) );
3216 file_out <<
"newpath " << x_ps <<
" " 3217 << y_ps <<
" 5 0 360 arc closepath fill\n";
3221 file_out <<
"% Set the RGB line color to red.\n";
3223 file_out <<
"0.900 0.200 0.100 setrgbcolor\n";
3225 file_out <<
"% Draw the triangles.\n";
3228 for ( t = 1; t <= tri_num; t++ )
3230 file_out <<
"newpath\n";
3232 for ( j = 1; j <= 4; j++ )
3236 k = nod_tri[3*(t-1)+e-1];
3239 ( ( x_max - g_xy[0+(k-1)*2] ) *
double( x_ps_min )
3240 + ( g_xy[0+(k-1)*2] - x_min ) *
double( x_ps_max ) )
3241 / ( x_max - x_min ) );
3244 ( ( y_max - g_xy[1+(k-1)*2] ) *
double( y_ps_min )
3245 + ( g_xy[1+(k-1)*2] - y_min ) *
double( y_ps_max ) )
3246 / ( y_max - y_min ) );
3250 file_out << x_ps <<
" " << y_ps <<
" moveto\n";
3254 file_out << x_ps <<
" " << y_ps <<
" lineto\n";
3259 file_out <<
"stroke\n";
3263 file_out <<
"restore showpage\n";
3265 file_out <<
"% End of page.\n";
3267 file_out <<
"%%Trailer\n";
3268 file_out <<
"%%EOF\n";
3277 int tri_vert[],
int tri_nabe[] )
3338 cout <<
"TRIANGULATION_PRINT\n";
3339 cout <<
" Information defining a triangulation.\n";
3341 cout <<
" The number of points is " << point_num <<
"\n";
3346 cout <<
" The number of triangles is " << tri_num <<
"\n";
3348 cout <<
" Sets of three points are used as vertices of\n";
3349 cout <<
" the triangles. For each triangle, the points\n";
3350 cout <<
" are listed in counterclockwise order.\n";
3355 cout <<
" On each side of a given triangle, there is either\n";
3356 cout <<
" another triangle, or a piece of the convex hull.\n";
3357 cout <<
" For each triangle, we list the indices of the three\n";
3358 cout <<
" neighbors, or (if negative) the codes of the\n";
3359 cout <<
" segments of the convex hull.\n";
3366 vertex_list =
new int[3*tri_num];
3369 for ( t = 0; t < tri_num; t++ )
3371 for ( s = 0; s < 3; s++ )
3373 vertex_list[
k] = tri_vert[s+t*3];
3382 delete [] vertex_list;
3386 boundary_num = 2 * vertex_num - tri_num - 2;
3389 cout <<
" The number of boundary points is " << boundary_num <<
"\n";
3391 cout <<
" The segments that make up the convex hull can be\n";
3392 cout <<
" determined from the negative entries of the triangle\n";
3393 cout <<
" neighbor list.\n";
3395 cout <<
" # Tri Side N1 N2\n";
3402 for ( i = 0; i < tri_num; i++ )
3404 for ( j = 0; j < 3; j++ )
3406 if ( tri_nabe[j+i*3] < 0 )
3408 s = -tri_nabe[j+i*3];
3411 if ( t < 1 || tri_num < t )
3414 cout <<
" Sorry, this data does not use the DTRIS2\n";
3415 cout <<
" convention for convex hull segments.\n";
3421 s2 =
i_wrap ( s1+1, 1, 3 );
3423 n1 = tri_vert[s1-1+(t-1)*3];
3424 n2 = tri_vert[s2-1+(t-1)*3];
3425 cout <<
setw(4) << k <<
" " 3426 <<
setw(4) << t <<
" " 3427 <<
setw(4) << s1 <<
" " 3428 <<
setw(4) << n1 <<
" " 3429 <<
setw(4) << n2 <<
"\n";
3446 void vbedg (
double x,
double y,
int point_num,
double point_xy[],
int tri_num,
3447 int tri_vert[],
int tri_nabe[],
int *ltri,
int *ledg,
int *rtri,
int *redg )
3540 l = -tri_nabe[3*((*rtri)-1)+(*redg)-1];
3543 a = tri_vert[3*(t-1)+e-1];
3547 b = tri_vert[3*(t-1)+e];
3551 b = tri_vert[3*(t-1)+0];
3554 ax = point_xy[2*(a-1)+0];
3555 ay = point_xy[2*(a-1)+1];
3557 bx = point_xy[2*(b-1)+0];
3558 by = point_xy[2*(b-1)+1];
3560 lr =
lrline ( x, y, ax, ay, bx, by, 0.0 );
3582 b = tri_vert[3*(t-1)+e-1];
3583 e =
i_wrap ( e-1, 1, 3 );
3585 while ( 0 < tri_nabe[3*(t-1)+e-1] )
3587 t = tri_nabe[3*(t-1)+e-1];
3589 if ( tri_vert[3*(t-1)+0] ==
b )
3593 else if ( tri_vert[3*(t-1)+1] ==
b )
3604 a = tri_vert[3*(t-1)+e-1];
3605 ax = point_xy[2*(a-1)+0];
3606 ay = point_xy[2*(a-1)+1];
3608 bx = point_xy[2*(b-1)+0];
3609 by = point_xy[2*(b-1)+1];
3611 lr =
lrline ( x, y, ax, ay, bx, by, 0.0 );
int s_len_trim(const char *s)
void imat_transpose_print(int m, int n, int a[], const char *title)
int i_wrap(int ival, int ilo, int ihi)
void vbedg(double x, double y, int point_num, double point_xy[], int tri_num, int tri_vert[], int tri_nabe[], int *ltri, int *ledg, int *rtri, int *redg)
bool dvec_lt(int n, double a1[], double a2[])
int * d2vec_sort_heap_index_a(int n, double a[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
void ivec_sorted_unique(int n, int a[], int *nuniq)
dimensionedScalar yn(const int n, const dimensionedScalar &ds)
void d2vec_sort_quick_a(int n, double a[])
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
int * ivec_indicator(int n)
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
double * triangle_circumcenter_2d(double t[])
dimensionedScalar y0(const dimensionedScalar &ds)
label k
Boltzmann constant.
void dmat_transpose_print(int m, int n, double a[], const char *title)
const dimensionedScalar c
Speed of light in a vacuum.
void triangulation_print(int point_num, double xc[], int tri_num, int tri_vert[], int tri_nabe[])
bool dvec_gt(int n, double a1[], double a2[])
bool triangulation_plot_eps(const char *file_out_name, int g_num, double g_xy[], int tri_num, int nod_tri[])
void perm_inv(int n, int p[])
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void dmat_transpose_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, const char *title)
double d_max(double x, double y)
int lrline(double xu, double yu, double xv1, double yv1, double xv2, double yv2, double dv)
void dmat_uniform(int m, int n, double b, double c, int *seed, double r[])
void dvec_print(int n, double a[], const char *title)
int i_min(int i1, int i2)
dimensionedScalar y1(const dimensionedScalar &ds)
int * points_delaunay_naive_2d(int n, double p[], int *ntri)
void imat_transpose_print_some(int m, int n, int a[], int ilo, int jlo, int ihi, int jhi, const char *title)
void ivec_sort_heap_a(int n, int a[])
bool perm_check(int n, int p[])
int dtris2(int point_num, double point_xy[], int *tri_num, int tri_vert[], int tri_nabe[])
void d2vec_part_quick_a(int n, double a[], int *l, int *r)
void ivec_heap_d(int n, int a[])
void d2vec_permute(int n, double a[], int p[])
int diaedg(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
Omanip< int > setw(const int i)
double d_min(double x, double y)
const dimensionedVector & g
void dvec_swap(int n, double a1[], double a2[])
const dimensionedScalar e
Elementary charge.
bool dvec_eq(int n, double a1[], double a2[])
int swapec(int i, int *top, int *btri, int *bedg, int point_num, double point_xy[], int tri_num, int tri_vert[], int tri_nabe[], int stack[])
int i_max(int i1, int i2)