So I create an *instance* of vtkMatlabMexAdapter and it compiles and runs, but then I get:<br><br>-snip-<br>Generic Warning: In ..\..\..\..\..\..\source\cpp\lib\3rdParty\Win\vtk-5.6.0\Graphics\vtkMatlabMexAdapter.cxx, line 460<br>
Input to mxArrayTovtkDataArray() has more than two dimensions, cannot convert to vtkDataArray<br><br>ERROR: In ..\..\..\..\..\..\source\cpp\lib\3rdParty\Win\VTKEdge-5-4-0\VolumeRendering\vtkKWEGPUVolumeRayCastMapper.cxx, line 270<br>
vtkKWEOpenGLGPUVolumeRayCastMapper (000000000C1B61E0): No scalars found on input.<br>-end snip-<br><br>in the status window. So I search:<br><br><a href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html">http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html</a><br>
<br>for the words "two" and "dimension" hoping to find the error of my ways. No luck. Any have any ideas?<br><br>My code:<br><br>-snip-<br> double *volumeData;<br><br><br> for (int i = 0; i < nrhs; i++)<br>
{<br><br> if( mxGetNumberOfDimensions( prhs[i] ) != 3 )<br> {<br> mexErrMsgTxt("Render volume can only accept matrix of 3 dimensions");<br> return;<br> }<br><br> // Get the dimensions<br>
const mwSize* matDimensions = mxGetDimensions( prhs[i] );<br><br> y_dim = matDimensions[0];<br> x_dim = matDimensions[1];<br> z_dim = matDimensions[2];<br><br> mexPrintf( "y_dim = %d, x_dim = %d, z_dim = %d \n", y_dim, x_dim, z_dim );<br>
<br> volumeData = mxGetPr(prhs[i]);<br> }<br><br> image->SetDimensions( numeric_cast<int>(y_dim) , numeric_cast<int>(x_dim), numeric_cast<int>(z_dim) );<br>// image->SetSpacing(1.0, 1.0, 1.0);<br>
image->SetOrigin(0.0, 0.0, 0.0);<br><br> vtkDoubleArray* dataArray = vtkDoubleArray::New();<br>
<br>
// Set the array to point to data<br>
dataArray->SetVoidArray( (void *) volumeData, y_dim*x_dim*z_dim ,
1);<br>
<br> image->GetPointData()->SetScalars(dataArray);<br><br><br>-end snip-<br><br>Did show my volume when using CPU rendering. However switching to GPU rendering would lock up. I was hoping that I was doing something wrong and vtkMatlabMexAdapter would be the answer for both CPU and GPU.<br>
<br>Brian<br>