3DShapeNets icon indicating copy to clipboard operation
3DShapeNets copied to clipboard

Error using polygon2voxel_double Requested 515396075640x140711718551672x140719189273184 (17179869184.0GB) array exceeds maximum array size preference

Open jawhster opened this issue 7 years ago • 6 comments

I ran polygon2voxeldemo with example function below and receive error that array exceeds maximum array size preference. Any ideas? Thanks, Justin

polygon2voxeldemo Error using polygon2voxel_double Requested 515396075640x140711718551672x140719189273184 (17179869184.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in polygon2voxel (line 171) Volume=polygon2voxel_double(FacesA,FacesB,FacesC,VerticesX,VerticesY,VerticesZ,VolumeSize,Wrap);

Error in polygon2voxeldemo (line 35) J = polygon2voxel(FV,[120, 120, 120],'none');

% Make A Volume with a few blocks
  I = false(120,120,120);
  I(40:60,50:70,60:80)=1; I(60:90,45:75,60:90)=1;
  I(20:60,40:80,20:60)=1; I(60:110,35:85,10:60)=1;

  % Convert the volume to a triangulated mesh
  FV = isosurface(I,0.8);

  % Convert the triangulated mesh back to a surface in a volume
  J = polygon2voxel(FV,[120, 120, 120],'none'); 
  % Fill the volume
  J=imfill(J,'holes');

  % Differences between original and reconstructed
  VD = abs(J-I);

  % Show the original Mesh and Mesh of new volume
  figure, 
  subplot(1,3,1),  title('original')
    patch(FV,'facecolor',[1 0 0],'edgecolor','none'), camlight;view(3);
  subplot(1,3,2), title('converted');
    patch(isosurface(J,0.8),'facecolor',[0 0 1],'edgecolor','none'), camlight;view(3);
  subplot(1,3,3), title('difference');
    patch(isosurface(VD,0.8),'facecolor',[0 0 1],'edgecolor','none'), camlight;view(3); 

jawhster avatar Aug 31 '17 23:08 jawhster

Update: unfortunately, still problem with this. Nevermind. I think that I should follow the code in polygon2voxel.m without uncommenting the previous examples. I'll give it a try. Thanks, Justin

jawhster avatar Sep 01 '17 00:09 jawhster

this is probably some change from the newer version of matlab. In polygon2voxel_double.c, VolumeDims is being fed into mxCreateLogicalArray but is not an array of mwSize. A quick fix is to: create an mwSize array and an int array for dimensions and pass the mwSize array to mxCreateLogicalArray() and pass the int array or draw_or_split().

mwSize VolumeDims[3] = {0, 0, 0}; int VolumeDimsInt[3]={0,0,0}; ... VolumeDims[0]=(int)VolumeSize[0]; VolumeDims[1]=(int)VolumeSize[1]; VolumeDims[2]=(int)VolumeSize[2]; VolumeDimsInt[0]=(int)VolumeSize[0]; VolumeDimsInt[1]=(int)VolumeSize[1]; VolumeDimsInt[2]=(int)VolumeSize[2]; ... plhs[0] = mxCreateLogicalArray(3, VolumeDims); ... Volume=draw_or_split(Volume,AX,AY,AZ,BX,BY,BZ,CX,CY,CZ,VolumeDimsInt,wrap);

gregoryenriquez avatar Oct 30 '17 05:10 gregoryenriquez

I met the same problem. This is caused by the data type conversion in c. Open the file polygon2voxel_double(called by polygon2voxel) and replace 'int VolumeDims[3]={0,0,0};' to 'mwSize VolumeDims[3]={0,0,0};' .Then reconpile the c file. It may works.

tasx0823 avatar Apr 17 '18 12:04 tasx0823

It's also possible to compile with mex using the setting -compatibleArrayDims, like so: mex(filename.c,'-compatibleArrayDims') Though Matlab might stop supporting that option in the future. More in the documentation

DahnJ avatar Sep 17 '18 09:09 DahnJ

wow this saved me so much time thank you all

hsw28 avatar Jul 22 '20 20:07 hsw28

It's also possible to compile with mex using the setting -compatibleArrayDims, like so: mex(filename.c,'-compatibleArrayDims') Though Matlab might stop supporting that option in the future. More in the documentation

Your solution has saved me hours sir. I went through nearly 100 queries on MATLAB forum, none seem to work. Thanks again!

viren3999 avatar Sep 14 '20 10:09 viren3999