[vtkusers] Problem with reusing vtkImageMapper

Thomas Lambertz thomas at hexerei-software.de
Sun Jan 7 00:32:21 EST 2007


Hi All,

i want to display some images in different windows. Displaying in a 
single window works fine - but when i want to reuse a vtkImageMapper the 
hole Image (in both windows) is displayed as a white box (even if the 
LookupTable has no index colored white). When i instead add a new 
vtkImageMapper but reuse the vtkImageMapToColors wich is used as input 
all works also fine. Seemes i missed something in the concept of (re)use 
vtkImgeMapper.

May someone be so kind to tell me what i missed ?


Thanks in advanced,
Tom



As code says more than 1000 words here is what a have scrambled together 
to reproduced my failed attempt:


void MapperTest(vtkImageData* i1)
{
    vtkLookupTable* c1;
    c1 = vtkLookupTable::New();
    c1->SetTableRange (0,255);
    c1->SetNumberOfTableValues(256);
    c1->Build();
    c1->SetTableValue(0,0.0,1.0,1.0,1.0);
    for(int i=1;i<256;i++) {
        c1->SetTableValue(i,0,0,double(i)/255.0,1.0);
    }


    vtkImageMapToColors* m1 = vtkImageMapToColors::New();
    m1->SetLookupTable( c1 );
    m1->SetInput( i1 );


    vtkImageActor* im1 = vtkImageActor::New();
    im1->SetInput( m1->GetOutput() );


    vtkRenderer* ren1 = vtkRenderer::New();
    ren1->AddActor( im1 );

    vtkRenderWindow* rw = vtkRenderWindow::New();
    rw->AddRenderer( ren1 );
    rw->Render();

    // at this point all works fine - i get the expected image

    // Adding new Renderer + RenderWindow

    vtkRenderer* ren2 = vtkRenderer::New();
    ren2->AddActor( im1 );

    vtkRenderWindow* rw2 = vtkRenderWindow::New();
    rw2->AddRenderer( ren2 );
    rw2->Render();

    // now both renderwindows only display white boxes (color of inded 0)

}



More information about the vtkusers mailing list