00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00025 #ifndef _MMC_UTILITIES_H
00026 #define _MMC_UTILITIES_H
00027
00028 #include <stdio.h>
00029 #include <vector_types.h>
00030
00031 #define MAX_PROP 256
00032 #define MAX_DETECTORS 256
00033 #define MAX_PATH_LENGTH 1024
00034 #define MAX_SESSION_LENGTH 256
00035 #define MIN(a,b) ((a)<(b)?(a):(b))
00036
00037 #define MMCDEBUG(cfg,debugflag,outputstr) {\
00038 if((cfg)->debuglevel & (debugflag)) {\
00039 fprintf outputstr ;\
00040 fflush((cfg)->flog);\
00041 }\
00042 }
00043
00044 enum TDebugLevel {dlMove=1,dlTracing=2,dlBary=4,dlWeight=8,dlDist=16,dlTracingEnter=32,
00045 dlTracingExit=64,dlEdge=128,dlAccum=256,dlTime=512,dlReflect=1024,
00046 dlProgress=2048};
00047
00048
00058 typedef struct MMC_medium{
00059 float mua;
00060 float mus;
00061 float n;
00062 float g;
00063 } medium;
00064
00065
00066
00073 typedef struct MMC_config{
00074 int nphoton;
00077
00078 int nblocksize;
00079 int nthread;
00080 int seed;
00082 float3 srcpos;
00083 float3 srcdir;
00084 float tstart;
00085 float tstep;
00086 float tend;
00087 float3 steps;
00089 uint3 dim;
00090 uint3 crop0;
00091 uint3 crop1;
00092 int medianum;
00093 int detnum;
00094 float detradius;
00095 float sradius;
00099 medium *prop;
00100 float4 *detpos;
00101 float minstep;
00103 int maxgate;
00104 int respin;
00105 int printnum;
00107 unsigned char *vol;
00108 char session[MAX_SESSION_LENGTH];
00109 char meshtag[MAX_PATH_LENGTH];
00110 char isrowmajor;
00111 char isreflect;
00112 char isref3;
00113 char isnormalized;
00114 char issavedet;
00115 char issave2pt;
00116 char isgpuinfo;
00117 char basisorder;
00118 float roulettesize;
00119 float minenergy;
00120 float nout;
00121 FILE *flog;
00122 char rootpath[MAX_PATH_LENGTH];
00123 unsigned int debuglevel;
00124 float unitinmm;
00125 } Config;
00126
00127 #ifdef __cplusplus
00128 extern "C" {
00129 #endif
00130 void mcx_savedata(float *dat,int len,Config *cfg);
00131 void mcx_error(int id,char *msg);
00132 void mcx_loadconfig(FILE *in, Config *cfg);
00133 void mcx_saveconfig(FILE *in, Config *cfg);
00134 void mcx_readconfig(char *fname, Config *cfg);
00135 void mcx_writeconfig(char *fname, Config *cfg);
00136 void mcx_initcfg(Config *cfg);
00137 void mcx_clearcfg(Config *cfg);
00138 void mcx_parsecmd(int argc, char* argv[], Config *cfg);
00139 void mcx_usage(char *exename);
00140 void mcx_loadvolume(char *filename,Config *cfg);
00141 void mcx_normalize(float field[], float scale, int fieldlen);
00142 int mcx_readarg(int argc, char *argv[], int id, void *output,char *type);
00143 void mcx_printlog(Config *cfg, char *str);
00144 int mcx_remap(char *opt);
00145 int mcx_parsedebugopt(char *debugopt);
00146 void mcx_progressbar(unsigned int n, unsigned int ntotal, Config *cfg);
00147
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151
00152 #endif