<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Dear all </p>
<p>T want to read and view .vtk file ,but there is an error at <span style="font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, 'Apple Color Emoji', 'Segoe UI Emoji', NotoColorEmoji, 'Segoe UI Symbol', 'Android Emoji', EmojiSymbols; font-size: 16px;">actor->SetMapper(Mapper)</span>
</p>
<p>said that <span>There is no proper conversion function from <span>vtkSmartPointer<vtkPolyDataMapper></span> to<<span>vtkImageMapper3D></span></span> .</p>
<p>here is my code:</p>
<p></p>
<div>vtkSmartPointer<vtkPolyDataReader> vtkReader = vtkSmartPointer<vtkPolyDataReader>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkReader->SetFileName("C:\\Users\\Administrator\\Desktop\\jing\\t.vtk");</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>//vtkSmartPointer<vtkPolyData> polydata = vtkReader->GetOutput();</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkPolyDataMapper> Mapper =</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>Mapper->SetInputConnection(vtkReader->GetOutputPort());</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkImageActor> actor =</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkImageActor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>actor->SetMapper(Mapper);//->SetInputConnection(vtkreader->GetOutputPort());</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderer> renderer =</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderer>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderWindow> renderWindow =</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderWindow>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderWindow->AddRenderer(renderer);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>vtkSmartPointer<vtkRenderWindowInteractor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderWindowInteractor->SetRenderWindow(renderWindow); </div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderer->AddActor(actor);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderer->SetBackground(.2, .3, .4);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderWindow->Render();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>renderWindowInteractor->Start();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>return 0;</div>
<p></p>
</div>
</body>
</html>