[vtkusers] Cannot render polygen data immediately

lor fal lorfalwit at gmail.com
Fri May 18 06:02:07 EDT 2018


Hi all:
I have hundreds  of images to display by using vtkResliceImageViewer. I
need to draw a marker when the left mouse button is clicked. My current
solution is to use vtkRegularPolygonSource to draw a circle. The problem is
that the circle does not render immediately even if I called render()
afterwards. However, if I scroll the mouse wheel, the circle will be
rendered correctly.
The code snippet is attached below:

void add_marker()
{
       auto _circle_source =
vtkSmartPointer<vtkRegularPolygonSource>::New();
_circle_source->SetNormal(1, 0, 0);
_circle_source->SetRadius(1);
_circle_source->SetGeneratePolygon(false);
_circle_source->SetNumberOfSides(50);
_circle_source->Update();
auto _mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
_mapper->SetInputData(_circle_source->GetOutput());
auto _actor = vtkSmartPointer<vtkActor>::New();
_actor->SetMapper(_mapper);
auto _cam_pos_x =
_in->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->GetPosition()[0];
_actor->SetPosition(_cam_pos_x - 10, nipple[0], nipple[1]);


_actor->GetProperty()->SetColor(1.0, 1.0, 0.0);
_in->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->AddActor(_actor);
}

The add_marker function was called in the callback of
vtkCommand::LeftButtonPressEvent.
Anyone could help me to solve this problem?
Thank you.

-- 
Best regards,
Hugh Lo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180518/00d08ae5/attachment.html>


More information about the vtkusers mailing list