Skip to content

Commit

Permalink
[bug] fix mmclab compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 11, 2024
1 parent 805a59f commit 6346ecd
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/meshtest/mesh0.inp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
0. 0. 1. # initial directional vector
0.e+00 5.e-09 1e-10 # time-gates(s): start, end, step
mesh0 # volume ('uchar' format)
8 # index of elem that encloses the source
3 # index of elem that encloses the source
4 1 # detector number and radius (mm)
30.0 20.0 0.0 # detector 1 position (mm)
30.0 40.0 0.0 # ...
Expand Down
2 changes: 1 addition & 1 deletion examples/meshtest/mesh0.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Mesh": {
"MeshID": "mesh0",
"InitElem": 8
"InitElem": 3
},
"Session": {
"Photons": 1000000,
Expand Down
2 changes: 1 addition & 1 deletion examples/meshtest/mesh1.inp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
0. 0. 1. # initial directional vector
0.e+00 5.e-09 1.e-10 # time-gates(s): start, end, step
mesh1 # volume ('uchar' format)
3 # index of elem that encloses the source
5 # index of elem that encloses the source
4 1 # detector number and radius (mm)
30.0 20.0 0.0 # detector 1 position (mm)
30.0 40.0 0.0 # ...
Expand Down
2 changes: 1 addition & 1 deletion examples/meshtest/mesh1.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Mesh": {
"MeshID": "mesh1",
"InitElem": 3
"InitElem": 5
},
"Session": {
"Photons": 1000000,
Expand Down
2 changes: 1 addition & 1 deletion examples/meshtest/mesh2.inp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
0. 0. 1. # initial directional vector
0.e+00 5.e-09 1.e-10 # time-gates(s): start, end, step
mesh2 # volume ('uchar' format)
8 # index of elem that encloses the source
7 # index of elem that encloses the source
4 1 # detector number and radius (mm)
30.0 20.0 0.0 # detector 1 position (mm)
30.0 40.0 0.0 # ...
Expand Down
2 changes: 1 addition & 1 deletion examples/meshtest/mesh2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Mesh": {
"MeshID": "mesh2",
"InitElem": 8
"InitElem": 7
},
"Session": {
"Photons": 1000000,
Expand Down
6 changes: 3 additions & 3 deletions examples/meshtest/run_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

time ../../bin/mmc -f mesh0.inp -s mesh0 -n 30000000 -b 0 -l -D TP
time ../../bin/mmc -f mesh1.inp -s mesh1 -n 30000000 -b 0 -l -D TP
time ../../bin/mmc -f mesh2.inp -s mesh2 -n 30000000 -b 0 -l -D TP
time ../../bin/mmc -f mesh0.inp -s mesh0 -n 30000000 -b 0 -D TP $@
time ../../bin/mmc -f mesh1.inp -s mesh1 -n 30000000 -b 0 -D TP $@
time ../../bin/mmc -f mesh2.inp -s mesh2 -n 30000000 -b 0 -D TP $@

6 changes: 5 additions & 1 deletion matlab/savemmcmesh.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ function savemmcmesh(key, node, elem, varargin)
% License: GPLv3, see http://mcx.sf.net/mmc/ for details
%

opt = varargin2struct(varargin{:});
if(~isempty(varargin) && ischar(varargin{1}))
opt = varargin2struct(varargin{:});
else
opt = struct;
end

if (nargin < 5 || isempty(jsonopt('evol', [], opt)))
evol = elemvolume(node, elem(:, 1:4));
Expand Down
6 changes: 4 additions & 2 deletions src/mmc_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,9 +2241,9 @@ void mcx_savejdata(char* filename, mcconfig* cfg) {
/* save "Shapes" constructs, containing InitElem, MeshNode, MeshElem, and MeshROI */
cJSON_AddItemToObject(root, "Shapes", obj = cJSON_CreateObject());

if (cfg->meshtag[0]) {
if (cfg->meshtag[0] && cfg->nodenum == 0) {
cJSON_AddStringToObject(obj, "MeshID", cfg->meshtag);
} else {
} else if (cfg->nodenum && cfg->elemnum) {
uint dims[2] = {0};
cJSON_AddItemToObject(obj, "MeshNode", sub = cJSON_CreateObject());

Expand Down Expand Up @@ -2273,6 +2273,8 @@ void mcx_savejdata(char* filename, mcconfig* cfg) {
MMC_ERROR(-10, "saving mesh ROI data to JSON failed");
}
}
} else {
MMC_ERROR(-10, "incomplete mesh data");
}

cJSON_AddNumberToObject(obj, "InitElem", cfg->e0);
Expand Down
4 changes: 3 additions & 1 deletion src/mmclab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void mmc_set_field(const mxArray* root, const mxArray* item, int idx, mcconfig*
void mmc_validate_config(mcconfig* cfg, tetmesh* mesh);
void mmclab_usage();

extern const char debugflag[];

/** @brief 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
Expand Down Expand Up @@ -729,7 +731,7 @@ void mmc_set_field(const mxArray* root, const mxArray* item, int idx, mcconfig*
mexWarnMsgTxt("not enough space. string is truncated.");
}

cfg->debuglevel = mcx_parsedebugopt(buf);
cfg->debuglevel = mcx_parsedebugopt(buf, debugflag);
printf("mmc.debuglevel='%s';\n", buf);
} else if (strcmp(name, "srctype") == 0) {
int len = mxGetNumberOfElements(item);
Expand Down

0 comments on commit 6346ecd

Please sign in to comment.