35 #ifndef IE_CORE_BOUNDEDKDTREE_H
36 #define IE_CORE_BOUNDEDKDTREE_H
40 #include "OpenEXR/ImathBox.h"
42 #include "IECore/BoxTraits.h"
49 template<
class BoundIterator>
54 typedef BoundIterator Iterator;
55 typedef typename std::iterator_traits<BoundIterator>::value_type Bound;
56 typedef typename BoxTraits<Bound>::BaseType BaseType;
58 typedef std::vector<Node> NodeVector;
59 typedef typename NodeVector::size_type NodeIndex;
69 BoundedKDTree( BoundIterator first, BoundIterator last,
int maxLeafSize=4 );
76 void init( BoundIterator first, BoundIterator last,
int maxLeafSize=4 );
82 unsigned int intersectingBounds(
const S &b, std::vector<BoundIterator> &bounds )
const;
88 const Node&
node( NodeIndex idx )
const;
101 typedef std::vector<BoundIterator> Permutation;
102 typedef typename Permutation::iterator PermutationIterator;
103 typedef typename Permutation::const_iterator PermutationConstIterator;
107 unsigned char majorAxis( PermutationConstIterator permFirst, PermutationConstIterator permLast );
108 void build( NodeIndex nodeIndex, PermutationIterator permFirst, PermutationIterator permLast );
109 void bound( NodeIndex nodeIndex );
112 void intersectingBoundsWalk( NodeIndex nodeIndex,
const S &p, std::vector<BoundIterator> &bounds )
const;
117 BoundIterator m_lastBound;
120 template<
class BoundIterator>
128 inline bool isLeaf()
const;
130 inline BoundIterator *permFirst()
const;
132 inline BoundIterator *permLast()
const;
134 inline bool isBranch()
const;
136 inline unsigned char cutAxis()
const;
138 inline const Bound &bound()
const;
144 inline void makeLeaf( PermutationIterator permFirst, PermutationIterator permLast );
145 inline void makeBranch(
unsigned char cutAxis );
147 inline Bound &bound();
149 unsigned char m_cutAxisAndLeaf;
156 BoundIterator *first;
163 typedef BoundedKDTree<std::vector<Imath::Box2f>::const_iterator> Box2fTree;
164 typedef BoundedKDTree<std::vector<Imath::Box2d>::const_iterator> Box2dTree;
165 typedef BoundedKDTree<std::vector<Imath::Box3f>::const_iterator> Box3fTree;
166 typedef BoundedKDTree<std::vector<Imath::Box3d>::const_iterator> Box3dTree;
170 #include "BoundedKDTree.inl"
172 #endif // IE_CORE_BOUNDEDKDTREE_H
Definition: BoundedKDTree.h:50
static NodeIndex highChildIndex(NodeIndex index)
Retrieve the index of the "high" child node.
NodeIndex rootIndex() const
Returns the index for the root node.
const Node & node(NodeIndex idx) const
Retrieve the node associated with a given index.
unsigned int intersectingBounds(const S &b, std::vector< BoundIterator > &bounds) const
void init(BoundIterator first, BoundIterator last, int maxLeafSize=4)
NodeIndex numNodes() const
Returns the number of nodes in the tree.
static NodeIndex lowChildIndex(NodeIndex index)
Retrieve the index of the "low" child node.
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43