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

Student Life lifestudent37 at gmail.com
Thu Jan 8 17:37:27 EST 2015


Dear David Doria, John,

Many thanks for your response.

I sort of have a clear picture on what I want to achieve and how I am going
to go about achieving it.

I have a few questions, and I would really appreciate it if you could
answer them or give me some suggestions.

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.

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?*

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.

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.

Once again, thank you for answering my previous queries, it has meant a lot
to me. I would really appreciate it if you could answer my questions.

Thanks

On Wed, Jan 7, 2015 at 1:21 PM, David Doria <daviddoria at gmail.com> wrote:

> On Tue, Jan 6, 2015 at 5:51 PM, Student Life <lifestudent37 at gmail.com>
> wrote:
>
>> Dear David Doria,
>>
>> Thank you for your response.
>>
>> I did some research into the* vtkAssembly* class and found that the
>> method, *'void AddPart (vtkProp3D *)'* adds the part. However, it takes
>> a *vtkProp3D* object as its parameter, but then *vtkActor *inherits from
>> *vtkProp3D.* Would I be right in saying that this function would still
>> work, as my objects are all declared as *vtkActor *and not *vtkProp3D?*
>>
>
> Yes, that's exactly how it is done in the example I sent.
>
>
>> The only sort of difficulty/concern I am having is storing more than one *vtkActor
>> *in a *vtkRenderer.*
>>
>> So far, I intend on implementing an actor class in C++, and then another
>> class called 'MultipleActors' which takes instances of the actor class and
>> stores it as a linked list. However, I am not sure if this is a wise thing
>> to do. Is there another way/data structure that I could use for storing
>> multiple actors into memory in C++?
>>
>
> Sure, you can do whatever you want with your pointers (such as store them
> in a std::vector, as John pointed out).
>
>
>> Also, in regards to moving the actor independently, I want to make use of
>> matrices? How do I incorporate this into my actor class/VTK?
>>
>
> You can set the "transform" (vtkActor::SetTransform) of an actor like this:
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TransformActor
>
> and you can use vtkTransform::SetMatrix to specify a transform matrix
> directly:
>
> http://www.vtk.org/doc/nightly/html/classvtkTransform.html
>
> Finally, I am slightly confused about how the* vtkPolyDataMapper*
>> works/is incorporated with *vtkActors*? Does every *vtkActor *have its
>> own *vtkPolyDataMapper?* Are rotations and the mathematics behind the
>> *vtkPolyDataMapper?*
>>
>
> Yes, every actor needs a mapper. I don't believe any transforms are
> applied in the mapper, but rather directly to the actor as I mentioned
> above.
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150108/561b54ee/attachment.html>


More information about the vtkusers mailing list