1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#ifndef __octree_iterator
#define __octree_iterator
// Included by octree
#include <vtkstd/iterator>
/**\brief An octree iterator.
*
* Unlike most STL container iterators, octree iterators contain some state that most developers will be interested in.
* Specifically, the iterator may be set to traverse siblings but not children, only leaf nodes, or all nodes in an octree.
* Also, the bounding box of an octree node is implicit in its position in the hierarchy;
* since octree nodes themselves do not contain their position relative to their parents it is up to the iterator
* to provide bounding box information.
*
*\bug Const octree iterators don't seem to work -- comparison operators aren't defined properly?
*/
template< typename T_, typename R_, typename P_, typename O_, typename OP_, int d_ = 3 >
class octree_iterator : public octree_path<T_,R_,P_,O_,OP_,d_>
{
public:
typedef O_ octree_type;
typedef OP_ octree_pointer;
typedef typename O_::allocator_type octree_allocator_type;
typedef typename O_::octree_node_reference octree_node_reference;
typedef typename O_::octree_node_pointer octree_node_pointer;
typedef vtkstd::bidirectional_iterator_tag iterator_category;
typedef octree_iterator< T_, T_&, T_*, O_, O_*, d_ > iterator;
typedef octree_iterator< T_, const T_&, const T_*, O_, const O_*, d_ > const_iterator;
typedef octree_iterator< T_, R_, P_, O_, OP_, d_ > self_iterator;
bool _M_immediate_family; // Iterate over all the subnodes or just the direct children?
bool _M_only_leaf_nodes; // Should the iterator visit all nodes or only leaf nodes?
octree_iterator();
octree_iterator( octree_node_pointer oroot, octree_node_pointer onode, bool only_leaves = true );
octree_iterator( const const_iterator& it );
~octree_iterator();
octree_node_pointer check_incr();
octree_node_pointer check_decr();
void immediate_family( bool state );
bool immediate_family() const { return this->_M_immediate_family; }
bool& immediate_family() { return this->_M_immediate_family; }
virtual self_iterator& operator = ( const iterator& it );
#if ! ( defined(_MSC_VER) && (_MSC_VER < 1300) )
virtual self_iterator& operator = ( const const_iterator& it );
#endif
self_iterator& operator ++ () { this->_M_current_node = check_incr(); return *this; }
self_iterator operator ++ ( int ) { self_iterator tmp = *this; this->_M_current_node = check_incr(); return tmp; }
self_iterator& operator -- () { this->_M_current_node = check_decr(); return *this; }
self_iterator operator -- ( int ) { self_iterator tmp = *this; this->_M_current_node = check_decr(); return tmp; }
};
#endif // __octree_iterator
|