[vtkusers] Voxel Data from MATLAB to VTK
Brian Davis
bitminer at gmail.com
Thu May 20 17:25:42 EDT 2010
So I create an *instance* of vtkMatlabMexAdapter and it compiles and runs,
but then I get:
-snip-
Generic Warning: In
..\..\..\..\..\..\source\cpp\lib\3rdParty\Win\vtk-5.6.0\Graphics\vtkMatlabMexAdapter.cxx,
line 460
Input to mxArrayTovtkDataArray() has more than two dimensions, cannot
convert to vtkDataArray
ERROR: In
..\..\..\..\..\..\source\cpp\lib\3rdParty\Win\VTKEdge-5-4-0\VolumeRendering\vtkKWEGPUVolumeRayCastMapper.cxx,
line 270
vtkKWEOpenGLGPUVolumeRayCastMapper (000000000C1B61E0): No scalars found on
input.
-end snip-
in the status window. So I search:
http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html
for the words "two" and "dimension" hoping to find the error of my ways. No
luck. Any have any ideas?
My code:
-snip-
double *volumeData;
for (int i = 0; i < nrhs; i++)
{
if( mxGetNumberOfDimensions( prhs[i] ) != 3 )
{
mexErrMsgTxt("Render volume can only accept matrix of 3
dimensions");
return;
}
// Get the dimensions
const mwSize* matDimensions = mxGetDimensions( prhs[i] );
y_dim = matDimensions[0];
x_dim = matDimensions[1];
z_dim = matDimensions[2];
mexPrintf( "y_dim = %d, x_dim = %d, z_dim = %d \n", y_dim, x_dim,
z_dim );
volumeData = mxGetPr(prhs[i]);
}
image->SetDimensions( numeric_cast<int>(y_dim) ,
numeric_cast<int>(x_dim), numeric_cast<int>(z_dim) );
// image->SetSpacing(1.0, 1.0, 1.0);
image->SetOrigin(0.0, 0.0, 0.0);
vtkDoubleArray* dataArray = vtkDoubleArray::New();
// Set the array to point to data
dataArray->SetVoidArray( (void *) volumeData, y_dim*x_dim*z_dim , 1);
image->GetPointData()->SetScalars(dataArray);
-end snip-
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.
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100520/1a51b803/attachment.htm>
More information about the vtkusers
mailing list