GColor gethue(float r, float g, float b) { float h, s, v; float min, max, delta; min = MINI( r, g, b ); max = MAXI( r, g, b ); v = max; // v delta = max - min; if( max != 0 ) s = delta / max; // s else { // r = g = b = 0 // s = 0, v is undefined s = 0; h = -1; return (GColor(h, s, v)); } if( r == max ) h = ( g - b ) / delta; // between yellow & magenta else if( g == max ) h = 2 + ( b - r ) / delta; // between cyan & yellow else h = 4 + ( r - g ) / delta; // between magenta & cyan h *= 60; // degrees if( h < 0 ) h += 360; return (GColor(h, s, v)); }
int main() { int i, f; int tras, frente, solucao; scanf("%d\n", &n); gets(colar); solucao = -1; for (i = 0; i < n; ++i) { tras = contar_tras(i, &f); frente = contar_frente(ADD(i), f); solucao = MAXI(solucao, tras+frente); } printf("%d\n", solucao); return 0; }
/*-----------------------------------------------------------------------------*/ UDWORD DisplayColSize(SWORD coltype, UDWORD collen, UCHAR *colname) { switch (ODBCToXSBType(coltype)) { case SQL_C_SLONG: return sizeof(long *); case SQL_C_CHAR: { UDWORD tmp = MAXI(collen+1, strlen((char *) colname)); if (tmp < MAXVARSTRLEN) return tmp; else return MAXVARSTRLEN; } case SQL_C_BINARY: { return MAXVARSTRLEN; } case SQL_C_FLOAT: return sizeof(float *); default: printf("Illegal ODBC Type: %d\n",coltype); return 0; } }
// Sorts the heap (in increasing order), storing the indices // in sortInds and the values in sortVals. If the heap is not // full (ie it has DUMMY_IDX's in it), it will pad the sortVals // array with MAX_REAL and the sortInds with DUMMY_IDX. // This destroys the heap. void heapSort(heap *hp, unint *sortInds, real *sortVals){ unint i,j, swapInd; heapEl t; for(i=0; i<hp->len; i++){ sortVals[i] = MAX_REAL; sortInds[i] = DUMMY_IDX; } for(i=0; i<hp->len; i++){ sortInds[hp->len-i-1] = hp->h[0].id; if(hp->h[0].id != DUMMY_IDX) sortVals[hp->len-i-1] = hp->h[0].val; hp->h[0].id = DELETED_IDX; hp->h[0].val = MIN_REAL; j=0; while(2*j+1 < hp->len ){ if( 2*j+2 < hp->len ) swapInd = MAXI(hp->h[2*j+1].val, hp->h[2*j+2].val, 2*j+1, 2*j+2); else swapInd = 2*j+1; t.id = hp->h[swapInd].id; t.val = hp->h[swapInd].val; if( t.id == DELETED_IDX ) break; hp->h[swapInd].id = hp->h[j].id; hp->h[swapInd].val = hp->h[j].val; hp->h[j].id = t.id; hp->h[j].val = t.val; j = swapInd; } } }
void rupfront (double **s_depth, double **vs, int num_model_depth, double *nx, double *ny, double *z, int nns, double dstep, double lathypo, double lonhypo, double dephypo, double seglat, double seglon, double segdepth, double dip, double rupvel, double *time1) { float REARTH=6.371e+3; double PI= 4.0 * atan (1.0); double xdis=0, ydis=0; double dissq, diffstart; double diseps; double dis,sx,sy,s,radius,vsp, dage, det; double xs, ys, dxs[9], dys[9]; double dx0, dy0;//, rx, ry; float fac=1.0; int startx, starty, stopx, stopy; double time0; double **vrup, **set, **age; double agemax=0.0, agemin; double depthsum=0, s_depth_max, vrupmean=0.0; double rupvel2=0.6; int i,k,ns; int ixhypo, iyhypo, ix, iy,inx, iny,ixy; int ixmin, iymin, ixmax, iymax, ix0, iy0, ix0old, iy0old; int nxset, nyset, ixs[9], iys[9]; //printf("number of sourcepoints: %d\n", nns); disazi(REARTH*1000.0,seglat,seglon, lathypo,lonhypo,&xdis,&ydis); dissq=(xdis*xdis)+(ydis*ydis); dstep=dstep*1000.0; diseps=1.0e-06*dstep; vrupmean=0.0; depthsum=0; printf("s_depth[%d]=%lf\n",num_model_depth-2, (*s_depth)[num_model_depth-2]); printf("s_depth[%d]=%lf\n",num_model_depth-1, (*s_depth)[num_model_depth-1]); printf("s_depth[%d]=%lf\n",num_model_depth, (*s_depth)[num_model_depth]); s_depth_max=MIN((*s_depth)[num_model_depth],60000.0); for (k=1;k<num_model_depth;k++) //calculate mean rupture velocity for the segment { if ((*s_depth)[k]<s_depth_max) { if(k==1) { vrupmean=vrupmean+(*vs)[k]*(*s_depth)[k]; depthsum=(*s_depth)[k]; } else { vrupmean=vrupmean+(*vs)[k]*((*s_depth)[k]-(*s_depth)[k-1]); depthsum=depthsum+(*s_depth)[k]-(*s_depth)[k-1]; } } } vrupmean=vrupmean/depthsum*rupvel; ///////determine hypocenter location xdis, ydis /////// adjust location if hypocenter lies outside the fault (e.g. for multiple fault segments) printf(" dip=%lf\n",dip); if (dip>0.0) { ydis=((dephypo-segdepth)*1000.0)/sin(dip*PI/180.0); printf(" dip=%lf\n",dip); if (pow(dissq-((dephypo-segdepth)*1000.0/tan(dip*PI/180.0)),2)>0.0) { xdis=sqrt(dissq-pow(((dephypo-segdepth)*1000.0/tan(dip*PI/180.0)),2)); } else { xdis=0.0; } } else { printf("*dip < 0.0 \n"); exit(0); } // printf("lat lon x y %lf %lf %lf %lf \n",lathypo,lonhypo,xdis,ydis); printf("xdis=%lf, ydis=%lf, dstep=%lf\n", xdis, ydis, dstep); printf("nx=%lf, ny=%lf,\n", nx[nns], ny[nns]); if(xdis>nx[nns]*1000.0) { diffstart=xdis-nx[nns]*1000.0; time0=diffstart/vrupmean; xdis=nx[nns]*1000.0; } else if(xdis<dstep) { diffstart=dstep-xdis; time0=diffstart/vrupmean; xdis=dstep; } else { time0=0; xdis=(int)(xdis/dstep)*dstep; } if(ydis>ny[nns]*1000.0) { diffstart=ydis-ny[nns]*1000.0; time0=time0+diffstart/vrupmean; ydis=ny[nns]*1000.0; } else if(ydis<dstep) { diffstart=dstep-ydis; time0=time0+diffstart/vrupmean; ydis=dstep; } else { ydis=(int)(ydis/dstep)*dstep; } // printf("xdis=%lf, ydis=%lf, nx=%lf, ny=%lf, dstep=%lf\n", xdis, ydis, nx[nns], ny[nns], dstep); printf("hypocenter %lf %lf %lf\n",xdis, ydis, time0); ixhypo=(int)(xdis/dstep); iyhypo=(int)(ydis/dstep); xs=0.5*nx[nns]; ys=0.5*ny[nns]; i=2; printf("nx(i)=%lf nx(i-1)=%lf\n",nx[i], nx[i-1]); while(nx[i]>nx[i-1]) { i++; // printf("nx(i)=%lf nx(i-1)=%lf\n",nx[i], nx[i-1]); } inx=i-1; iny=nns/inx; printf("iny %d, inx %d , nns %d\n",inx, iny, nns); ///// fix the velocity field ///// velocity is set to rupvel times the local S-velocity vrup = (double**)calloc(inx,sizeof(double*)); if ( vrup== NULL) { printf("stop: could not allocate vrup\n"); exit(1); } for(i=0;i<inx;i++) { vrup[i] = (double*)calloc(iny,sizeof(double)); if ( vrup[i]== NULL) { printf("stop: could not allocate vrup\n"); exit(1); } } set = (double**)calloc(inx,sizeof(double*)); if ( vrup== NULL) { printf("stop: could not allocate set\n"); exit(1); } for(i=0;i<inx;i++) { set[i] = (double*)calloc(iny,sizeof(double)); if ( set[i]== NULL) { printf("stop: could not allocate vrup\n"); exit(1); } } age = (double**)calloc(inx,sizeof(double*)); if ( vrup== NULL) { printf("stop: could not allocate age\n"); exit(1); } for(i=0;i<inx;i++) { age[i] = (double*)calloc(iny,sizeof(double)); if ( age[i]== NULL) { printf("stop: could not allocate age\n"); exit(1); } } for (i=1;i<=nns;i++) { ix=(int) round(nx[i]*1000.0/dstep); iy=(int) round(ny[i]*1000.0/dstep); k=1; //printf("iy %d, ix %d %d\n",iy, ix,i); while(vrup[ix][iy]==0.0) { if(z[i]*1000.0<=(*s_depth)[k]) { vrup[ix][iy]= rupvel*(*vs)[k]; k=1; } else if (z[i]*1000.0<(*s_depth)[num_model_depth]) { k++; } else { vrup[ix][iy]= rupvel*(*vs)[num_model_depth]; k=1; } } if (z[i]<=5.0) { vrup[ix][iy]= vrup[ix][iy]*rupvel2; } else if (z[i]>5.0 && z[i]<8.0) { vrup[ix][iy]= vrup[ix][iy]*((1-rupvel2)/3.*z[i]+1-8./3.*(1-rupvel2)); fac=((1-rupvel2)/3.*z[i]+1-8./3.*(1-rupvel2)); } } for(ix=ixhypo-1; ix<ixhypo+1; ix++) { for(iy=iyhypo-1; iy<iyhypo+1; iy++) { dis=sqrt(pow(((ix-ixhypo)*dstep),2)+pow(((iy-iyhypo)*dstep),2)); age[ix-1][iy-1]=2.0*dis/(vrup[ix-1][iy-1]+vrup[ixhypo-1][iyhypo-1]); set[ix-1][iy-1]=1; agemax=MAX(agemax,age[ix-1][iy-1]); } } ixmin=ixhypo-1; iymin=iyhypo-1; ixmax=ixhypo+1; iymax=iyhypo+1; printf("min und max: %d / %d, %d / %d\n", ixmin, iymin, ixmax, iymax); /////////////////////////////////////////////////7 100 agemin=2.0*agemax; ix0=0; iy0=0; for(ix=ixmin; ix<ixmax; ix++) { for(iy=iymin; iy<iymax; iy++) { if(set[ix-1][iy-1]==1) { nxset=set[ix-1-1][iy-1]+set[ix+1-1][iy-1]; nyset=set[ix-1][iy-1-1]+set[ix-1][iy+1-1]; if (ix==inx || ix==1) { nxset=nxset+1; } if (iy==iny || iy==1) { nyset=nyset+1; } if (nxset>0 && nyset>0 && nxset+nyset<4 && agemin>=age[ix-1][iy-1]) { agemin=age[ix-1][iy-1]; ix0=ix; iy0=iy; } } } } while (ix0>0 || iy0>0) { //printf("agemin=%lf, ix=%d, iy=%d\n", agemin, ix, iy); ///////// the oldest edge patch is found: (ix0,iy0) ns=0; if(set[ix0-1-1][iy0-1]==1) { ns=ns+1; ixs[ns]=ix0-1; iys[ns]=iy0; dxs[ns]=-dstep; dys[ns]=0.0; if(set[ix0+1-1][iy0-1]==0) { sx=(age[ix0-1][iy0-1]-age[ix0-1-1][iy0-1])/dstep; } else { ns=ns+1; ixs[ns]=ix0+1; iys[ns]=iy0; dxs[ns]=dstep; dys[ns]=0.0; sx=0.5*(age[ix0+1-1][iy0-1]-age[ix0-1-1][iy0-1])/dstep; } } else { ns=ns+1; ixs[ns]=ix0+1; iys[ns]=iy0; dxs[ns]=dstep; dys[ns]=0.0; sx=(age[ix0+1-1][iy0-1]-age[ix0-1][iy0-1])/dstep; } if(set[ix0-1][iy0-1-1]==1) { ns=ns+1; ixs[ns]=ix0; iys[ns]=iy0-1; dxs[ns]=0.0; dys[ns]=-dstep; if(set[ix0-1][iy0-1+1]==0) { sy=(age[ix0-1][iy0-1]-age[ix0-1][iy0-1-1])/dstep; } else { ns=ns+1; ixs[ns]=ix0; iys[ns]=iy0+1; dxs[ns]=0.0; dys[ns]=dstep; sy=0.5*(age[ix0-1][iy0+1-1]-age[ix0-1][iy0-1-1])/dstep; } } else { ns=ns+1; ixs[ns]=ix0; iys[ns]=iy0+1; dxs[ns]=0.0; dys[ns]=dstep; sy=(age[ix0-1][iy0+1-1]-age[ix0-1][iy0-1])/dstep; } s=sqrt(sx*sx+sy*sy); sx=sx/s; sy=sy/s; // printf("s, sx, sy: %lf, %lf, %lf\n",s, sx, sy); radius=0.0; for( i=1; i<ns; i++) { vsp=0.5*(vrup[ix0-1][iy0-1]+vrup[ixs[i]-1][iys[i]-1]); dage=age[ixs[i]-1][iys[i]-1]-age[ix0-1][iy0-1]; det=2.0*(vsp*dage-dxs[i]*sx-dys[i]*sy); if(abs(det)>diseps) { radius=MAX(radius, (dxs[i]*dxs[i]+dys[i]*dys[i]-(vsp*dage)*(vsp*dage))/det); } } xs=radius*sx; ys=radius*sy; startx=MAXI(1,ix0-1); starty=MAXI(1,iy0-1); stopx=MINI(ix0+1,inx); stopy=MINI(iy0+1,iny); for(ix=startx; ix<=stopx; ix++) { dx0=(ix-ix0)*dstep; for(iy=starty; iy<=stopy; iy++) { dy0=(iy-iy0)*dstep; if(set[ix-1][iy-1]==0) { age[ix-1][iy-1]=age[ix0-1][iy0-1]+2.0*(sqrt((xs+dx0)*(xs+dx0)+(ys+dy0)*(ys+dy0))-radius) /(vrup[ix-1][iy-1]+vrup[ix0-1][iy0-1]); // printf("age=%lf,ix=%d,iy=%d, vel=%lf, vel(ix0,iy0)=%lf\n", age[ix-1][iy-1], ix, iy, vrup[ix-1][iy-1], vrup[ix0-1][iy0-1]); agemax=MAX(agemax,age[ix-1][iy-1]); set[ix-1][iy-1]=1; } } } ixmin=MINI(ixmin,MAXI(1,ix0-1)); iymin=MINI(iymin,MAXI(1,iy0-1)); ixmax=MAXI(ixmax,MINI(inx-1,ix0+1)); iymax=MAXI(iymax,MINI(iny-1,iy0+1)); // printf("min und max: %d / %d, %d / %d\n", ixmin, iymin, ixmax, iymax); agemin=2.0*agemax; ix0old=ix0; iy0old=iy0; ix0=0; iy0=0; for(ix=ixmin; ix<=ixmax; ix++) { for(iy=iymin; iy<=iymax; iy++) { if(set[ix-1][iy-1]==1) { // printf("agemin=%lf\n",agemin); if (ix==inx) { nxset=set[ix-1-1][iy-1]+1; } else if (ix==1) { nxset=set[ix+1-1][iy-1]+1; } else {nxset=set[ix-1-1][iy-1]+set[ix+1-1][iy-1]; } if (iy==iny) { nyset=set[ix-1][iy-1-1]+1; } else if (iy==1) { nyset=set[ix-1][iy+1-1]+1; } else { nyset=set[ix-1][iy-1-1]+set[ix-1][iy+1-1]; } if (ix==inx || ix==1) { nxset=nxset+1; } if (iy==iny || iy==1) { nyset=nyset+1; } if (nxset>0 && nyset>0 && nxset+nyset<4 && agemin>=age[ix-1][iy-1] && (ix!=ix0old || iy!=iy0old)) { agemin=age[ix-1][iy-1]; ix0=ix; iy0=iy; } } } } } // ///// add age to start time (time0) to determine absolute rupture time (time1) ixy=1; for(iy=1;iy<=iny;iy++) { //ry=(iy-1)*dstep; for(ix=1; ix<=inx; ix++) {//rx=(ix-1)*dstep; time1[ixy]=age[ix-1][iy-1]+time0; // printf("%lf\t %lf\t %lf\t %lf\t %lf\n", rx, ry, nx[ixy], ny[ixy], time1[ixy]); ixy=ixy+1; } } }
mlib_status __mlib_GraphicsDrawEllipse_X_32( mlib_image *buffer, mlib_s16 x, mlib_s16 y, mlib_s32 a, mlib_s32 b, mlib_f32 t, mlib_s32 c0, mlib_s32 c1) { mlib_s32 c = c0 ^ c1; mlib_s32 stride = mlib_ImageGetStride(buffer) / 4; mlib_s32 width = mlib_ImageGetWidth(buffer); mlib_s32 height = mlib_ImageGetHeight(buffer); mlib_u32 *data = mlib_ImageGetData(buffer); mlib_u32 *line0, *line1; mlib_f32 cosfi, sinfi, cosfi2, sinfi2; mlib_s32 doclip = 0; mlib_s32 left, right, bottom, top, length; mlib_s32 cx, cy; mlib_f32 a2, b2; mlib_s32 zeroangle = 0; if (!data) return (MLIB_NULLPOINTER); if (a < 0 || b < 0) return (MLIB_FAILURE); mlib_sincosf(-t, &sinfi, &cosfi); if (a == 0 || b == 0) { mlib_s32 x1, y1, x2, y2; if (b == 0) { x1 = a * cosfi + ((cosfi > 0.0f) ? 0.5f : -0.5f); y1 = -a * sinfi + ((sinfi < 0.0f) ? 0.5f : -0.5f); x2 = -x1; y2 = -y1; } else { x1 = -b * sinfi + ((sinfi < 0.0f) ? 0.5f : -0.5f); y1 = -b * cosfi + ((cosfi < 0.0f) ? 0.5f : -0.5f); x2 = -x1; y2 = -y1; } return __mlib_GraphicsDrawLine_X_32(buffer, x + x1, y + y1, x + x2, y + y2, c0, c1); } if (a == b) return (__mlib_GraphicsDrawCircle_X_32 (buffer, x, y, a, c0, c1)); length = MAXI(a, b); if (mlib_fabs(sinfi * length) < 0.5f) zeroangle = 1; else if (mlib_fabs(cosfi * length) < 0.5f) { mlib_s32 tmp = b; b = a; a = tmp; zeroangle = 1; } a2 = a * a; b2 = b * b; if (!zeroangle) { mlib_f32 A, B, C, D, A2, B2, C2, _2A, _2B, _2C, _4B, s, z1, z2; mlib_f32 fcx, fcy, _2fcx, _2fcy, fcx1, fcy1, fcx21, fcy21, _2fcx1, _2fcy1, _2fcx3, _2fcy3; mlib_f32 d, dinside, doutside; mlib_f32 gradi, gradj; mlib_f32 d1n_n, d1n_ne, d1ne_n, d1ne_ne; mlib_f32 d2e_e, d2e_ne, d2ne_e, d2ne_ne; mlib_f32 d3e_e, d3e_se, d3se_e, d3se_se; mlib_f32 d4s_s, d4s_se, d4se_s, d4se_se; mlib_f32 grad1n_i, grad1ne_i; mlib_f32 grad2e_j, grad2ne_j; mlib_f32 grad3e_j, grad3se_j; mlib_f32 grad4s_i, grad4se_i; mlib_s32 stop1y, stop3x; mlib_s32 minxx, minxy, maxyx, maxyy, maxxx, maxxy, minyx, minyy; cosfi2 = cosfi * cosfi; sinfi2 = sinfi * sinfi; A = b2 * cosfi2 + a2 * sinfi2; B = sinfi * cosfi * (b2 - a2); C = b2 * sinfi2 + a2 * cosfi2; D = a2 * b2; _2A = A * 2.0f; _2B = B * 2.0f; _2C = C * 2.0f; _4B = B * 4.0f; A2 = A * A; B2 = B * B; C2 = C * C; /* determine the rectangle that the the ellipse fits in */ s = mlib_sqrtf(D / (A * C2 - C * B2)); minxx = -C * s - 0.5f; minxy = B * s + ((B > 0.0f) ? 0.5f : -0.5f); maxxx = -minxx; maxxy = -minxy; s = mlib_sqrtf(D / (A2 * C - B2 * A)); minyy = -A * s - 0.5f; minyx = B * s + ((B > 0.0f) ? 0.5f : -0.5f); maxyy = -minyy; maxyx = -minyx; z1 = C + B; z2 = A + B; s = mlib_sqrtf(D / (A * z1 * z1 - 2.0f * B * z1 * z2 + C * z2 * z2)); stop1y = (z2 > 0.0f) ? (z2 * s + 0.5f) : (z2 * s - 0.5f); z1 = C - B; z2 = A - B; s = mlib_sqrtf(D / (A * z1 * z1 + 2.0f * B * z1 * z2 + C * z2 * z2)); stop3x = (z1 > 0.0f) ? (z1 * s + 0.5f) : (z1 * s - 0.5f); left = minxx + x - 1; right = maxxx + x + 1; bottom = minyy + y - 1; top = maxyy + y + 1; if (right < 0 || left >= width || top < 0 || bottom >= height) return (MLIB_SUCCESS); if (left < 0 || right >= width || bottom < 0 || top >= height) doclip = 1; cx = minxx; cy = minxy; line0 = data + stride * (y - minxy) + (x + minxx); line1 = data + stride * (y + minxy) + (x - minxx); d4s_s = d1n_n = _2C; d1ne_n = d1n_ne = _2B + _2C; d2ne_ne = d1ne_ne = _2A + _4B + _2C; d3e_e = d2e_e = _2A; d2ne_e = d2e_ne = _2A + _2B; d3se_e = d3e_se = _2A - _2B; d4se_se = d3se_se = _2A - _4B + _2C; d4se_s = d4s_se = _2C - _2B; grad3e_j = grad2e_j = grad1n_i = _2B; grad1ne_i = _2A + _2B; grad2ne_j = _2C + _2B; grad3se_j = _2B - _2C; grad4s_i = -_2B; grad4se_i = _2A - _2B; if (!doclip) { mlib_s32 tmp0, tmp1; ROTATED_ELLIPSE_PHASE1_START; ROTATED_PUT_NOCLIP; PHASE_END; ROTATED_ELLIPSE_PHASE2_START; ROTATED_PUT_NOCLIP; PHASE_END; ROTATED_ELLIPSE_PHASE3_START; ROTATED_PUT_NOCLIP; PHASE_END; ROTATED_ELLIPSE_PHASE4_START; ROTATED_PUT_NOCLIP; PHASE_END; } else { ROTATED_ELLIPSE_PHASE1_START; ROTATED_PUT_CLIP; PHASE_END; ROTATED_ELLIPSE_PHASE2_START; ROTATED_PUT_CLIP; PHASE_END; ROTATED_ELLIPSE_PHASE3_START; ROTATED_PUT_CLIP; PHASE_END; ROTATED_ELLIPSE_PHASE4_START; ROTATED_PUT_CLIP; PHASE_END; } } else { /* Simple algorithm that draws a simple not rotated ellipse */ mlib_s32 _2a2, _2b2; mlib_f32 _4a2b2; mlib_s32 cx1, cy1, _2cx, _2cy, _2cx1, _2cy1, _2cx3, _2cy3, cx21, cy21; mlib_s32 d, dinside, doutside; mlib_s32 gradi, gradj; mlib_s32 d1e_e, d1e_se, d1se_e, d1se_se; mlib_s32 d2s_s, d2s_se, d2se_s, d2se_se; mlib_s32 grad1_j, grad2_i; mlib_s32 gradstop1; left = x - a; right = x + a; top = y + b; bottom = y - b; if (right < 0 || left >= width || top < 0 || bottom >= height) return (MLIB_SUCCESS); if (left < 0 || right >= width || bottom < 0 || top >= height) doclip = 1; _2a2 = a2 * 2; _2b2 = b2 * 2; _4a2b2 = a2 * b2 * 4; gradstop1 = a2 / mlib_sqrtf(a2 + b2) + 0.5f; cx = 0; cy = b; line0 = data + stride * (y - b) + x; line1 = data + stride * (y + b) + x; d1se_e = d1e_se = d1e_e = _2b2; d2se_se = d1se_se = _2b2 + _2a2; d2se_s = d2s_se = d2s_s = _2a2; grad1_j = -_2a2; grad2_i = _2b2; if (!doclip) { mlib_s32 tmp0, tmp1, tmp2, tmp3; tmp0 = *line0 ^ c; tmp1 = *line1 ^ c; *line0 = tmp0; *line1 = tmp1; SIMPLE_ELLIPSE_PHASE1_START; SIMPLE_PUT_NOCLIP; PHASE_END; SIMPLE_ELLIPSE_PHASE2_START; SIMPLE_PUT_NOCLIP; PHASE_END; } else { mlib_s32 h0 = 0, h1 = 0, v0 = 0, v1 = 0; if ((x | ((width - 1) - (x + cx))) > 0) { h0 = (y - cy) | ((height - 1) - (y - cy)); h1 = (y + cy) | ((height - 1) - (y + cy)); if (h0 > 0) *line0 ^= c; if (h1 > 0) *line1 ^= c; } SIMPLE_ELLIPSE_PHASE1_START; SIMPLE_SET_CLIP_FLAGS; SIMPLE_PUT_CLIP; PHASE_END; SIMPLE_ELLIPSE_PHASE2_START; SIMPLE_SET_CLIP_FLAGS; SIMPLE_PUT_CLIP; PHASE_END; SIMPLE_PUT_CLIP_LAST; } } return (MLIB_SUCCESS); }
int main(int argc, char *argv[]) { int err, i; if (argc < 3) { msg("Missing parameters"); exit(1); } for (i = 0; i < (argc - 2); i++) { fprintf(stdout, "Processando parâmetro %d: %s", i, argv[i]); if (strcmp(argv[i], "-D") == 0) { if (setupWorkDir(argv[i + 1]) == ERRO) { msg("Invalid working directory on parameter -D"); return ERRO; } argv[i] = ""; argv[i+1] = ""; fprintf(stdout, "\nSet test session directory for %s", workingDir); } else if (strcmp(argv[i], "-DD") == 0) { if (! tem_dir(argv[i+1])) { msg("Invalid directory on parameter -DD"); return ERRO; } strcpy(testCaseImportDir, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet directory for importing test cases to %s", testCaseImportDir); } else if (strcmp(argv[i], "-DE") == 0) { if (! tem_dir(argv[i+1])) { msg("Invalid directory on parameter -DE"); return ERRO; } strcpy(executableDir, argv[i+1]); // FIXME: DirExec? argv[i] = ""; argv[i+1] = ""; printf("\nSet directory for executable file to %s", executableDir); } else if (strcmp(argv[i], "-I") == 0) { strcpy(testCaseInputDataImportFilename, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet file prefix for test cases to %s", testCaseInputDataImportFilename); } else if (strcmp(argv[i], "-p") == 0) { strcpy(testCaseParametersImportFilename, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet file prefix for test cases to %s", testCaseInputDataImportFilename); } else if (strcmp(argv[i], "-E") == 0) { strcpy(executableFilename, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet executable file to %s", executableFilename); } else if (strcmp(argv[i], "-EE") == 0) { strcpy(instrumentedExecutableFilename, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet executable for trace file to %s", instrumentedExecutableFilename); } else if (strcmp(argv[i], "-label") == 0 ) { strcpy(Label, argv[i+1]); argv[i] = ""; argv[i+1] = ""; printf("\nSet label (?) to %s", Label); } else if (strcmp(argv[i], "-f") == 0) { firstTestCase = MAXI(atoi(argv[i+1]), 0); argv[i] = ""; argv[i+1] = ""; printf("\nSet initial test case to %d", firstTestCase); } else if (strcmp(argv[i], "-t") == 0) { lastTestCase = MINI(atoi(argv[i+1]), MAX_TCASE); argv[i] = ""; argv[i+1] = ""; printf("\nSet final test case to %d", lastTestCase); } else if (strcmp(argv[i], "-v") == 0) { verbosityChar = *argv[i+1]; argv[i] = ""; argv[i+1] = ""; printf("\nSet progress symbol to %c", verbosityChar); } } for (i = 2; i < argc-1; i++) { if (strcmp(argv[i], "-trace") == 0) { enableTrace = TRUE; argv[i] = ""; printf("\nEnable tracing."); } else if (strcmp(argv[i], "-ninter") == 0) { isInteractive = FALSE; argv[i] = ""; printf("\nDisable ninter (?)"); } else if (strcmp(argv[i], "-inter") == 0) { isInteractive = TRUE; argv[i] = ""; printf("\nEnable ninter (?)"); } } if (setupTestSession(argv[argc - 1]) == ERRO) { msg("Invalid test session"); return ERRO; } argv[argc - 1] = ""; // Could not find a parameter configuring the working directory, so the use // the default one (current directory). if (isempty(workingDir)) { setupWorkDir("."); } if (isempty(executableDir)) { strcpy(executableDir, workingDir); fprintf(stdout, "\nSet directory for executable file to %s", executableDir); } if (isempty(testCaseImportDir)) { strcpy(testCaseImportDir, workingDir); fprintf(stdout, "\nSet directory for importing test cases to %s", testCaseImportDir); } if (isempty(testCaseInputDataImportFilename)) { strcpy(testCaseInputDataImportFilename, testSessionName); fprintf(stdout, "\nSet file prefix for test cases to %s", testCaseInputDataImportFilename); } if (isempty(executableFilename)) { strcpy(executableFilename, testSessionName); fprintf(stdout, "\nSet executable file to %s", executableFilename); } if (isempty(instrumentedExecutableFilename)) { strcpy(instrumentedExecutableFilename, testSessionName); fprintf(stdout, "\nSet executable for trace file to %s", instrumentedExecutableFilename); } if (lastTestCase == 0) { lastTestCase = firstTestCase + MAX_TCASE; } else { lastTestCase = MINI(lastTestCase, firstTestCase + MAX_TCASE); } fprintf(stdout, "\nSet initial test case to %d", firstTestCase); fprintf(stdout, "\nSet final test case to %d", lastTestCase); if (strcmp(argv[1], "-create") == 0) { argv[1] = ""; err = CreateTcase(argc, argv); if (err != 0) { msg("Error creating test set"); } exit(2); } else if (strcmp(argv[1], "-l") == 0 || strcmp(argv[1], "-d") == 0 || strcmp(argv[1], "-e") == 0 || strcmp(argv[1], "-i") == 0) { err = ListTcase(argc, argv); if (err != 0) { msg("Error listing test cases"); } exit(3); } else if (strcmp(argv[1], "-proteum") == 0 || strcmp(argv[1], "-poke") == 0 || strcmp(argv[1], "-ascii") == 0 ) { err = ImportTcase(argc, argv); if (err != 0) { msg("Error importing test cases"); } exit(4); } else if (strcmp(argv[1], "-add") == 0) { argv[1] = ""; err = AddTcase(argc, argv); if (err != 0) { msg("Error adding test case to test set"); } exit(5); } else if (strcmp(argv[1], "-z") == 0) { argv[1] = ""; err = ZapTcase(argc, argv); if (err != 0) { msg("Error reseting test set"); } exit(6); } else { msg("Missing parameter"); exit(1); } return err; }