[vtkusers] VTK-JS: How to get Position of actor

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon Oct 23 14:32:01 EDT 2017


Hum, looking at the code it seems that information should be properly set.

https://github.com/Kitware/vtk-js/blob/master/Utilities/DataGenerator/vtk-data-converter.py#L182

Are you using an older version?

On Mon, Oct 23, 2017 at 2:29 PM, Sebastien Jourdain <
sebastien.jourdain at kitware.com> wrote:

> Ok the issue is related to the vtkDataConverter that does not properly
> define the number of component to 3 for points.
> You can edit the generated json to fix that. This will fix the getBounds()
> call.
>
> I'm going to fix the vtkDataConverter code.
>
> On Mon, Oct 23, 2017 at 6:50 AM, Katrin Hartwig <katrin_hartwig at gmx.de>
> wrote:
>
>> Hi Sebastien,
>> I stored the data as vtk data and used the vtkDataConverter which seemed
>> to work fine. When I run the code, every actor appears exactly at the right
>> place. So I guess the information in the vtk data must be correct (without
>> ever using any function like "setPosition"). Though I do not understand why
>> I cannot retrieve the information of their positions in the code.
>>
>> Here is how I read my data files, it is a function I found in the
>> documentation:
>>
>> function loadSegment(string, actor, renderer, i){
>>     const reader = vtkHttpDataSetReader.newInstance({ fetchGzip: true });
>> reader.setUrl(string).then(() => {
>>   reader.loadData().then(() => {
>>     renderer.resetCamera();
>>     renderWindow.render();
>>   });
>> });
>> const mapper = vtkMapper.newInstance();
>> mapper.setInputConnection(reader.getOutputPort());
>> actor.setMapper(mapper);
>> renderer.addActor(actor);
>> }
>>
>> Any ideas what could be wrong?
>>
>> Thank you for your help!
>>
>> Am 20.10.2017 um 21:39 schrieb Sebastien Jourdain:
>>
>> Then I believe your dataset is not valid. How did you build it?
>>
>>
>> On Fri, Oct 20, 2017 at 1:07 PM, Katrin Hartwig <katrin_hartwig at gmx.de>
>> wrote:
>>
>>> Hi Sebastian and Logan,
>>>
>>> thank you a lot for your help and i apologize for my late answer!
>>> Unfortunately I still could not solve the problem. I tried both
>>> suggestions:
>>> With *actor*.getCenter() I get the default-values (0,0,0) for each
>>> actor. So I tried to get the information of the dataset as you suggested:
>>>
>>>        dataset = mapper.getInputData();
>>>        bounds = dataset.getBounds();
>>>
>>> By doing so I get the following error massage:
>>> *       "getBounds called on an array with components of 1"*
>>>
>>> The output of getBounds remains default because of the error.
>>>
>>> As I could not find any solutions yet, I would be grateful for any help!
>>>
>>> Thank you
>>> Katrin
>>>
>>> *Gesendet:* Montag, 18. September 2017 um 16:38 Uhr
>>> *Von:* "Sebastien Jourdain" <sebastien.jourdain at kitware.com>
>>> *An:* "Katrin Hartwig" <katrin_hartwig at gmx.de>
>>> *Cc:* vtkusers <vtkusers at vtk.org>
>>> *Betreff:* Re: [vtkusers] VTK-JS: How to get Position of actor
>>> Hi Katrin,
>>>
>>> The actor position only describe the relative position to the data,
>>> that's why by default they are always (0,0,0).
>>> Which means its your source or dataset that has the information about
>>> the position that you are looking for.
>>>
>>> For example to find the bounds of a rendered dataset you can do as
>>> follow.
>>>
>>> dataset = mapper.getInputData();
>>> bounds = dataset.getBounds();
>>>
>>> // bounds is an array as follow:
>>> // [ minX, maxX, minY, maxY, minZ, maxZ]
>>>
>>> Hope that helps,
>>>
>>> Otherwise you can learn more on the basic concepts behind VTK here:
>>> https://www.vtk.org/vtk-users-guide/
>>>
>>> Seb
>>>
>>> On Mon, Sep 18, 2017 at 7:31 AM, Katrin Hartwig <katrin_hartwig at gmx.de>
>>> wrote:
>>>>
>>>> Dear all,
>>>>
>>>> I am using a visualization of several actors with VTK-js.
>>>> Unfortunately, when using *actor.getPosition() *I always get [0,0,0]
>>>> as a result, no matter which actor I checked, although they appear on
>>>> different positions in my rendering window.
>>>> How can I get the real positions or centers of the different actors?
>>>>
>>>> As I am completely new to VTK-js and I could not find any solutions to
>>>> my problem, any help would be great!
>>>>
>>>> Thank you
>>>> Katrin
>>>>
>>>> _______________________________________________
>>>> 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/20171023/e02f4242/attachment.html>


More information about the vtkusers mailing list