[vtkusers] know the pixels on the line

Martijn Koopman koopman.mk at gmail.com
Tue Nov 28 04:38:09 EST 2017


Hi Pankaj,

You could use vtkTransformCoordinateSystems to transform the world
coordinates of your vtkPolyData to display coordinates.
Also the convenience method vtkInteractorObserver::ComputeWorldToDisplay
would be an option.

>From these two display points you can derive the vector of the 2D line and
then traverse the intermediate points.

However, this is method only gives you a description of the 2D line. It
does not tell exactly which which pixels on the screen are rendered from
that line.
The thickness of the line is neglected for example.

Regards,
Martijn

2017-11-28 7:21 GMT+01:00 Pankaj Gupta <stn.gupta.pankaj at gmail.com>:

> Hi,
>
>  I am new to vtk. I am using Activiz. I created multiple lines using
> vtkLine and display them using vtkActor. Now i want to draw line on 2D
> points calculated from the 3D Line Points. I want to know all the pixels of
> 3D lines from where my lines is passed. Below is my code.
>
> vtkPoints points = vtkPoints.New();
> for (int i = 0; i < point.Count; i++)
> points.InsertNextPoint(x, y, z);
>
> vtkCellArray lines = vtkCellArray.New();
> for (int i = 0; i < point.Count-1; i++)
> {
>   vtkLine line = vtkLine.New();
>   line.GetPointIds().SetId(0, i);
>   line.GetPointIds().SetId(1, i + 1);
>   lines.InsertNextCell(line);
> }
>
> vtkPolyData linesPolyData = vtkPolyData.New();
> linesPolyData.SetPoints(points);
> linesPolyData.SetLines(lines);
> linesPolyData.Update();
>
> vtkPolyDataMapper mapper = vtkPolyDataMapper.New();
> mapper.SetInput(linesPolyData);
> mapper.Update();
>
> vtkActor actor = vtkActor.New();
> actor.SetMapper(mapper);
> actor.GetProperty().SetLineWidth(10);
> actor.GetProperty().SetColor(255, 255, 0);
> renderer.AddActor(actor);
>
>
> Now i want to know the pixels on the lines. Please help me. Thanks in
> advance. :) :)
>
>
> Thanks,
>
> Pankaj
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171128/690dc1ea/attachment.html>


More information about the vtkusers mailing list