[vtkusers] deriving my own class from vtkActor
Berk Geveci
berk.geveci at kitware.com
Mon Oct 21 08:57:30 EDT 2002
If you added the vtkTypeMacro to your class' header, you
can use SafeDownCast. This is much safer down static casting:
vtkActorCollection *actors = vtkRenderer->GetActors() ;
vtkActor *actor;
for (actors->InitTraversal();actor=actors->GetNextActor());)
{
vtkMyActor* myactor = vtkMyActor::SafeDownCast(actor);
if (myactor)
{
actor->MyExtendedMethod();
}
// etc etc
}
-Berk
On Sun, 2002-10-20 at 08:43, Steffen Oeltze wrote:
>
> Malcolm Drummond wrote:
>
> >Hi Steffen
> >
> >Try casting to your type of actor - the actor collection contains pointers
> >to type vtkActor.
> >
> Unfortunately, I'm not very familiar with C. How does casting work ?
> What is the syntax ?
>
> Steffen
>
> >
> >
> >Malcolm
> >
> >----- Original Message -----
> >From: "Steffen Oeltze" <Steffen.Oeltze at Student.Uni-Magdeburg.DE>
> >To: "VTK users" <vtkusers at public.kitware.com>
> >Sent: Saturday, October 19, 2002 6:05 PM
> >Subject: [vtkusers] deriving my own class from vtkActor
> >
> >
> >>Dear VTK-users,
> >>
> >>I have derived my own class from vtkActor and I have added a couple of
> >>methods to this new class.
> >>After creating and modifying such a new actor I add it to my existing
> >>renderer. At some point I use
> >>vtkRenderer->GetActors() to retrieve my custom actors. Then, I would
> >>like to traverse the returned
> >>list and apply a custom method to each of my selfmade actors. However, I
> >>get the error:
> >>
> >>>'method' : is not an element of 'vtkActor'
> >>>
> >>I guess this is a problem of backward compatibility but I don't know how
> >>to solve it. Can anybody help me ?
> >>
> >>Steffen
> >>
> >>
> >>_______________________________________________
> >>This is the private VTK discussion list.
> >>Please keep messages on-topic. Check the FAQ at:
> >>
> ><http://public.kitware.com/cgi-bin/vtkfaq>
> >
> >>Follow this link to subscribe/unsubscribe:
> >>http://public.kitware.com/mailman/listinfo/vtkusers
> >>
> >>
> >
> >
> >_______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> >Follow this link to subscribe/unsubscribe:
> >http://public.kitware.com/mailman/listinfo/vtkusers
> >
>
More information about the vtkusers
mailing list