Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

vtkKWEObjectTreeNodeIterator Class Reference

Iterator for nodes in an ObjectTree. More...

#include <vtkKWEObjectTreeNodeIterator.h>

Inheritance diagram for vtkKWEObjectTreeNodeIterator:
Inheritance graph
[legend]
Collaboration diagram for vtkKWEObjectTreeNodeIterator:
Collaboration graph
[legend]

List of all members.

Public Types

enum  TraversalModes { DEPTH_FIRST = 0, BREADTH_FIRST }

Public Member Functions

 vtkTypeRevisionMacro (vtkKWEObjectTreeNodeIterator, vtkObject)
void PrintSelf (ostream &os, vtkIndent indent)
void InitTraversal ()
void GoToFirstNode ()
void GoToNextNode ()
vtkKWEObjectTreeNodeBaseGetCurrentNode ()
bool IsDoneWithTraversal ()

void SetBaseNode (vtkKWEObjectTreeNodeBase *baseNode)
virtual vtkKWEObjectTreeNodeBaseGetBaseNode ()

void SetPatternNode (vtkKWEObjectTreeNodeBase *patternNode)
virtual vtkKWEObjectTreeNodeBaseGetPatternNode ()

virtual int GetCurrentDepth ()

virtual void IncludeBaseNodeOn ()
virtual void IncludeBaseNodeOff ()
virtual void SetIncludeBaseNode (bool)
virtual bool GetIncludeBaseNode ()

virtual void SetMaximumTraversalDepth (int)
virtual int GetMaximumTraversalDepth ()

void SetTraversalToChildrenOnly ()

void SetTraversalToEntireSubtree ()

void SetTraversalModeToDepthFirst ()
void SetTraversalModeToBreadthFirst ()
virtual void SetTraversalMode (int)
virtual int GetTraversalMode ()
const char * GetTraversalModeAsString ()

virtual void ConsiderInheritedPropertiesOn ()
virtual void ConsiderInheritedPropertiesOff ()
virtual void SetConsiderInheritedProperties (bool)
virtual bool GetConsiderInheritedProperties ()

Static Public Member Functions

static
vtkKWEObjectTreeNodeIterator
New ()

Protected Member Functions

 vtkKWEObjectTreeNodeIterator ()
virtual ~vtkKWEObjectTreeNodeIterator ()
void AddChildren (vtkstd::vector< vtkKWEObjectTreeNodeBase * > &children)
void Clear ()

Protected Attributes

vtkKWEObjectTreeNodeBaseBaseNode
vtkKWEObjectTreeNodeBasePatternNode
vtkSmartPointer
< vtkKWEObjectTreeNodeBase
CurrentNode
vtkKWEObjectTreeNodeIteratorInternals * Internals
bool IncludeBaseNode
unsigned long InitTraversalTime
int CurrentDepth
int MaximumTraversalDepth
int TraversalMode
bool ConsiderInheritedProperties

Friends

class vtkKWEObjectTreeNodeBase

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
DEPTH_FIRST 
BREADTH_FIRST 

Definition at line 183 of file vtkKWEObjectTreeNodeIterator.h.


Constructor & Destructor Documentation

vtkKWEObjectTreeNodeIterator::vtkKWEObjectTreeNodeIterator (  )  [protected]
virtual vtkKWEObjectTreeNodeIterator::~vtkKWEObjectTreeNodeIterator (  )  [protected, virtual]

Member Function Documentation

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]

Friends And Related Function Documentation

friend class vtkKWEObjectTreeNodeBase [friend]

Definition at line 227 of file vtkKWEObjectTreeNodeIterator.h.


Member Data Documentation

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.

Is the BaseNode included in the traversal?

Definition at line 222 of file vtkKWEObjectTreeNodeIterator.h.

Time at which we started traversal

Definition at line 225 of file vtkKWEObjectTreeNodeIterator.h.

Depth (relative to BaseNode) of the CurrentNode

Definition at line 231 of file vtkKWEObjectTreeNodeIterator.h.

The maximum depth (relative to BaseNode) of traversal

Definition at line 234 of file vtkKWEObjectTreeNodeIterator.h.

Depth-first versus breadth-first

Definition at line 237 of file vtkKWEObjectTreeNodeIterator.h.

During comparison the a PatternNode can the node inherit the property to achieve a match

Definition at line 241 of file vtkKWEObjectTreeNodeIterator.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines