[vtkusers] Best way to store multiple vtkActors using C++

Student Life lifestudent37 at gmail.com
Sat Jan 10 19:14:36 EST 2015


Dear David Doria,

Thank you for your response.

I have an actor class which will store the properties of the actor on
screen. For example, its opacity, colour etc. Basically, as I have
previously mentioned, I only want to move the actor sometimes meaning that
I would need to make use of the  *'vtkInteractorStyleTrackballActor'. *However,
this will mean that I will need to handle the mathematics behind it, so I
am not sure where to store an actors transformation. Should I store it in
the actor class or implement another class?

As for the polydata and polydata mapper, should I keep it in the same class
as the actor class?

There is currently an example on YouTube, of a similar software that I am
trying to implement. Basically, I want to group and ungroup objects on
screen/memory, but I am not sure on how to implement the data structure. This
is the link to the video - https://www.youtube.com/watch?v=iy0gTaN3BKI, I
am trying to implement a feature similar to the one shown between 3:00 -
6:05 minutes of the video. I was thinking of using the vtkAssembly, but I
am struggling with the memory management of all the vtkActors/objects on
screen. I don't know if I should use a vector or linked list

Would greatly appreciate it if you could give me ideas.

On Fri, Jan 9, 2015 at 1:22 PM, David Doria <daviddoria at gmail.com> wrote:

> 1) Since I intend on using the* 'vtkInteractorStyleTrackballActor' *to
>> interact with actors individually, I know that I will need to manually do
>> the mathematics to allow the user to interact with the actor. I intend on
>> using matrices, however I am not sure how to incorporate it into my class
>> structure. At the moment, I have an *Actor* class, which basically
>> stores a *vtkActor's* properties such as opacity, lighting and scale.
>> The thing is, I am not sure if I should store the functions that the
>> *vtkTransform* and *vtkMatrix4x4* offer in the *Actor *class. Should
>> they be part of my *Actor* class, or should they be somewhere else?
>> Because, ideally I want to apply transformations on each actor, but I am
>> not sure if I should store each transformation in the *Actor *class.
>>
>
> It is not clear why you are trying to duplicate the VTK class
> structure/functionality? It sounds like all you need is to have a contain
> of these objects and use their functions (and NOT manually do the
> mathematics).
>
>
>> 2) In terms of data structure for handling multiple *vtkActors* and
>> *vtkAssembly's*, I am not sure if I should opt for the *std::vector * data
>> structure or use a *linked list*. Ideally, I want the user to load a few
>> stl/obj files and then my software to store each stl/obj file into memory.
>> I can't really use an array, because it is unknown how many *vtkActors*,
>> the user wants on the screen. What is the best sort of way of storing each
>> *vtkActor* into memory? As for *vtkAssemblys*, some actors can be
>> grouped into parts, so there will definitely be more than one
>> *vtkAssembly* but again, I am not sure which data structure to go for.
>> Should I go for a *std::vector *or a *linked list?*
>>
>
> The container you choose should only matter for the speed of insertions
> and removals.
>
>
>> 3) If I understand *vtkPolyDatas *correctly, they are basically the
>> geometry and mesh behind a physical *vtkActor*? Should I have a separate
>> class to handle *vtkPolyData*, because at the moment I have the
>> *vtkPolyDataMapper* in my Actor class.
>>
>
> Again, it's still not clear why you are duplicating the hierarchy.
>
>
>> 4) What is the difference between *vtkActorCollection* and *vtkAssembly*?
>> Ideally, I want to 'group' some *vtkActors*, so that they can be
>> interacted with and rotated in unison, but again I am not too sure which
>> one to go for. After, you recommended the *vtkAssembly*, I did some
>> research into it and it seems to be the more appropriate one, but now the
>> *vtkActorCollection* is confusing me.
>>
>
> I'm not too sure, but after a quick look it looks like vtkAssembly allows
> hierarchy to be encoded, whereas vtkActorCollection is more like your #2
> above where it is simply a flat container to store a collection of actors.
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150111/e517ad4d/attachment.html>


More information about the vtkusers mailing list