Rhino C++ API  7.21
Classes | Public Member Functions | List of all members
ON_RTreeIterator Class Reference

#include <opennurbs_rtree.h>

Public Member Functions

 ON_RTreeIterator ()
 
 ON_RTreeIterator (const class ON_RTree &a_rtree)
 
 ~ON_RTreeIterator ()
 
bool First ()
 
bool Initialize (const class ON_RTree &a_rtree)
 
bool Initialize (const struct ON_RTreeNode *a_node)
 
bool Last ()
 
bool Next ()
 
bool Prev ()
 
const ON_RTreeBranchValue () const
 

Detailed Description

ON_RTreeIterator

The ON_RTreeIterator class can be used to iterate each leaf in an ON_RTree.

Constructor & Destructor Documentation

◆ ON_RTreeIterator() [1/2]

ON_RTreeIterator::ON_RTreeIterator ( )

Description: Construct an empty iterator. Call Initialize() to attach the iterator to an R-tree. Remark: Any calls to ON_RTree::Insert() or ON_RTree::Remove() that modify an R-tree being iterated invalidate the iterator. The iterator must be re-initialized before being used again.

There is no connection between the order elements are inserted in an R-tree and the order the elements are iterated by an iterator.

◆ ON_RTreeIterator() [2/2]

ON_RTreeIterator::ON_RTreeIterator ( const class ON_RTree a_rtree)

◆ ~ON_RTreeIterator()

ON_RTreeIterator::~ON_RTreeIterator ( )

Member Function Documentation

◆ First()

bool ON_RTreeIterator::First ( )

Description: Reset the iterator so the current leaf is the first leaf in the R-tree. The Initialize() functions automatically do this, but First() can be called if an iterator needs to be used more than once or to make code easy to read and understand. Example: Iterate every leaf in an R-tree.

  ON_RTree rtree;
  ...
  ON_RtreeIterator rit(rtree);
  const ON_RTreeBranch* rtree_leaf;
  for ( rit.First(); 0 != (rtree_leaf = rit.Value()); rit.Next() )
  {

/ leaf id = rtree_leaf->m_id / leaf bounding box = rtree->m_rect }

Returns: True if a call to Value() will return a non-null pointer. See Also: ON_RTreeIterator::Last();

◆ Initialize() [1/2]

bool ON_RTreeIterator::Initialize ( const class ON_RTree a_rtree)

Description: Initialize an iterator to iterate every leaf in the rtree. Parameters: a_rtree - [in] R-tree to iterate Example: See the comment for ON_RTreeIterator::First(). Returns: True if a_rtree has at least one element. Remarks: Any calls to ON_RTree::Insert() or ON_RTree::Remove() that modify this node or its children will invalidate this iterator and it must be re-initialized.

There is no connection between the order elements are inserted in an R-tree and the order the elements are iterated by an iterator.

◆ Initialize() [2/2]

bool ON_RTreeIterator::Initialize ( const struct ON_RTreeNode a_node)

Description: Initialize an iterator to iterate every leaf on or below a_node. Parameters: a_node - [in] R-tree node to iterate Example: See the comment for ON_RTreeIterator::First(). Returns: True if a_node has at least one element. Remarks: Any calls to ON_RTree::Insert() or ON_RTree::Remove() that modify this node or its children will invalidate this iterator and it must be re-initialized.

There is no connection between the order elements are inserted in an R-tree and the order the elements are iterated by an iterator.

◆ Last()

bool ON_RTreeIterator::Last ( )

Description: Set the iterator so the current leaf is the last leaf in the R-tree.

Example: Iterate an R-tree in reverse order.

  ON_RTree rtree;
  ...
  ON_RTreeIterator rit(rtree);
  const ON_RTreeBranch* rtree_leaf;
  for ( rit.Last(); 0 != (rtree_leaf = rit.Value()); rit.Prev() )
  {

/ leaf id = rtree_leaf->m_id / leaf bounding box = rtree->m_rect }

Returns: True if a call to Value() will return a non-null pointer. See Also: ON_RTreeIterator::First();

◆ Next()

bool ON_RTreeIterator::Next ( )

Description: Increment the iterator to the next leaf in the R-tree. Example: See the comment for ON_RTreeIterator::First() Returns: True if a call to Value() will return a non-null pointer. False if there is not a next leaf and all susequent calls to Value() will return null. See Also: ON_RTreeIterator::Prev();

◆ Prev()

bool ON_RTreeIterator::Prev ( )

Description: Decrement the iterator to the previous leaf in the R-tree. Example: See the comment for ON_RTreeIterator::Last() Returns: True if a call to Value() will return a non-null pointer. False if there is not a previous leaf and all susequent calls to Value() will return null. See Also: ON_RTreeIterator::Next();

◆ Value()

const ON_RTreeBranch* ON_RTreeIterator::Value ( ) const

Description: Get the value of the current leaf element. Calling Value() does not increment or decrement the iterator. Example: See the comment for ON_RTreeIterator::First(). Return: Null pointer if there are no more leaves to iterate A pointer to the current R-tree leaf. When there are no more leaves, the returned pointer is null.