[Insight-users] Show 3d image data by vtk, cont'
jiang
jiang at TI . Uni-Trier . DE
Thu, 25 Sep 2003 16:40:54 +0200
Hi Luis,
Thank you for your hint. I modify my code according the example
itkImageToVTKImage, and try to render it by VTK:
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
// renWin->SetParentId(mainFm); It doesn't work! :(
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin); // It also doesn't work
typedef itk::VTKImageExport<ImageNDType> ExportType;
ExportType::Pointer connector;
connector= ExportType::New();
connector->SetInput( reader->GetOutput() );//reader gets a series of DICOM
files.
/*Create a pipeline ITK-->VTK*/
vtkImageImport* importer = vtkImageImport::New();
importer->SetUpdateInformationCallback(connector->GetUpdateInformationCallba
ck());
importer->SetPipelineModifiedCallback(connector->GetPipelineModifiedCallback
());
importer->SetWholeExtentCallback(connector->GetWholeExtentCallback());
importer->SetSpacingCallback(connector->GetSpacingCallback());
importer->SetOriginCallback(connector->GetOriginCallback());
importer->SetScalarTypeCallback(connector->GetScalarTypeCallback());
importer->SetNumberOfComponentsCallback(connector->GetNumberOfComponentsCall
back());
importer->SetPropagateUpdateExtentCallback(connector->GetPropagateUpdateExte
ntCallback());
importer->SetUpdateDataCallback(connector->GetUpdateDataCallback());
importer->SetDataExtentCallback(connector->GetDataExtentCallback());
importer->SetBufferPointerCallback(connector->GetBufferPointerCallback());
importer->SetCallbackUserData(connector->GetCallbackUserData());
/*Create a pipeline ITK-->VTK*/
vtkStructuredPoints* structPts= vtkStructuredPoints::New();
vtkImageToStructuredPoints* its=vtkImageToStructuredPoints::New();
its->SetInput(importer->GetOutput());
structPts=its->GetOutput();
vtkDataSetMapper* mapper=vtkDataSetMapper::New();
mapper->SetInput(structPts);
vtkActor* actor=vtkActor::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderer->SetBackground(1,1,1);
renWin->Render();
iren->Start();
However, in the vtk window, there is only one blue square is shown, no
image. I want to show this vtk window in the QtFrame. But
renWin->SetParentId(mainFm); doesn't work. And iren also doesn't work.
I'm sure the reader works correct. I displayed one image from it. It is
fine.
Could you tell me what is wrong in my code?
Thank you very much!
Chunyan