Iterator for nodes in an ObjectTree. More...
#include <vtkKWEObjectTreeNodeIterator.h>


Iterator for nodes in an ObjectTree.
vtkKWEObjectTreeNodeIterator is an iterator for nodes in an ObjectTree. The iterator can be set to depth-first or breadth-first, to include the BaseNode or not, and to only consider nodes up to a maximum dpeth from the BaseNode. Additionally, a PatternNode can be sepcified which will act as a filter controlling which nodes in the tree will be iterated over. Matching nodes can be a superset of the PatternNode, but whatever Attributes and Properties (as well as node type and the type of the node in the object) are specified on the PatternNode must exist and have matching values in the nodes be considered for iteration.
To use this iterator, SetBaseNode() and then either InitTraversal() or GoToFirstNode(). GetCurrentNode() can then be called to retrieve the top/current node in the iterator. Repeated calls to GoToNextNode followed by GetCurrentNode can be made to move through the values being iterated over (and GetCurrentDepth can be called to get the depth of the current node realtive to the BaseNode; 0 - BaseNode, 1 - children of BaseNode, etc) When the value of GetCurrentNode is NULL, iteration is complete. Note that values pushed onto the internal stack of the iterator are vtkWeakPointers, and thus COULD become NULL during iteration. However, GoToNextNode() will skip over NULL values. CurrentNode is a vtkSmartPointer, and thus will not become invalid unless done so by the iterator (setting it to NULL).
A simple example:
vtkSmartPointer<vtkKWEObjectTreeNodeIterator> iterator = vtkSmartPointer<vtkKWEObjectTreeNodeIterator>::New(); iterator->SetBaseNode( root ); iterator->SetTraversalToEntireSubtree(); iterator->SetTraversalModeToDepthFirst(); // only interested in nodes that have a "user" property, though we don't // care about the contents of the user property. vtkSmartPointer<vtkKWEObjectTreeTransformableNode> patternNode = vtkSmartPointer<vtkKWEObjectTreeTransformableNode>::New(); vtkSmartPointer<vtkKWEObjectTreeUserProperty> userProp = vtkSmartPointer<vtkKWEObjectTreeUserProperty>::New(); patternNode->AddProperty(userProp); iterator->SetPatternNode( patternNode ); for (iterator->InitTraversal(); (currentNode = iterator->GetCurrentNode()); iterator->GoToNextNode()) { // do something }
NOTE: A 2nd call to InitTraversal() or GoToFirstNode() clears the existing contents and starts iteration again based on the current tree structure. Thus, the 2nd (or subsequent) iterations may not give the same results (if the ObjectTree has changed).
Also, changes made to the iterater (changing the value of a member variable) result in clearing the iteration. InitiTraversal or GoToFirstNode must be called to start the iteration over. Note, however, that the PatternNode CAN be changed without requireing restarting the iteration (though nodes already passed-over in the tree because they didn't match the PatternNode but which might now match, will not be reconsidered)
Definition at line 95 of file vtkKWEObjectTreeNodeIterator.h.
Definition at line 183 of file vtkKWEObjectTreeNodeIterator.h.
| vtkKWEObjectTreeNodeIterator::vtkKWEObjectTreeNodeIterator | ( | ) | [protected] |
| virtual vtkKWEObjectTreeNodeIterator::~vtkKWEObjectTreeNodeIterator | ( | ) | [protected, virtual] |
| static vtkKWEObjectTreeNodeIterator* vtkKWEObjectTreeNodeIterator::New | ( | ) | [static] |
Reimplemented from vtkObject.
| vtkKWEObjectTreeNodeIterator::vtkTypeRevisionMacro | ( | vtkKWEObjectTreeNodeIterator | , | |
| vtkObject | ||||
| ) |
| void vtkKWEObjectTreeNodeIterator::PrintSelf | ( | ostream & | os, | |
| vtkIndent | indent | |||
| ) | [virtual] |
Reimplemented from vtkObject.
| void vtkKWEObjectTreeNodeIterator::SetBaseNode | ( | vtkKWEObjectTreeNodeBase * | baseNode | ) |
Set/Get the BaseNode from which to fill the iterator
| virtual vtkKWEObjectTreeNodeBase* vtkKWEObjectTreeNodeIterator::GetBaseNode | ( | ) | [virtual] |
Set/Get the BaseNode from which to fill the iterator
| void vtkKWEObjectTreeNodeIterator::SetPatternNode | ( | vtkKWEObjectTreeNodeBase * | patternNode | ) |
Set/Get the PatternNode; if set, only nodes matching the PatternNode will be iterated over. Note: nodes can be a superset of this node but must match Atttributes, Properties, and Object type (actual object not compared) set on the Pattern node
| virtual vtkKWEObjectTreeNodeBase* vtkKWEObjectTreeNodeIterator::GetPatternNode | ( | ) | [virtual] |
Set/Get the PatternNode; if set, only nodes matching the PatternNode will be iterated over. Note: nodes can be a superset of this node but must match Atttributes, Properties, and Object type (actual object not compared) set on the Pattern node
| void vtkKWEObjectTreeNodeIterator::InitTraversal | ( | ) | [inline] |
Clear stack/iterator and then initialize the stack with the children of the BaseNode, setting CurrentNode to be the 1st of these children. Same as GoToFirstNode.
Definition at line 120 of file vtkKWEObjectTreeNodeIterator.h.
| void vtkKWEObjectTreeNodeIterator::GoToFirstNode | ( | ) |
Clear stack/iterator and then initialize the stack with the children of the BaseNode, setting CurrentNode to be the 1st of these children. Same as InitTraversal.
| void vtkKWEObjectTreeNodeIterator::GoToNextNode | ( | ) |
Sets the value of CurrentNode to be the next non-zero value in the iterator. If empty or only NULL values, the CurrentNode is set to NULL.
| vtkKWEObjectTreeNodeBase* vtkKWEObjectTreeNodeIterator::GetCurrentNode | ( | ) |
Returns pointer to the current node in the iteration. To iterate through the nodes: InitTraversal(), GetCurrentNode(), GoToNextNode(), GetCurrentNode(), GoToNextNode(), etc. until GetCurrentNode returns a NULL pointer. CurrentNode is a SmartPointer and thus is protected from destruction elsewhere in the application.
| virtual int vtkKWEObjectTreeNodeIterator::GetCurrentDepth | ( | ) | [virtual] |
Get the depth (relative to the BaseNode) of the current node . 0 is the BaseNode level, 1 would be children of the base node, etc. The value is only valid if CurrentNode is non-NULL;
| bool vtkKWEObjectTreeNodeIterator::IsDoneWithTraversal | ( | ) |
Test whether the iterator is currently positioned at a valid item.
| virtual void vtkKWEObjectTreeNodeIterator::IncludeBaseNodeOn | ( | ) | [virtual] |
Set/Get whether the BaseNode is included (considered) during traversal.
| virtual void vtkKWEObjectTreeNodeIterator::IncludeBaseNodeOff | ( | ) | [virtual] |
Set/Get whether the BaseNode is included (considered) during traversal.
| virtual void vtkKWEObjectTreeNodeIterator::SetIncludeBaseNode | ( | bool | ) | [virtual] |
Set/Get whether the BaseNode is included (considered) during traversal.
| virtual bool vtkKWEObjectTreeNodeIterator::GetIncludeBaseNode | ( | ) | [virtual] |
Set/Get whether the BaseNode is included (considered) during traversal.
| virtual void vtkKWEObjectTreeNodeIterator::SetMaximumTraversalDepth | ( | int | ) | [virtual] |
Set/Get the maximum depth for traversal
| virtual int vtkKWEObjectTreeNodeIterator::GetMaximumTraversalDepth | ( | ) | [virtual] |
Set/Get the maximum depth for traversal
| void vtkKWEObjectTreeNodeIterator::SetTraversalToChildrenOnly | ( | ) | [inline] |
Convenience method for setting iterator to only consider the children of the BaseNode (BaseNode NOT traversed).
Definition at line 166 of file vtkKWEObjectTreeNodeIterator.h.
| void vtkKWEObjectTreeNodeIterator::SetTraversalToEntireSubtree | ( | ) | [inline] |
Convenience method for setting iterator to consider the entier subtree of the BaseNode (BaseNode is included)
Definition at line 176 of file vtkKWEObjectTreeNodeIterator.h.
| void vtkKWEObjectTreeNodeIterator::SetTraversalModeToDepthFirst | ( | ) | [inline] |
Set/Get whether the tree is iterated over depth-first or breadth-first.
Definition at line 192 of file vtkKWEObjectTreeNodeIterator.h.
| void vtkKWEObjectTreeNodeIterator::SetTraversalModeToBreadthFirst | ( | ) | [inline] |
Set/Get whether the tree is iterated over depth-first or breadth-first.
Definition at line 194 of file vtkKWEObjectTreeNodeIterator.h.
| virtual void vtkKWEObjectTreeNodeIterator::SetTraversalMode | ( | int | ) | [virtual] |
Set/Get whether the tree is iterated over depth-first or breadth-first.
| virtual int vtkKWEObjectTreeNodeIterator::GetTraversalMode | ( | ) | [virtual] |
Set/Get whether the tree is iterated over depth-first or breadth-first.
| const char* vtkKWEObjectTreeNodeIterator::GetTraversalModeAsString | ( | ) |
Set/Get whether the tree is iterated over depth-first or breadth-first.
| virtual void vtkKWEObjectTreeNodeIterator::ConsiderInheritedPropertiesOn | ( | ) | [virtual] |
Set/Get whether inherited properties are considered when comparing to a PatternNode. By default this is off (only properties actually set on the node are compared)
| virtual void vtkKWEObjectTreeNodeIterator::ConsiderInheritedPropertiesOff | ( | ) | [virtual] |
Set/Get whether inherited properties are considered when comparing to a PatternNode. By default this is off (only properties actually set on the node are compared)
| virtual void vtkKWEObjectTreeNodeIterator::SetConsiderInheritedProperties | ( | bool | ) | [virtual] |
Set/Get whether inherited properties are considered when comparing to a PatternNode. By default this is off (only properties actually set on the node are compared)
| virtual bool vtkKWEObjectTreeNodeIterator::GetConsiderInheritedProperties | ( | ) | [virtual] |
Set/Get whether inherited properties are considered when comparing to a PatternNode. By default this is off (only properties actually set on the node are compared)
| void vtkKWEObjectTreeNodeIterator::AddChildren | ( | vtkstd::vector< vtkKWEObjectTreeNodeBase * > & | children | ) | [protected] |
| void vtkKWEObjectTreeNodeIterator::Clear | ( | ) | [protected] |
friend class vtkKWEObjectTreeNodeBase [friend] |
Definition at line 227 of file vtkKWEObjectTreeNodeIterator.h.
Definition at line 214 of file vtkKWEObjectTreeNodeIterator.h.
Definition at line 215 of file vtkKWEObjectTreeNodeIterator.h.
Definition at line 217 of file vtkKWEObjectTreeNodeIterator.h.
vtkKWEObjectTreeNodeIteratorInternals* vtkKWEObjectTreeNodeIterator::Internals [protected] |
Definition at line 219 of file vtkKWEObjectTreeNodeIterator.h.
bool vtkKWEObjectTreeNodeIterator::IncludeBaseNode [protected] |
Is the BaseNode included in the traversal?
Definition at line 222 of file vtkKWEObjectTreeNodeIterator.h.
unsigned long vtkKWEObjectTreeNodeIterator::InitTraversalTime [protected] |
Time at which we started traversal
Definition at line 225 of file vtkKWEObjectTreeNodeIterator.h.
int vtkKWEObjectTreeNodeIterator::CurrentDepth [protected] |
Depth (relative to BaseNode) of the CurrentNode
Definition at line 231 of file vtkKWEObjectTreeNodeIterator.h.
int vtkKWEObjectTreeNodeIterator::MaximumTraversalDepth [protected] |
The maximum depth (relative to BaseNode) of traversal
Definition at line 234 of file vtkKWEObjectTreeNodeIterator.h.
int vtkKWEObjectTreeNodeIterator::TraversalMode [protected] |
Depth-first versus breadth-first
Definition at line 237 of file vtkKWEObjectTreeNodeIterator.h.
bool vtkKWEObjectTreeNodeIterator::ConsiderInheritedProperties [protected] |
During comparison the a PatternNode can the node inherit the property to achieve a match
Definition at line 241 of file vtkKWEObjectTreeNodeIterator.h.
1.7.1