View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015303VTK(No Category)public2015-02-05 09:262015-10-07 08:31
ReporterLuc Habert 
Assigned ToDavid C. Lonie 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0015303: vtkTextMapper update issue
DescriptionWhen a previously rendered vtkTextMapper (not vtkOpenGLFreeTypeTextMapper) has its text or textproperty changed, and is rendered again, the result is sometimes not updated, as witnessed by the following code (assuming vtkOpenGLFreeTypeTextMapper is not overriding vtkTextMapper::New, vtkLabeledDataMapper uses a vtkTextMapper).

    vtkNew<vtkRenderWindow> window;
    vtkNew<vtkRenderer> renderer;

    window->AddRenderer(renderer.GetPointer());
    vtkNew<vtkRenderWindowInteractor> iren;
    iren->SetRenderWindow(window.GetPointer());
    window->SetSize(600, 600);
    iren->Initialize();


    vtkNew<vtkLabeledDataMapper> lmap;
    vtkNew<vtkActor2D> actor;
    actor->SetMapper(lmap.GetPointer());

    renderer->AddActor(actor.GetPointer());

    vtkNew<vtkPoints> pts;
    pts->InsertNextPoint(0, 0, 0);
    vtkNew<vtkStringArray> s1;
    s1->InsertNextValue("E");
    s1->SetName("S");

    vtkNew<vtkPolyData> p1;
    p1->SetPoints(pts.GetPointer());
    p1->GetPointData()->AddArray(s1.GetPointer());

    lmap->SetInputData(p1.GetPointer());
    lmap->SetLabelModeToLabelFieldData();
    vtkNew<vtkTextProperty> prop;
    prop->SetFontFamilyToArial();
    prop->SetFontSize(14);
    lmap->SetLabelTextProperty(prop.GetPointer());
    lmap->SetFieldDataName("S");

    iren->Initialize();

    renderer->ResetCamera();
    renderer->Render();

    lmap->GetLabelTextProperty()->SetColor(1, 0, 0);


    renderer->Render();

    iren->Start();
    // the E is still white instead of becoming red

The problem is that vtkTextRenderer::RenderString called at vtkTextMapper.cxx:536 does not modify the mtime of the image when it does not reallocate it. As a result, the texture does not update itself before rendering, resulting in the previous text being displayed.

I believe vtkTextRenderer::RenderString should call image->Modified(), or, at least, vtkTextMapper::UpdateImage should do it itself.

TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Files

 Relationships

  Notes
(0034205)
Luc Habert (reporter)
2015-02-11 08:33
edited on: 2015-02-11 08:35

I found another update problem. At the end of vtkTextMapper::UpdateQuad, the mtime check to update Points can fail to detect that the image was modified. I think it should also check for CoordsTime < TCoordsTime.

(0034206)
Luc Habert (reporter)
2015-02-11 08:40

Finally, I noticed that vtkTextMapper::RenderOverlay does not call Texture->PostRender at the end like actors normally do. I have no clue whether it's a problem or not, and I didn't notice any adverse effects.
(0034290)
David C. Lonie (developer)
2015-03-02 10:23

I recently fixed a bug that might be the cause of this. Can you try with the latest master? This commit in particular should fix it:

commit f23c7b26c6f5257120c4b6f58f169bd69e9d3063
Author: David C. Lonie <david.lonie@kitware.com>
Date: Tue Oct 28 15:47:01 2014 -0400

    Manually mark text buffer images as modified.
    
    If the image doesn't need to be rescaled, it is possible that only
    vtkImageData::GetScalarPointer will be called to draw on the image,
    which will not update the MTime. This was preventing the image rendering
    classes from updating textures appropriately.
    
    Change-Id: If5071ab6146ce907131f910c396639ce9e361d06
(0035263)
Luc Habert (reporter)
2015-10-05 06:45

Sorry for not answering sooner. Indeed, your commit fixes the first problem, but the second one remains. Sorry, I probably should have created a second ticket for it.

Here is some code that triggers this second issue. It's really a corner case (you need only one point and two renders before changing the input!), but it happened to me in real code.

The problem is that the "blah" is sized to occupy the same rectangle as the "a" that was previously rendered (look at its distorted aspect, or remove one of the previous renders and compare).

    vtkNew<vtkRenderWindow> window;
    vtkNew<vtkRenderer> renderer;

    window->AddRenderer(renderer.GetPointer());
    vtkNew<vtkRenderWindowInteractor> iren;
    iren->SetRenderWindow(window.GetPointer());
    window->SetSize(600, 600);
    iren->Initialize();


    vtkNew<vtkLabeledDataMapper> lmap;
    vtkNew<vtkActor2D> actor;
    actor->SetMapper(lmap.GetPointer());

    renderer->AddActor(actor.GetPointer());

    vtkNew<vtkPoints> pts;
    pts->InsertNextPoint(0, 0, 0);
    vtkNew<vtkStringArray> s1;
    s1->InsertNextValue("a");
    s1->SetName("S");

    vtkNew<vtkPolyData> p1;
    p1->SetPoints(pts.GetPointer());
    p1->GetPointData()->AddArray(s1.GetPointer());

    vtkNew<vtkTrivialProducer> src;
    src->SetOutput(p1.GetPointer());
    lmap->AddInputConnection(0, src->GetOutputPort(0));
    lmap->GetLabelTextProperty()->SetFontSize(40);
    lmap->SetLabelModeToLabelFieldData();
    iren->Initialize();

    renderer->ResetCamera();
    renderer->Render();
    renderer->Render();

    vtkNew<vtkPolyData> p2;
    p2->SetPoints(pts.GetPointer());
    vtkNew<vtkStringArray> s2;
    s2->InsertNextValue("blah");
    s2->SetName("S");
    p2->GetPointData()->AddArray(s2.GetPointer());
    src->SetOutput(p2.GetPointer());

    renderer->Render();

    iren->Start();
(0035264)
Luc Habert (reporter)
2015-10-05 06:46

The solution is to replace, in UpdateQuad

  if (this->CoordsTime < actor->GetMTime() ||
      this->CoordsTime < this->TextProperty->GetMTime())

by

  if (this->CoordsTime < actor->GetMTime() ||
      this->CoordsTime < this->TextProperty->GetMTime()
      || this->CoordsTime < this->TCoordsTime)
(0035265)
David C. Lonie (developer)
2015-10-06 10:49

Ah, sorry, I overlooked the issue. Your patch looks good:

https://gitlab.kitware.com/vtk/vtk/merge_requests/733 [^]
(0035267)
David C. Lonie (developer)
2015-10-07 08:31

Patch merged.

 Issue History
Date Modified Username Field Change
2015-02-05 09:26 Luc Habert New Issue
2015-02-11 08:33 Luc Habert Note Added: 0034205
2015-02-11 08:35 Luc Habert Note Edited: 0034205
2015-02-11 08:40 Luc Habert Note Added: 0034206
2015-03-02 10:23 David C. Lonie Note Added: 0034290
2015-10-05 06:45 Luc Habert Note Added: 0035263
2015-10-05 06:46 Luc Habert Note Added: 0035264
2015-10-06 10:49 David C. Lonie Note Added: 0035265
2015-10-06 10:50 David C. Lonie Assigned To => David C. Lonie
2015-10-06 10:50 David C. Lonie Status backlog => active development
2015-10-06 10:50 David C. Lonie Status active development => gerrit review
2015-10-07 08:31 David C. Lonie Note Added: 0035267
2015-10-07 08:31 David C. Lonie Status gerrit review => closed
2015-10-07 08:31 David C. Lonie Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team