[vtkusers] Problem with lookup table, mapper, and number of colors in 5.8
Riku
subs at collab.se
Thu Feb 17 06:49:51 EST 2011
Hello all,
I have a weird problem using the VTK source code from the release head
in git. The results differ consistently between VS2008 (Windows 7
64-bit) and gcc (Ubuntu 10.10).
In the test program I set the number of table values (colors) in the
lookup table to 10. In the rendered image this is reflected correctly
by the scalar bar actor, but NOT by the sliced structured grid, but
only when running the program on Linux. I get a higher number of
colors than requested, but it seems different inputs give different
results. I have not been able to understand the logic of the problem.
The Windows compiled program behaves "well".
My test program below reproduces the problem. Am I missing anything
obvious? Can someone else reproduce the problem? (Is this an issue for
the developers?)
I have compiled the release head in different varieties, all with the
same result.
Thanks for any help!
Riku
--- Test code below ---
#include "vtkSmartPointer.h"
#include "vtkDataSetReader.h"
#include "vtkPlane.h"
#include "vtkCutter.h"
#include "vtkLookupTable.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkScalarBarActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkWindowToImageFilter.h"
#include "vtkPNGWriter.h"
#define VTK_CREATE(type, var) vtkSmartPointer<type> var =
vtkSmartPointer<type>::New()
int main(int argc, char* argv[])
{
VTK_CREATE(vtkDataSetReader, reader);
reader->SetFileName("SampleStructGrid.vtk");
reader->Update();
VTK_CREATE(vtkPlane, plane);
plane->SetOrigin(0.5, 0.5, 0.26);
plane->SetNormal(0, 0, 1);
VTK_CREATE(vtkCutter, cutter);
cutter->SetCutFunction(plane);
cutter->SetInputConnection(reader->GetOutputPort());
VTK_CREATE(vtkLookupTable, lut);
lut->SetNumberOfTableValues(10);
lut->SetHueRange(0.66667, 0);
lut->Build();
VTK_CREATE(vtkDataSetMapper, mapper);
mapper->SetInputConnection(cutter->GetOutputPort());
mapper->SetLookupTable(lut);
mapper->InterpolateScalarsBeforeMappingOn();
mapper->SetScalarRange(0.3, 1.1);
VTK_CREATE(vtkActor, actor);
actor->SetMapper(mapper);
VTK_CREATE(vtkScalarBarActor, bar);
bar->SetLookupTable(lut);
bar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
bar->GetPositionCoordinate()->SetValue(0.25, 0.01);
bar->SetOrientationToHorizontal();
bar->SetWidth(0.5);
bar->SetHeight(0.11);
VTK_CREATE(vtkRenderer, renderer);
renderer->AddViewProp(actor);
renderer->AddViewProp(bar);
renderer->SetBackground(1, 1, 1);
renderer->ResetCamera();
VTK_CREATE(vtkRenderWindow, window);
window->OffScreenRenderingOn();
window->AddRenderer(renderer);
window->SetSize(600, 600);
VTK_CREATE(vtkWindowToImageFilter, wti);
wti->SetInput(window);
VTK_CREATE(vtkPNGWriter, writer);
writer->SetInputConnection(wti->GetOutputPort());
writer->SetFileName("test-color.png");
writer->Write();
return 0;
}
--- End test code ---
More information about the vtkusers
mailing list