[vtkusers] read and view .vtk file
Zou Jing
zjinger at hotmail.com
Tue May 2 04:26:43 EDT 2017
Dear all
T want to read and view .vtk file ,but there is an error at actor->SetMapper(Mapper)
said that There is no proper conversion function from vtkSmartPointer<vtkPolyDataMapper> to<vtkImageMapper3D> .
here is my code:
vtkSmartPointer<vtkPolyDataReader> vtkReader = vtkSmartPointer<vtkPolyDataReader>::New();
vtkReader->SetFileName("C:\\Users\\Administrator\\Desktop\\jing\\t.vtk");
//vtkSmartPointer<vtkPolyData> polydata = vtkReader->GetOutput();
vtkSmartPointer<vtkPolyDataMapper> Mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
Mapper->SetInputConnection(vtkReader->GetOutputPort());
vtkSmartPointer<vtkImageActor> actor =
vtkSmartPointer<vtkImageActor>::New();
actor->SetMapper(Mapper);//->SetInputConnection(vtkreader->GetOutputPort());
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(actor);
renderer->SetBackground(.2, .3, .4);
renderWindow->Render();
renderWindowInteractor->Start();
return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170502/adfc215e/attachment.html>
More information about the vtkusers
mailing list