Commit 15342029 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

Use the vtkPolyDataNormals filter to calculate normals

I am not sure we want to keep it this way, we can just copy over
the logic from the painters to generate normals as this adds a
whole new module for one filter.

Change-Id: Ied4680bd05e32d01228f8dacfa1cb8309a5840ac
parent 5d973c64
......@@ -51,11 +51,11 @@ int TestVBOPLYMapper(int argc, char *argv[])
vtkNew<vtkPLYReader> reader;
reader->SetFileName(fileName);
reader->Update();
vtkNew<vtkPolyDataNormals> computeNormals;
computeNormals->SetInputConnection(reader->GetOutputPort());
computeNormals->Update();
//vtkNew<vtkPolyDataNormals> computeNormals;
//computeNormals->SetInputConnection(reader->GetOutputPort());
//computeNormals->Update();
mapper->SetInputConnection(computeNormals->GetOutputPort());
mapper->SetInputConnection(reader->GetOutputPort());
actor->SetMapper(mapper.Get());
actor->GetProperty()->SetAmbientColor(0.2, 0.2, 1.0);
actor->GetProperty()->SetDiffuseColor(1.0, 0.65, 0.7);
......
......@@ -7,6 +7,7 @@ vtk_module(vtkRenderingOpenGL2
PRIVATE_DEPENDS
vtksys
vtkRenderingOpenGL
vtkFiltersCore # Do we want this just for vtkPolyDataNormals?
COMPILE_DEPENDS
vtkUtilitiesEncodeString
TEST_DEPENDS
......
......@@ -31,6 +31,9 @@
#include "vtkMatrix4x4.h"
#include "vtkLookupTable.h"
#include "vtkCellData.h"
#include "vtkPolyDataNormals.h"
#include "vtkNew.h"
#include "vtkSmartPointer.h"
#include "vtkglShader.h"
#include "vtkglShaderProgram.h"
......@@ -534,6 +537,8 @@ void vtkVBOPolyDataMapper::UpdateVBO(vtkActor *act)
return;
}
vtkSmartPointer<vtkDataArray> n;
// This replicates how the painter decided on normal generation.
int interpolation = act->GetProperty()->GetInterpolation();
bool buildNormals = this->Internal->buidNormals;
......@@ -545,8 +550,14 @@ void vtkVBOPolyDataMapper::UpdateVBO(vtkActor *act)
if (buildNormals)
{
// FIXME: Add implementation for normal generation.
vtkErrorMacro("Asked to generate normals, needs to be implemented!");
return;
vtkNew<vtkPolyDataNormals> computeNormals;
computeNormals->SetInputData(poly);
computeNormals->Update();
n = computeNormals->GetOutput()->GetPointData()->GetNormals();
}
else
{
n = poly->GetPointData()->GetNormals();
}
}
......@@ -569,7 +580,6 @@ void vtkVBOPolyDataMapper::UpdateVBO(vtkActor *act)
}
// Create a mesh packed with vertex, normal and possibly color.
vtkDataArray* n = poly->GetPointData()->GetNormals();
if (n->GetNumberOfTuples() != poly->GetNumberOfPoints())
{
vtkErrorMacro(<< "Polydata without enough normals for all points. "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment