[vtkusers] Export data from VTK to ITK

Massi Massinissa.Bandou at USherbrooke.ca
Wed Oct 3 10:41:04 EDT 2012


Hello everyone!
I'm trying to send mesh data produced from the contour of a volume of dicom
series via VTK to ITK. My goal is to do a surface registration with another
mesh file but I'm stuck with an error saying :

c:.../ITK-4.1/itkImageFileWriter.hxx:202: error: 'ImageDimension' is not a
member of 'itk::Mesh<float, 3u, itk::DefaultStaticMeshTraits&lt;float, 3u,
3u, float, float, float> >'

Here is my code (using ITK4.1 , VTK5.10 on Win8 64bits)

#include "vtkDICOMImageReader.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataConnectivityFilter.h"
#include "vtkImageExport.h"
#include "itkVTKImageImport.h"
#include "itkMesh.h"
#include "itkImageFileWriter.h"

int main(int argc, char *argv[]) {

vtkSmartPointer<vtkDICOMImageReader> Read = 
vtkSmartPointer<vtkDICOMImageReader>::New();
Read->SetDirectoryName(filename.c_str());
Read->Update();
    
//Get the contour of the PolyData
vtkSmartPointer<vtkContourFilter> contour =
vtkSmartPointer<vtkContourFilter>::New();
contour->SetInput(Read->GetOutput());
contour->ComputeScalarsOff();
contour->SetValue(0,0.5);
    
//Mesh the largest contour
vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
connectivityFilter->SetInput(contour->GetOutput());
connectivityFilter->SetExtractionModeToLargestRegion();
connectivityFilter->Update();
    
//Export vtk Data to ITK
vtkImageExport* exportdata = vtkImageExport::New();
exportdata->SetInput(connectivityFilter->GetOutput());
    
const unsigned int Dimension = 3;
typedef float PixelType;
typedef itk::Mesh< PixelType, Dimension > MeshType;
typedef itk::ImageFileWriter<MeshType> WriteMeshType;
typedef itk::VTKImageImport<MeshType> importMeshType;
    
WriteMeshType::Pointer WMeshType = WriteMeshType::New();
importMeshType::Pointer IMeshType = importMeshType::New();
exportdata->SetOutput(IMeshType);
IMeshType->Update();
WMeshType->SetInput(IMeshType->GetOutput());

return EXIT_SUCCESS;;
}

thank you for your help!!

Massi



--
View this message in context: http://vtk.1045678.n5.nabble.com/Export-data-from-VTK-to-ITK-tp5716418.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list