|
| KdBVH () |
|
template<typename Iter > |
| KdBVH (Iter begin, Iter end) |
|
template<typename OIter , typename BIter > |
| KdBVH (OIter begin, OIter end, BIter boxBegin, BIter boxEnd) |
|
template<typename Iter > |
void | init (Iter begin, Iter end) |
|
template<typename OIter , typename BIter > |
void | init (OIter begin, OIter end, BIter boxBegin, BIter boxEnd) |
|
Index | getRootIndex () const |
|
EIGEN_STRONG_INLINE void | getChildren (Index index, VolumeIterator &outVBegin, VolumeIterator &outVEnd, ObjectIterator &outOBegin, ObjectIterator &outOEnd) const |
|
const Volume & | getVolume (Index index) const |
|
template<typename Scalar_, int Dim_, typename _Object>
class Eigen::KdBVH< Scalar_, Dim_, _Object >
A simple bounding volume hierarchy based on AlignedBox.
- Parameters
-
Scalar_ | The underlying scalar type of the bounding boxes |
Dim_ | The dimension of the space in which the hierarchy lives |
<em>Object | The object type that lives in the hierarchy. It must have value semantics. Either bounding_box(_Object) must be defined and return an AlignedBox<Scalar, Dim_> or bounding boxes must be provided to the tree initializer. |
This class provides a simple (as opposed to optimized) implementation of a bounding volume hierarchy analogous to a Kd-tree. Given a sequence of objects, it computes their bounding boxes, constructs a Kd-tree of their centers and builds a BVH with the structure of that Kd-tree. When the elements of the tree are too expensive to be copied around, it is useful for _Object to be a pointer.
template<typename Scalar_ , int Dim_, typename _Object >
template<typename OIter , typename BIter >
Eigen::KdBVH< Scalar_, Dim_, _Object >::KdBVH |
( |
OIter |
begin, |
|
|
OIter |
end, |
|
|
BIter |
boxBegin, |
|
|
BIter |
boxEnd |
|
) |
| |
|
inline |
template<typename Scalar_ , int Dim_, typename _Object >
188 if (to - from == 2) {
189 boxes.push_back(objBoxes[objCenters[from].second].merged(objBoxes[objCenters[from + 1].second]));
192 }
else if (to - from == 3) {
194 std::nth_element(objCenters.begin() + from, objCenters.begin() + mid, objCenters.begin() + to,
195 VectorComparator(dim));
196 build(objCenters, from, mid, objBoxes, (dim + 1) %
Dim);
198 boxes.push_back(
boxes[idx1].merged(objBoxes[objCenters[mid].second]));
202 int mid = from + (to - from) / 2;
203 nth_element(objCenters.begin() + from, objCenters.begin() + mid, objCenters.begin() + to,
204 VectorComparator(dim));
205 build(objCenters, from, mid, objBoxes, (dim + 1) %
Dim);
207 build(objCenters, mid, to, objBoxes, (dim + 1) %
Dim);
#define eigen_assert(x)
Definition: Macros.h:910
ObjectList objects
Definition: KdBVH.h:218
void build(VIPairList &objCenters, int from, int to, const VolumeList &objBoxes, int dim)
Definition: KdBVH.h:186
VolumeList boxes
Definition: KdBVH.h:217
std::vector< int > children
Definition: KdBVH.h:215
References Eigen::KdBVH< Scalar_, Dim_, _Object >::boxes, Eigen::KdBVH< Scalar_, Dim_, _Object >::children, Eigen::KdBVH< Scalar_, Dim_, _Object >::Dim, eigen_assert, int(), and Eigen::KdBVH< Scalar_, Dim_, _Object >::objects.
Referenced by Eigen::KdBVH< Scalar_, Dim_, _Object >::init().
template<typename Scalar_ , int Dim_, typename _Object >
Given an index of a node, on exit, outVBegin and outVEnd range over the indices of the volume children of the node and outOBegin and outOEnd range over the object children of the node
146 outOEnd = outOBegin +
objects.size();
150 int numBoxes =
static_cast<int>(
boxes.size());
155 outVEnd = outVBegin + 2;
157 }
else if (
children[idx] >= numBoxes) {
160 outOEnd = outOBegin + 2;
163 outVEnd = outVBegin + 1;
165 outOEnd = outOBegin + 1;
References Eigen::KdBVH< Scalar_, Dim_, _Object >::boxes, Eigen::KdBVH< Scalar_, Dim_, _Object >::children, and Eigen::KdBVH< Scalar_, Dim_, _Object >::objects.
template<typename Scalar_ , int Dim_, typename _Object >
template<typename Iter >
template<typename Scalar_ , int Dim_, typename _Object >
template<typename OIter , typename BIter >
void Eigen::KdBVH< Scalar_, Dim_, _Object >::init |
( |
OIter |
begin, |
|
|
OIter |
end, |
|
|
BIter |
boxBegin, |
|
|
BIter |
boxEnd |
|
) |
| |
|
inline |
Given an iterator range over Object references and an iterator range over their bounding boxes, constructs the BVH, overwriting whatever is in there currently.
112 int n =
static_cast<int>(
objects.size());
120 internal::get_boxes_helper<ObjectList, VolumeList, BIter>()(
objects, boxBegin, boxEnd, objBoxes);
122 objCenters.reserve(
n);
126 for (
int i = 0;
i <
n; ++
i) objCenters.push_back(
VIPair(objBoxes[
i].center(),
i));
128 build(objCenters, 0,
n, objBoxes, 0);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
std::vector< VIPair, aligned_allocator< VIPair > > VIPairList
Definition: KdBVH.h:174
std::vector< Object, aligned_allocator< Object > > ObjectList
Definition: KdBVH.h:72
internal::vector_int_pair< Scalar, Dim > VIPair
Definition: KdBVH.h:173
std::vector< Volume, aligned_allocator< Volume > > VolumeList
Definition: KdBVH.h:75
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void swap(DenseBase< OtherDerived > &other)
Override DenseBase::swap() since for dynamic-sized matrices of same type it is enough to swap the dat...
Definition: PlainObjectBase.h:898
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
References Eigen::KdBVH< Scalar_, Dim_, _Object >::boxes, Eigen::KdBVH< Scalar_, Dim_, _Object >::build(), Eigen::KdBVH< Scalar_, Dim_, _Object >::children, Eigen::placeholders::end, i, n, Eigen::KdBVH< Scalar_, Dim_, _Object >::objects, Eigen::PlainObjectBase< Derived >::swap(), and tmp.