[vtkusers] How to refresh screen without flicker?

Wenlong Wang scc.wwl at gmail.com
Mon Oct 17 15:06:16 EDT 2011


Dear all,

I'm using a vtkVertexGlyphFilter objects to represent few points. The
coordinates of these points are supposed to change as certain parameter
changes. That means I have to clean the screen and re-draw these points
every time the parameter changes. I used the following function to do the
refreshing.

void ReDrawPoints(float current_mode[][3])
{
    float t[3];

    points = vtkPoints::New();
    for (int i = 0; i < 5090; i++)
    {
        t[0] = current_mode[i][0];
        t[1] = current_mode[i][1];
        t[2] = current_mode[i][2];
        points->InsertPoint(vtkIdType(i), t);
    }

    polydata = vtkPolyData::New();
    polydata->SetPoints(points);

    gf = vtkVertexGlyphFilter::New();
    gf->AddInput(newpolydata);
    gf->Update();

    array = vtkFloatArray::New();
    for (int i = 0; i < 5090; i++)
    {
        newarray->InsertTuple1(i, float(i));
    }

    polydata = vtkPolyData::New();
    polydata->GetPointData()->SetScalars(array);

    mapper = vtkPolyDataMapper::New();
    mapper->SetInputConnection(gf->GetOutputPort());

    actor = vtkActor::New();
    actor->SetMapper(mapper);

    renderer->AddActor(actor);
    renWin->AddRenderer(renderer);

    ren->Render();
    iren->SetRenderWindow(renWin);
    renWin->Render();

    gf->RemoveAllInputs();
    gf->Delete();
    points->Delete();
    polydata->Delete();
    array->Delete();
    mapper->Delete();
    actor->Delete();
    renderer->RemoveActor(actor);    //This one erase the points from the
screen.
}

This function is being called all the times until some condition is
fulfilled.

However, it only cleans the screen. The points just show up on the screen
for a flash and gone.

Can anyone help me out of this? I'll be extremely grateful.

Yours
Long
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111017/81a7ed06/attachment.htm>


More information about the vtkusers mailing list