[Insight-users] Show 3d image data by vtk, cont'

Luis Ibanez luis . ibanez at kitware . com
Thu, 25 Sep 2003 11:25:12 -0400


Hi Jiang,

Please look at Sebastien's page on how to combine
VTK & QT

http://www . barre . nom . fr/vtk/links-classes . html#qt

Using any of the components indicated in this page
will save you a lot of time.



Also, instead of connecting the vtkImageImport
filter by yourself, it will be much simpler to
use the pseudo-filters in

InsightApplications/Auxiliary/vtk

             itkImageToVTKImageFilter

They put together an ITK & VTK Importer/Exporter
and do all the pipeline connections.  It will be
equivalent to your code, but much cleaner.



Regards,


   Luis



-----------------------
jiang wrote:
> 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
> 
> 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>