[vtkusers] VTK-JS: How to visualize numbers

Sebastien Jourdain sebastien.jourdain at kitware.com
Fri Dec 1 10:20:17 EST 2017


Hi Cristina,

You should fill the points in a static manner using the typed array like
below:

var nbPoints = 10;
var coords = new Float32Array(nbPoints * 3);

coords[0] = x0;
coords[1] = y0;
coords[2] = z0;
[...]
coords[3*n+0] = xn;
coords[3*n+1] = yn;
coords[3*n+2] = zn;

var polydata = vtkPolyData.newInstance();
polydata.getPoints().setData(coords, 3);

Otherwise your approach with vtkPixelSpaceCallbackMapper seems correct.

Seb

On Fri, Dec 1, 2017 at 8:01 AM, Cristina Oyarzun <
coyarzunlaura at googlemail.com> wrote:

> Hello Sebastian,
>
> I am trying to adapt the example to my current problem. I have a render
> window with 4 renderers. Each renderer has several actors and some of them
> should get labels next to them.
>
> My plan now is to create a vtkPointSet, and set this as inputData to the
> vtkPixelSpaceCallbackMapper. Is this correct?
>
> My problem right now is that when I try to set a point in a vtkPoints the
> vtkPoints remains empty. Do you have any idea what the problem could be?
> Just to test I simplified the problem to this:
>
> var Points = vtkPoints.newInstance();
> Points.setPoint(0, 13, 10, 50);
> console.log("Points", Points.getNumberOfPoints());
>
> And I get always 0.
>
> Thank you!!
> Cristina
>
>
> On Wed, Nov 29, 2017 at 6:59 PM, Sebastien Jourdain <
> sebastien.jourdain at kitware.com> wrote:
>
>> The example you mention is the right approach for what you are looking
>> for.
>>
>> The reason why you don't need vtkFollowers+vtkTextActors, is that we
>> have a 2D layer on top of the 3D for which it is trivial to render text
>> that is always facing the camera. ;-)
>> And we have a mechanism that can convert a set of location in the 3D
>> world into the screen space so those label could be printed.
>>
>> Let us know if you the example is not enough to get you started.
>>
>> Seb
>>
>> On Wed, Nov 29, 2017 at 10:51 AM, Cristina Oyarzun via vtkusers <
>> vtkusers at vtk.org> wrote:
>>
>>> Hello,
>>>
>>> I would like to visualize some numbers next to my actors. I saw an
>>> example (Spheres and Labels) where a canvas is created for this purpose. I
>>> remember doing this using vtkFollowers in the past. Is there currently some
>>> easy way to do this with vtk-js? I mean something similar to vtkFollowers
>>> or vtkTextActors?
>>>
>>> Thank you!
>>> Cristina
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/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/20171201/deabbc7d/attachment.html>


More information about the vtkusers mailing list