[vtk-developers] Some changes to vtkCollections

Ken Martin ken.martin at kitware.com
Tue Feb 24 11:53:22 EST 2004


Collection Changes

Collections have had some small changes (originally started by Chris Volpe)
to better support reentrant iteration. Specifically all the collection have
an InitTraversal(sit) and GetNextFoobar(sit) methods. (where Foobar is what
the collection contains, for example GetNextActor(sit)) The argument to both
of these methods is a vtkCollectionSimpleIterator. Most of the collection
use in VTK has been modified to use these new methods. The advantage is that
these new methods support having the same collection be iterated through in
a reentrant safe manner. In the past this was not true and led to a number
of problems. In the future for C++ class development please use this
approach to iterating through a collection. These changes are fully
backwards compatible and no old APIs were harmed in the making of these
changes. So in summary, for the future, where you would have written:


for (actors->InitTraversal(); (actor = actors->GetNextActor());)


you would now have:


vtkCollectionSimpleIterator actorIt;
for (actors->InitTraversal(actorIt); 
     (actor = actors->GetNextActor(actorIt));)



Thanks
Ken

Ken Martin, PhD
Kitware Inc.
518 371 3971 x101
469 Clifton Corporate Pkwy
Clifton Park NY 12065






More information about the vtk-developers mailing list