?? grad1.c
字號:
sscanf(cmd, "%d", &header_blocks);
break;
case 9:
printf("1 BO %s, 2 TO %s, 3 RL %s, 4 LL %s, 5 RE %s, 6 FR %s, 7 NO %s ",
(views & 1) ? "off" : "on",
(views & 1<<1) ? "off" : "on",
(views & 1<<2) ? "off" : "on",
(views & 1<<3) ? "off" : "on",
(views & 1<<4) ? "off" : "on",
(views & 1<<5) ? "off" : "on",
(views == 0) ? "off" : "on");
if (gets(cmd) == NULL) exit(0);
sscanf(cmd, "%d", &i);
if (i == 7)
views == 0;
else
views ^= 1 << --i;
break;
case 10:
printf("Enter for clipping: 1 RL, 2 LL, 3 RE, 4 FR : ");
if (gets(cmd) == NULL) exit(0);
sscanf(cmd, "%d", &i);
if (i > 0 && i < 5) {
printf("Enter clipping : ");
if (gets(cmd) == NULL) exit(0);
sscanf(cmd, "%d", &n);
switch (i) {
case 1:
clipx[0] = n;
break;
case 2:
clipx[1] = n;
break;
case 3:
clipy[0] = n;
break;
case 4:
clipy[1] = n;
break;
}
}
break;
case 11:
printf("Enter for image orienation: 1 X, 2 Y : ");
if (gets(cmd) == NULL) exit(0);
sscanf(cmd, "%d", &i);
if (i > 0 && i < 3)
image_or[i-1] *= -1;
break;
case 12:
printf("Enter for object orienation: 1 X, 2 Y, 3 Z : ");
if (gets(cmd) == NULL) exit(0);
sscanf(cmd, "%d", &i);
if (i > 0 && i < 4)
object_or[i-1] *= -1;
break;
default:
printf("Unvalid command!\n");
break;
}
}
}
}
}
THRESHOLD+=1024;
/* test parameters */
if (ZOOM > 5.0 || ZOOM < 1.0) {
printf("ZOOM must not be smaller than 1 or larger than 5!\n");
exit(1);
}
if (FIRSTSLICE < 1 || LASTSLICE <= FIRSTSLICE) {
printf("FIRSTSLICE and LASTSLICE are not within valid range!\n");
exit(1);
}
for (i = FIRSTSLICE; i <= LASTSLICE; i++) {
setfilename(i);
if ((fp = fopen(fnamein, "rb")) == NULL) continue;
fclose(fp);
break;
}
if (i > LASTSLICE) {
setfilename(FIRSTSLICE);
printf("No files with a name between %s and", fnamein);
setfilename(LASTSLICE);
printf(" %s!\n", fnamein);
exit(1);
}
else
FIRSTSLICE = i;
for (i = LASTSLICE; i >= FIRSTSLICE; i--) {
setfilename(i);
if ((fp = fopen(fnamein, "rb")) == NULL) continue;
fclose(fp);
break;
}
LASTSLICE = i;
if (LASTSLICE <= FIRSTSLICE) {
printf("FIRSTSLICE and LASTSLICE are not within valid range!\n");
exit(1);
}
if (GRAD_THRESHOLD < 1.0) {
printf("GRAD_THRESHOLD is too small!\n");
exit(1);
}
if (!isalpha(DR)) {
printf("Temporary drive has to be a letter!\n");
exit(1);
}
if (header_blocks < 0) {
printf("Number of header blocks has to be positive!\n");
exit(1);
}
if (clipx[0] < 0 || clipx[1] > 256 || clipx[1] <= clipx[0]) {
printf("Lateral clipping planes are not within valid range!\n");
}
if (clipy[0] < 0 || clipy[1] > 256 || clipy[1] <= clipy[0]) {
printf("Frontal clipping planes are not within valid range!\n");
}
/* temporary number of lines in output is used in finding
traversal of slices */
temp_nlines = ((float)(LASTSLICE-FIRSTSLICE)*ZOOM+.5);
/* get floating distance values (first pass over data)*/
if (!views || (views & 1) || (views & 1<<2) || (views & 1<<4)) {
/* set scan start/end/directions depending on object/image
orientations */
scanxdir[0] = clipx[0];
scanxdir[1] = clipx[1];
scanxdir[2] = 1;
scanydir[0] = clipy[0];
scanydir[1] = clipy[1];
scanydir[2] = 1;
scanzdir[0] = FIRSTSLICE;
scanzdir[1] = LASTSLICE;
scanzdir[2] = 1;
imagex[0] = clipy[0];
imagex[1] = 1;
imagex[2] = 0;
imagex[3] = 1;
imagey[0] = 255 - clipx[0];
imagey[1] = -1;
imagey[2] = 0;
imagey[3] = 1;
imagez[0] = clipx[0];
imagez[1] = 1;
imagez[2] = clipy[0];
imagez[3] = 1;
if (object_or[0] == -1) {
scanxdir[0] = clipx[1]-1;
scanxdir[1] = clipx[0]-1;
scanxdir[2] = -1;
imagey[0] = clipx[1]-1;
imagez[0] = 256 - clipx[1];
}
if (object_or[1] == -1) {
scanydir[0] = clipy[1]-1;
scanydir[1] = clipy[0]-1;
scanydir[2] = -1;
imagex[0] = 256 - clipy[1];
imagez[2] = 256 - clipy[1];
}
if (object_or[2] == -1) {
scanzdir[0] = LASTSLICE;
scanzdir[1] = FIRSTSLICE;
scanzdir[2] = -1;
}
if (image_or[0] == -1) {
imagex[0] = 255-imagex[0];
imagex[1] *= -1;
imagey[0] = 255-imagey[0];
imagey[1] *= -1;
imagez[0] = 255-imagez[0];
imagez[1] *= -1;
}
if (image_or[1] == -1) {
imagex[2] = temp_nlines-imagex[2];
imagex[3] *= -1;
imagey[2] = temp_nlines-imagey[2];
imagey[3] *= -1;
imagez[2] = 255-imagez[2];
imagez[3] *= -1;
}
printf("starting forward pass on data\n");
getdistances(scanxdir[0], scanxdir[1], scanxdir[2],
scanydir[0], scanydir[1], scanydir[2],
scanzdir[0], scanzdir[1], scanzdir[2],
imagex[0], imagex[1], imagex[2], imagex[3],
imagey[0], imagey[1], imagey[2], imagey[3],
imagez[0], imagez[1], imagez[2], imagez[3],
1);
/* create images */
if (views & 1) {
printf("doing bottom (Z) view(s)\n");
sprintf(filename,"%c:zdis%d.dat",DR,1);
doviews(filename,"gbo.out","dbo.out",256);
}
if (views & 1<<2) {
printf("doing right lateral (X) view(s)\n");
sprintf(filename,"%c:xdis%d.dat",DR,1);
doviews(filename,"grl.out","drl.out",NLINES);
}
if (views & 1<<4) {
printf("doing rear (Y) view(s)\n");
sprintf(filename,"%c:ydis%d.dat",DR,1);
doviews(filename,"gre.out","dre.out",NLINES);
}
}
/* get floating distance values (second pass over data)*/
if (!views || (views & 1<<1) || (views & 1<<3) || (views & 1<<5)) {
/* set scan start/end/directions depending on object/image
orientations */
scanxdir[0] = clipx[1]-1;
scanxdir[1] = clipx[0]-1;
scanxdir[2] = -1;
scanydir[0] = clipy[1]-1;
scanydir[1] = clipy[0]-1;
scanydir[2] = -1;
scanzdir[0] = LASTSLICE;
scanzdir[1] = FIRSTSLICE;
scanzdir[2] = -1;
imagex[0] = 256-clipy[1];
imagex[1] = 1;
imagex[2] = temp_nlines;
imagex[3] = -1;
imagey[0] = clipx[1]-1;
imagey[1] = -1;
imagey[2] = temp_nlines;
imagey[3] = -1;
imagez[0] = 256-clipx[1];
imagez[1] = 1;
imagez[2] = clipy[1]-1;
imagez[3] = -1;
if (object_or[0] == -1) {
scanxdir[0] = clipx[0];
scanxdir[1] = clipx[1];
scanxdir[2] = 1;
imagey[0] = 255 - clipx[0];
imagez[0] = clipx[0];
}
if (object_or[1] == -1) {
scanydir[0] = clipy[0];
scanydir[1] = clipy[1];
scanydir[2] = 1;
imagex[0] = clipy[0];
imagez[2] = 255 - clipy[0];
}
if (object_or[2] == -1) {
scanzdir[0] = FIRSTSLICE;
scanzdir[1] = LASTSLICE;
scanzdir[2] = 1;
}
if (image_or[0] == -1) {
imagex[0] = 255-imagex[0];
imagex[1] *= -1;
imagey[0] = 255-imagey[0];
imagey[1] *= -1;
imagez[0] = 255-imagez[0];
imagez[1] *= -1;
}
if (image_or[1] == -1) {
imagex[2] = temp_nlines-imagex[2];
imagex[3] *= -1;
imagey[2] = temp_nlines-imagey[2];
imagey[3] *= -1;
imagez[2] = 255-imagez[2];
imagez[3] *= -1;
}
printf("starting backward pass on data\n");
getdistances(scanxdir[0], scanxdir[1], scanxdir[2],
scanydir[0], scanydir[1], scanydir[2],
scanzdir[0], scanzdir[1], scanzdir[2],
imagex[0], imagex[1], imagex[2], imagex[3],
imagey[0], imagey[1], imagey[2], imagey[3],
imagez[0], imagez[1], imagez[2], imagez[3],
2);
/* create images */
if (views & 1<<1) {
printf("doing top (Z) view(s)\n");
sprintf(filename,"%c:zdis%d.dat",DR,2);
doviews(filename,"gto.out","dto.out",256);
}
if (views & 1<<3) {
printf("doing left lateral (X) view(s)\n");
sprintf(filename,"%c:xdis%d.dat",DR,2);
doviews(filename,"gll.out","dll.out",NLINES);
}
if (views & 1<<5) {
printf("doing front (Y) view(s)\n");
sprintf(filename,"%c:ydis%d.dat",DR,2);
doviews(filename,"gfr.out","dfr.out",NLINES);
}
}
printf("number of lines = %d\n",NLINES);
/* write temporary drive and number of lines */
par=fopen("param.dat","w");
fprintf(par,"%c %d\n",DR,NLINES);
/* write views */
if (views & 1)
fprintf(par, "BO ");
if (views & (1 << 1))
fprintf(par, "TO ");
if (views & (1 << 2))
fprintf(par, "RL ");
if (views & (1 << 3))
fprintf(par, "LL ");
if (views & (1 << 4))
fprintf(par, "RE ");
if (views & (1 << 5))
fprintf(par, "FR ");
if (!views)
fprintf(par, "NO ");
fprintf(par, "\n");
/* write clipping planes */
fprintf(par, "RL %d LL %d RE %d FR %d\n", clipx[0], clipx[1],
clipy[0], clipy[1]);
/* write image and object orientation */
fprintf(par, "image: x %2d y %2d\n", image_or[0], image_or[1]);
fprintf(par, "object: x %2d y %2d z %2d\n",
object_or[0], object_or[1], object_or[2]);
fclose(par);
}
usage()
{
printf("%s\n", usestr1);
printf("%s\n", usestr2);
printf("%s\n", usestr3);
exit(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -