fangq / mcx

Monte Carlo eXtreme (MCX) - GPU-accelerated photon transport simulator
http://mcx.space
Other
127 stars 71 forks source link

Bug in mcxplotshapes #227

Closed ChenJY-L closed 2 months ago

ChenJY-L commented 2 months ago

Dear Prof. Fang Qianqian: MCX is an amazing repo. There is a bug in mcxpreview.m dealing with "Grid", "Box" and "subgrid". The originate of box doesn't change acroing to my settings. cfg.shapes=['{ "Shapes":['... '{"ZLayers":[[1,2,2]]}, {"Box": {"Tag":3, "O":[50,50,50], "Size":[50,50,10]}}' ... '] }']; Because of the code in https://github.com/fangq/mcx/blob/80b57941cea33e10ab369723846108606d1cdba6/utils/mcxplotshapes.m#L72-L83

I tried to fix it using these code. Thanks for this amazing work again. Best wishes. Jiayu Chen

case {'Grid','Box','Subgrid'}
      if(strcmp(sname{1},'Grid') && ~isempty(hseg))
          delete(hseg);
          hseg=[];
      end
      obj=shp.(sname{1});
      if(isfield(obj,'Tag'))
          tag=obj.Tag;
      end

      gridsize=obj.Size;
      if(isfield(obj, 'O'))
          [no,fc]=latticegrid([obj.O(1) obj.Size(1)+obj.O(1)],[obj.O(2) obj.Size(2)+obj.O(2)],[obj.O(3) obj.Size(3)+obj.O(3)]);
      else
          [no,fc]=latticegrid([0 obj.Size(1)],[0 obj.Size(2)],[0 obj.Size(3)]);
      end
      hseg(end+1)=plotmesh(no*voxelsize,fc,'facealpha',0.3, 'linestyle', '-', 'facecolor','none', varargin{:});
fangq commented 2 months ago

thanks for reporting this and the patch. it should be fixed now in b17cb1a