mex function for MMCLAB More...
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <exception>
#include "mex.h"
#include "mmc_const.h"
#include "mmc_mesh.h"
#include "mmc_host.h"
#include "mmc_tictoc.h"
#include "mmc_raytrace.h"
Macros | |
#define | GET_1ST_FIELD(x, y) if(strcmp(name,#y)==0) {double *val=mxGetPr(item);x->y=val[0];printf("mmc.%s=%g;\n",#y,(float)(x->y));} |
Macro to read the 1st scalar cfg member. | |
#define | GET_ONE_FIELD(x, y) else GET_1ST_FIELD(x,y) |
Macro to read one scalar cfg member. | |
#define | GET_VEC3_FIELD(u, v) |
Macro to read one 3-element vector member of cfg. More... | |
#define | GET_VEC34_FIELD(u, v) |
Macro to read one 3- or 4-element vector member of cfg. More... | |
#define | GET_VEC4_FIELD(u, v) |
Macro to read one 4-element vector member of cfg. More... | |
#define | SET_GPU_INFO(output, id, v) mxSetField(output,id,#v,mxCreateDoubleScalar(gpuinfo[i].v)); |
#define | ABS(a) ((a)<0?-(a):(a)) |
#define | MAX(a, b) ((a)>(b)?(a):(b)) |
#define | MEXERROR(a) mcx_error(999,a,__FILE__,__LINE__) |
Typedefs | |
typedef mwSize | dimtype |
Functions | |
void | mmc_set_field (const mxArray *root, const mxArray *item, int idx, mcconfig *cfg, tetmesh *mesh) |
MATLAB type alias for integer type to use for array sizes and dimensions. More... | |
void | mmc_validate_config (mcconfig *cfg, tetmesh *mesh) |
Validate all input fields, and warn incompatible inputs. More... | |
void | mmclab_usage () |
Print a brief help information if nothing is provided. | |
void | mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) |
Mex function for the MMC host function for MATLAB/Octave This is the master function to interface all MMC features inside MATLAB. In MMCLAB, all inputs are read from the cfg structure, which contains all simuation parameters and data. More... | |
int | mmc_throw_exception (const int id, const char *msg, const char *filename, const int linenum) |
Error reporting function in the mex function, equivallent to mcx_error in binary mode. More... | |
void | mcx_matlab_flush () |
Force matlab refresh the command window to print all buffered messages. | |
mex function for MMCLAB
#define GET_VEC34_FIELD | ( | u, | |
v | |||
) |
Macro to read one 3- or 4-element vector member of cfg.
#define GET_VEC3_FIELD | ( | u, | |
v | |||
) |
Macro to read one 3-element vector member of cfg.
#define GET_VEC4_FIELD | ( | u, | |
v | |||
) |
Macro to read one 4-element vector member of cfg.
Macro to output GPU parameters as field
void mexFunction | ( | int | nlhs, |
mxArray * | plhs[], | ||
int | nrhs, | ||
const mxArray * | prhs[] | ||
) |
Mex function for the MMC host function for MATLAB/Octave This is the master function to interface all MMC features inside MATLAB. In MMCLAB, all inputs are read from the cfg structure, which contains all simuation parameters and data.
If no input is given for this function, it prints help information and return.
If a single string is passed, and if this string is 'gpuinfo', this function returns the list of GPUs on this host and return.
If a structure is passed to this function, a simulation will be launched.
Find out information about input and output.
The function can return 1-3 outputs (i.e. the LHS)
Loop over each element of the struct if it is an array, each element is a simulation
Enclose all simulation calls inside a try/catch construct for exception handling
Initialize cfg with default values first
Read each struct element from input and set value to the cfg configuration
Overwite the output flags using the number of output present
save fluence rate to the 1st output if present
save detected photon data to the 2nd output if present
save detected photon seeds to the 3rd output if present
Validate all input fields, and warn incompatible inputs
Clear up simulation data structures by calling the destructors
if the 2nd output presents, output the detected photon partialpath data
save diffuse reflectance
void mmc_set_field | ( | const mxArray * | root, |
const mxArray * | item, | ||
int | idx, | ||
mcconfig * | cfg, | ||
tetmesh * | mesh | ||
) |
MATLAB type alias for integer type to use for array sizes and dimensions.
Function to parse one subfield of the input structure.
This function reads in all necessary information from the cfg input structure. it can handle single scalar inputs, short vectors (3-4 elem), strings and arrays.
[in] | root | the cfg input data structure |
[in] | item | the current element of the cfg input data structure |
[in] | idx | the index of the current element (starting from 0) |
[out] | cfg | the simulation configuration structure to store all input read from the parameters |
[out] | mesh | the mesh data structure |
int mmc_throw_exception | ( | const int | id, |
const char * | msg, | ||
const char * | filename, | ||
const int | linenum | ||
) |
Error reporting function in the mex function, equivallent to mcx_error in binary mode.
[in] | id | a single integer for the types of the error |
[in] | msg | the error message string |
[in] | filename | the unit file name where this error is raised |
[in] | linenum | the line number in the file where this error is raised |