Ok so continuing on with my get my data into vtk from matlab using vtkMatlabMexAdapter I am a little confused as to how to get volume data 3 Dimensons of doubles from matlab to vtk. <br><br>If I try SetScalars and use <a class="el" href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html#ac8bfd9b0924b30a14a687bc3fab5c895">mxArrayTovtkDataArray</a> which takes const mxArray* (note use of keyword const) and coverts to vtkDataArray* I am told the reason for the errors in the terminal window are due to the fact that vtkDataArray only takes 2 dimensional data. If I try <a class="el" href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html#ae2f0c67e85d760929a64a37f0fe3ab54">mxArrayTovtkArray </a>which converts mxArray* I can no longer call SetScalars as it takes type vtkDataArray. Now I am sure there is a reason for the use of const in some functions but not others but to call <a class="el" href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html#ae2f0c67e85d760929a64a37f0fe3ab54">mxArrayTovtkArray</a>
(mxArray *mxa) I must first cast mxa to mxArray* as the array in Matlab is of const type : void mexFunction(int nlhs, mxArray *plhs[],<br>int nrhs, const mxArray *prhs[]). If I use <a class="el" href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html#ae2f0c67e85d760929a64a37f0fe3ab54">mxArrayTovtkArray </a>then I think I need to dynamic cast to vtkTypedArray<double> or maybe vtkDenseArray<double> though I cannot include the header files. I have used -DVTK_USE_N_WAY_ARRAYS=YES -DVTKSNL_N_WAY_ARRAYS=ON and -DVTK_USE_MATLAB_MEX=YES in my build of vtk. If I use <a class="el" href="http://www.vtk.org/doc/nightly/html/classvtkMatlabMexAdapter.html#ae2f0c67e85d760929a64a37f0fe3ab54">mxArrayTovtkArray
</a>where is the means to get this into vtkImageData as 3D of doubles?<br><br>Also the calls to create the vtk pipeline are somewhat verbose anyone in vtk programmer land ever look at using Boost.Dataflow <a href="http://dancinghacker.com/code/dataflow/dataflow/support/examples/new_layer.html">http://dancinghacker.com/code/dataflow/dataflow/support/examples/new_layer.html</a> to define the pipeline?<br>
<br>my use of vtkImageData requiring use of vtkDataArray<br>-snip-<br>vtkImageData* image = vtkImageData::New();<br><br> image->SetDimensions( numeric_cast<int>(y_dim) , numeric_cast<int>(x_dim), numeric_cast<int>(z_dim) );<br>
image->SetOrigin(0.0, 0.0, 0.0);<br><br> #ifndef USE_VTKMATLABMEXADAPTER<br> image->GetPointData()->SetScalars(dataArray);<br> #else<br> image->GetPointData()->SetScalars(volumeData);<br> #endif<br>
// image->GetPointData()->SetScalars(dataArray);<br><br>my build of vtk<br><br>-snip-<br>SET( THIRD_PARTY_PACKAGES<br> vtk-${VTK_LIB_VERSION}<br> VTKEdge-5-4-0<br> dcmtk-3.5.4<br> ${BOOST_PACKAGE}<br>
)<br><br>SET( VTK_DEFINES<br> -DVTKEdge_USE_CUDA=YES<br> -DVTKEdge_USE_DIRECTX=YES<br> -DVTKEdge_BUILD_EXAMPLES=YES<br> -DVTK_USE_PARALLEL=YES<br> -DBUILD_SHARED_LIBS=YES<br> -DVTK_DIR=${INSTALL_PREFIX}<br>
-DBUILD_SHARED_LIBS=YES<br> -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_TOOLKIT_ROOT_DIR}<br> -DCUDA_SDK_ROOT_DIR=${CUDA_SDK_ROOT_DIR}<br># -DCUDA_CUTIL_INCLUDE_DIR=${CUDA_CUTIL_INCLUDE_DIR}<br> -DCUDA_CUTIL_LIBRARY=${CUDA_CUTIL_LIBRARY}<br>
# -DCUDA_LIBRARIES=${CUDA_LIBRARIES}<br> -DVTK_USE_N_WAY_ARRAYS=YES<br> -DVTKSNL_N_WAY_ARRAYS=ON<br> -DVTK_USE_MATLAB_MEX=YES<br> )<br><br><br><br>foreach( PACKAGE ${THIRD_PARTY_PACKAGES} )<br><br> ExternalProject_Add(<br>
${PACKAGE}<br> DOWNLOAD_COMMAND ""<br> SOURCE_DIR ${TOP}/source/cpp/lib/3rdParty/Win/${PACKAGE}<br> BINARY_DIR ${BUILD_DIR}/ouput/bin/${PACKAGE}<br> INSTALL_DIR ${INSTALL_PREFIX}<br>
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DINSTALL_PREFIX=${INSTALL_PREFIX}<br> ${VTK_DEFINES}<br> ${BOOST_PACKAGE_DEFS}<br> )<br>-end snip-<br><br>Not sure if I am better served going back to the use of SetVoidArray?<br>
<br>-snip-<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> vtkImageData* image = vtkImageData::New();<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>
image->GetPointData()->SetScalars(dataArray);<br>-end snip-<br><br>Brian<br>