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

📄 layer-xyz2mod.c

📁 射线追踪程序
💻 C
字号:
/* * This file is part of tomo3d * * Copyright (C) 2002, 2003, Sebastien Judenherc <sebastien.judenherc@na.infn.it> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 * USA * *//* Lecture d'un fichier "layer" et ecriture d'un fichier "block" * exemple de fichier "layer":48.0 -2.0      40  10.0    40   10.0    10.0    5.8648.0 -2.0      20  20.0    20   20.0    20.0    6.8148.0 -2.0      15  30.0    15   30.0    30.0    7.848.0 -2.0      15  30.0    15   30.0    30.0    7.8748.0 -2.0      15  30.0    15   30.0    30.0    7.9448.0 -2.0      15  30.0    15   30.0    30.0    8.09 * * */#include <stdio.h>#include <stdlib.h>#include "tomo3d.h"struct xyzv_t { float x, y, z, v; };int main(int argc, char **argv){        struct block_t * blk=NULL;        struct layer_t *layers;        struct xyzv_t *xyzv=NULL;         int nxyzv=0;        FILE *f;        int nbl,nbb,k,i;        if (argc<3) {                fprintf(stderr,"%s <layer-cfg-file> <xyzmodel>\n",argv[0]);                exit(0);        }        if ((f=fopen(argv[2],"rt"))==NULL) {                perror(argv[2]);                exit(0);        }        xyzv=(struct xyzv_t *)malloc(sizeof(struct xyzv_t));        fscanf(f,"%f %f %f %f",&(xyzv[0].x),&(xyzv[0].y),&(xyzv[0].z),                        &(xyzv[0].v));        while (!feof(f)) {                nxyzv++;                xyzv=(struct xyzv_t *)realloc(xyzv,(nxyzv+1)*sizeof(struct xyzv_t));                fscanf(f,"%f %f %f %f",&(xyzv[nxyzv].x),&(xyzv[nxyzv].y),                                &(xyzv[nxyzv].z),&(xyzv[nxyzv].v));        }        fclose(f);        if ((blk=readlayers(argv[1], &nbb, &layers, &nbl))==NULL) exit(0);        fprintf(stderr,"nxyzv=%d, nbb=%d\n",nxyzv,nbb);        for (i=0; i<nbb; i++)                blk[i].L=blk[i].dV=0.0;        k=0;        for (i=0; i<nxyzv; i++) {                if (!(i%250)) { fprintf(stderr,"."); fflush(stderr); }                k=blocknum(xyzv[i].x,xyzv[i].y,xyzv[i].z,blk,nbb,k);                if (k<0) {                        fprintf(stderr,"i=%d %f %f %f k=-1\n",                                        i,xyzv[i].x,xyzv[i].y,xyzv[i].z);                        exit(0);                }                blk[k].dV+=xyzv[i].v;                blk[k].L+=1.0;        }        fprintf(stderr,"\n");        for (i=0; i<nbb; i++) {                if (blk[i].L>0.5) {                        blk[i].dV/=(100.*blk[i].L);                        fprintf(stderr,"."); fflush(stderr);                }                /*blk[i].V*=(1.+blk[i].dV);*/        }        printlayers(stderr,layers,nbl);        printblocks(stdout,blk,nbb);        return(0);}

⌨️ 快捷键说明

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