Try running vtkCleanPolyData before the normals calculation. The data may duplicate the points for each triangle. clean polydata will remove duplicate points.<br><br><div class="gmail_quote">On Fri, Jul 6, 2012 at 5:21 AM, Mika Fischer <span dir="ltr"><<a href="mailto:mika.fischer@zoopnet.de" target="_blank">mika.fischer@zoopnet.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
first of all I have to say that is the first time that I use vtk and I<br>
don't have much experience with 3D graphics.<br>
<br>
I have a 3d triangle mesh of a face in wrl format. I also managed to<br>
display it. However the shading of the triangles seems to be flat.<br>
Calling SetInterpolationToGouraud() or SetInterpolationToFlat() seems<br>
to make no difference.<br>
<br>
The code used to load the data and display it is below. Am I missing<br>
an important step here?<br>
<br>
Also, if I load the file in ParaView, it has the same issue and<br>
switching from Flat to Gouraud makes no visible difference. However if<br>
I use a CylinderSource, the shading is smooth as I would expect it<br>
(and switching to flat makes a huge difference).<br>
<br>
Here's a screenshot of the data in paraview: <a href="http://zoopnet.de/vrml.png" target="_blank">http://zoopnet.de/vrml.png</a><br>
<br>
Any tips would be very much appreciated!<br>
<br>
Best,<br>
Mika<br>
<br>
-------------------------------------<br>
vtkSmartPointer<vtkVRMLImporter> importer =<br>
vtkSmartPointer<vtkVRMLImporter>::New();<br>
importer->SetFileName(fileWrl.c_str());<br>
importer->Read();<br>
importer->Update();<br>
<br>
vtkActorCollection* actors = importer->GetRenderer()->GetActors();<br>
actors->InitTraversal();<br>
vtkDataSet* pDataset = actors->GetNextActor()->GetMapper()->GetInput();<br>
<br>
vtkPolyData* polyData = vtkPolyData::SafeDownCast(pDataset);<br>
polyData->Update();<br>
<br>
vtkSmartPointer<vtkPolyDataNormals> skinNormals =<br>
vtkSmartPointer<vtkPolyDataNormals>::New();<br>
skinNormals->SetFeatureAngle(90.0);<br>
skinNormals->SetInput(polyData);<br>
skinNormals->Update();<br>
<br>
vtkSmartPointer<vtkPolyDataMapper> solidMapper =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
solidMapper->SetInputConnection(skinNormals->GetOutputPort());<br>
solidMapper->ScalarVisibilityOff();<br>
<br>
vtkSmartPointer<vtkActor> solidActor = vtkSmartPointer<vtkActor>::New();<br>
solidActor->SetMapper(solidMapper);<br>
solidActor->GetProperty()->SetInterpolationToGouraud();<br>
<br>
-------------------------------------<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>