[vtkusers] Problem with lookup table, mapper, and number of colors in 5.8

Riku subs at collab.se
Tue Apr 5 07:08:40 EDT 2011


Hello,

I am going to annoyingly bump this topic again, as I still have found
no solution to the problem. Has anyone been able to reproduce the
deviant behaviour I described? At present I would categorize it a big
problem to the code, unless I made a blatantly obvious mistake.

To summarize: plots rendered with the release head of VTK and osmesa
do not honour the number of colours set in the lookup table.

(The VTK file referenced in the test code below is from the VTK data directory.)

Thank you,

Riku


On 21 February 2011 13:34, Riku <subs at collab.se> wrote:
> Hello,
>
> So far no new input regarding my problem (see below), so I thought I'd
> report some more on the problem and my recent findings. (Hoping
> someone might have a lead on this.)
>
> I have attached two PNG images that highlight my present problem.
>
> It seems that the problem is in some way related to OSMesa and/or what
> happens in VTK when that implementation is used. For my testing, I
> have created four different builds for shared objects:
>
> vtk-5.6.1
> vtk-5.6.1-osmesa
> vtk-5.8
> vtk-5.8-osmesa    <-- problem is here
>
> The CMake settings are the same for the four build, except for the
> OSMesa settings. (VTK_OPENGL_HAS_OSMESA is true, VTK_USE_X
> is false, OPENGL_gl_LIBRARY is set to the empty string.) For the
> OSMesa builds, the resulting libraries have no dependencies on X
> libraries or on libGL, only on libOSMesa.
>
> With the testing program (below), all is fine for the three first
> cases. For vtk-5.8-osmesa the colors go "wild". Is this a bug in the
> VTK code? I have started to review the code changes that I think are
> involved, but have so far not found anything obviously useful.
>
> Still hoping for some leads! I am very thankful for any help, as I
> need precisely my last case to work.
>
> Riku
>
>
>
> On 17 February 2011 12:49, Riku <subs at collab.se> wrote:
>> 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 ---
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-color-err.png
Type: image/png
Size: 10581 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110405/3df0999f/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-color-ok.png
Type: image/png
Size: 9045 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110405/3df0999f/attachment-0001.png>


More information about the vtkusers mailing list