vtkUnstructedGrid scalar color does not match when SetInterpolateScalarsBeforeMapping(1) and SetInterpolateScalarsBeforeMapping(0)
here is the test code, this vtu file displays right in paraview like this.
void main(int argc, char* argv[])
{
// Create the reader for the data.
std::string filename = "2.vtu";
std::cout << "Loading " << filename.c_str() << std::endl;
vtkNew<vtkXMLUnstructuredGridReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
vtkDataSet* data = reader->GetOutput();
double range[2]{ 0 };
data->GetPointData()->GetArray("Order 1")->GetRange(range, 3);
vtkNew<vtkLookupTable> lt;
lt->SetRange(range);
lt->SetNumberOfColors(15);
lt->Build();
vtkNew<vtkDataSetMapper> mapper;
mapper->SetLookupTable(lt.GetPointer());
mapper->SetInputConnection(reader->GetOutputPort());
mapper->SetScalarVisibility(true);
mapper->SetScalarModeToUsePointFieldData();
mapper->ColorByArrayComponent("Order 1", 3);
mapper->SetScalarRange(range);
mapper->SetInterpolateScalarsBeforeMapping(1);
mapper->Update();
vtkNew<vtkNamedColors> colors;
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor.GetPointer());
renderer->SetBackground(colors->GetColor3d("Wheat").GetData());
renderer->UseHiddenLineRemovalOn();
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.GetPointer());
renderWindow->SetSize(640, 480);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow.GetPointer());
renderer->ResetCamera();
renderer->ResetCameraClippingRange();
renderWindow->Render();
interactor->Start();
}
here is the result when SetInterpolateScalarsBeforeMapping(1)
but it should be like this SetInterpolateScalarsBeforeMapping(0)
So is this a bug or something wrong with my code?
Need help and thanks.