[vtkusers] Does the vtk Delete methods recursively delete?
Amy Henderson
amy.henderson at kitware.com
Wed Mar 17 08:38:32 EST 2004
Keep in mind that VTK does reference counting, and Delete only calls the
destructor when the reference count goes to 0. Adding a part to a
vtkAssembly increases the reference count by 1 of the actor added, so you
should call Delete on the actor immediately after adding it to the
assembly. This puts the reference count back to 1, and when Delete is
called in the assembly, and it calls Delete on the actors, then they will
destruct. The code (in C++) would look something like this:
vtkActor *actor1 = vtkActor::New();
vtkActor *actor2 = vtkActor::New();
vtkActor *actor3 = vtkActor::New();
vtkAssembly *assembly = vtkAssembly::New();
assembly->AddPart(actor1);
assembly->AddPart(actor2);
assembly->AddPart(actor3);
actor1->Delete();
actor2->Delete();
actor3->Delete();
< The rest of your code that uses vtkAssembly goes here. >
assembly->Delete();
- Amy
At 04:06 AM 3/17/2004, Veerapuram Varadhan wrote:
>Hi Benjamin,
>
>No need to iterate though the prop collection, the delete() of vtkAssembly
>object will essentially call delete() of each of the actors added to it.
>
>It is a common funtionality of all Delete() in all the vtk classes.
>
>Rgds,
>
>V. Varadhan
>
> > If I create an vtkAssembly class, add to it say 3 vtkActor objects using
> > the AddPart(..) routine, and then do:
> > myvtkAssbly->Delete();
> >
> > will this cause all of the vtkActor objects in the vtkAssembly object to
> > have their own Delete() routine called upon them? or do I have to:
> >
> > aProp3dCollection = myvtkAssbly->GetParts()
> >
> > then iterate through the prop collection calling:
> > (aProp3dCollection->GetNextProp())->Delete();
> >
> > to delete all the vtkActor objects in the assembly?
> >
> >
> > Regards,
> > Benjamin Burrell
> >
> > _______________________________________________
> > 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://www.vtk.org/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://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list