⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deppp.c

📁 vc编写的3D图形
💻 C
字号:
/************************ Distances.c ****************************

			  Distances.C
    Example 3-D surface reconstruction distance shading program

Daniel Geist
Michael W. Vannier

Mallinckrodt Institute of Radiology
Washington University School of Medicine
510 S. Kingshighway Blvd.
St. Louis, Mo. 63110

*******************************************************************/

#include <stdio.h>

#define LINE_SIZE 256
#define HEADER_SIZE 512
#define CTLINE_SIZE 512

int FIRSTSLICE,LASTSLICE,THRESHOLD; /* some global variables */
int  buffer[LINE_SIZE];
char ybuf[LINE_SIZE];

/* input and output files */
char *fnamein="ctbild.000",*fnd="dis.out";

/* Set input file name - add number to file extension name*/
setfilename(filenum)
int filenum;
{
    fnamein[7]=filenum/100+'0';
    fnamein[8]=(filenum%100)/10+'0';
    fnamein[9]='0'+filenum%10;
}
create_distance_shades()
{
    int z,x,y;
    FILE *fd,*fn;
    fd=fopen(fnd,"wb");                  /*open output file */
    for(z=0;z<(LASTSLICE-FIRSTSLICE+1);z++){  /* for each slice*/
        setfilename(FIRSTSLICE+z);       /*open slice file */
        fn=fopen(fnamein,"rb");
        fseek(fn,(long)HEADER_SIZE,SEEK_SET);    /* read header    */
        for(y=0;y<LINE_SIZE;y++){           /*for each line */
            fread(buffer,1,CTLINE_SIZE,fn);   /*read line */
            /* find Threshold transition */
            for(x=1;(x<LINE_SIZE) && (buffer[x]<THRESHOLD);x++);
            if(x<LINE_SIZE) ybuf[y]=LINE_SIZE-x;  /* if transition then distance shade */
            else ybuf[y]=0;           /*else empty */
        }
        fclose(fn);              /*close scan file */
        fwrite(ybuf,1,LINE_SIZE,fd);
        printf("did %d \n",z);
    }
    fclose(fd);                /* close output file */
}


/**********************************************************/
/**** MAIN ***** MAIN ***** MAIN ***** MAIN ***** MAIN ****/
/**********************************************************/
main()
{
    /* first get some parameters from user */
    printf("Enter Starting scan number: ");
    scanf("%d",&FIRSTSLICE);
    printf("Enter ending scan number: ");
    scanf("%d",&LASTSLICE);
    printf("Enter threshold number: ");
    scanf("%d",&THRESHOLD);
    THRESHOLD+=1024;

    create_distance_shades();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -