[vtkusers] Voxel Data from MATLAB to VTK

Brian Davis bitminer at gmail.com
Thu May 20 16:39:41 EDT 2010


So I upgraded to 5.6 to get vtkMatlabMexAdapter and....

The following code from
http://www.kitware.com/products/archive/kitware_quarterly1009.pdf

--snip--
void mexFunction(int nlhs,
mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
{
vtkDataArray* pointdata = (vtkDataArray*)
vtkMatlabMexAdapter::
mxArrayTovtkDataArray(prhs[0]);
vtkPoints* points = vtkPoints::New();
points->SetData(pointdata);
pointdata->Delete();
vtkPolyData* pointCloud = vtkPolyData::New();
pointCloud->SetPoints(points);
points->Delete();
vtkDelaunay2D* d2d = vtkDelaunay2D::New();
d2d->SetInput(pointCloud);
}

--end snip-

uses vtkMatlabMexAdapter::mxArrayTovtkDataArray(prhs[0]); as a static C++
call using the resolution operator::.  Problem is I get:

-snip-
1>..\..\..\..\..\..\..\..\source\Matlab\lib\dsaLib\visualization\vtk\showVolume3D\volume_render.cpp(117)
: error C2352: 'vtkMatlabMexAdapter::mxArrayTovtkDataArray' : illegal call
of non-static member function
1>
C:\Users\bdavis5\Documents\QS\QS-NIH\source\branches\trunk\build\Windows-6.0\install\include\vtk-5.6\vtkMatlabMexAdapter.h(84)
: see declaration of 'vtkMatlabMexAdapter::mxArrayTovtkDataArray'
1>..\..\..\..\..\..\..\..\source\Matlab\lib\dsaLib\visualization\vtk\showVolume3D\volume_render.cpp(307)
: error C2664: 'vtkDataSetAttributes::SetScalars' : cannot convert parameter
1 from 'double *' to 'vtkDataArray *'
-end snip-

because the vtkMatlabMexAdapter class does not have mxArrayTovtkDataArray as
a static class function.  As seen from vtkMatlabMexAdapter.h:

-snip-
  // Description:
  // Create a vtkDataArray copy of a Matlab mxArray (Allocates memory by
default)
  vtkDataArray* mxArrayTovtkDataArray(const mxArray* mxa, bool ShallowCopy =
false);
-end snip-

The following URL has an example similar to kitware quarterly pdf.
http://www.kitware.com/InfovisWiki/index.php/Matlab_Interface

Curious on which it should be.... an object for which I should create an
instance? or static class function?

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100520/7f944b14/attachment.htm>


More information about the vtkusers mailing list