Go to the documentation of this file.
10 #ifndef KDBVH_H_INCLUDED
11 #define KDBVH_H_INCLUDED
18 template<
typename Scalar,
int Dim>
32 template<
typename ObjectList,
typename VolumeList,
typename BoxIter>
34 void operator()(
const ObjectList &objects, BoxIter boxBegin, BoxIter boxEnd, VolumeList &outBoxes)
36 outBoxes.insert(outBoxes.end(), boxBegin, boxEnd);
42 template<
typename ObjectList,
typename VolumeList>
44 void operator()(
const ObjectList &objects,
int,
int, VolumeList &outBoxes)
46 outBoxes.reserve(objects.size());
47 for(
int i = 0;
i < (
int)objects.size(); ++
i)
68 template<
typename _Scalar,
int _Dim,
typename _Object>
class KdBVH
73 typedef std::vector<Object, aligned_allocator<Object> >
ObjectList;
76 typedef std::vector<Volume, aligned_allocator<Volume> >
VolumeList;
87 template<
typename OIter,
typename BIter>
KdBVH(OIter begin, OIter
end, BIter boxBegin, BIter boxEnd) {
init(begin,
end, boxBegin, boxEnd); }
91 template<
typename Iter>
void init(Iter begin, Iter
end) {
init(begin,
end, 0, 0); }
95 template<
typename OIter,
typename BIter>
void init(OIter begin, OIter
end, BIter boxBegin, BIter boxEnd)
102 int n =
static_cast<int>(
objects.size());
113 objCenters.reserve(
n);
117 for(
int i = 0;
i <
n; ++
i)
118 objCenters.push_back(
VIPair(objBoxes[
i].center(),
i));
120 build(objCenters, 0,
n, objBoxes, 0);
124 for(
int i = 0;
i <
n; ++
i)
140 outOEnd = outOBegin +
objects.size();
144 int numBoxes =
static_cast<int>(
boxes.size());
149 outVEnd = outVBegin + 2;
152 else if(
children[idx] >= numBoxes) {
155 outOEnd = outOBegin + 2;
158 outVEnd = outVBegin + 1;
160 outOEnd = outOBegin + 1;
172 typedef std::vector<VIPair, aligned_allocator<VIPair> >
VIPairList;
188 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,
196 build(objCenters, from, mid, objBoxes, (dim + 1) %
Dim);
198 boxes.push_back(
boxes[idx1].merged(objBoxes[objCenters[mid].second]));
203 int mid = from + (to - from) / 2;
204 nth_element(objCenters.begin() + from, objCenters.begin() + mid,
206 build(objCenters, from, mid, objBoxes, (dim + 1) %
Dim);
208 build(objCenters, mid, to, objBoxes, (dim + 1) %
Dim);
223 #endif //KDBVH_H_INCLUDED
void init(OIter begin, OIter end, BIter boxBegin, BIter boxEnd)
VectorComparator(int inDim)
Namespace containing all symbols from the Eigen library.
KdBVH(Iter begin, Iter end)
Box2d bounding_box(const Vector2d &v)
A simple bounding volume hierarchy based on AlignedBox.
void operator()(const ObjectList &objects, BoxIter boxBegin, BoxIter boxEnd, VolumeList &outBoxes)
Index getRootIndex() const
EIGEN_STRONG_INLINE void getChildren(Index index, VolumeIterator &outVBegin, VolumeIterator &outVEnd, ObjectIterator &outOBegin, ObjectIterator &outOEnd) const
Matrix< Scalar, Dim, 1 > VectorType
const typedef Object * ObjectIterator
const Volume & getVolume(Index index) const
AlignedBox< Scalar, Dim > Volume
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
void operator()(const ObjectList &objects, int, int, VolumeList &outBoxes)
const typedef int * VolumeIterator
Reference counted object base class.
std::vector< Volume, aligned_allocator< Volume > > VolumeList
KdBVH(OIter begin, OIter end, BIter boxBegin, BIter boxEnd)
#define EIGEN_STRONG_INLINE
bool operator()(const VIPair &v1, const VIPair &v2) const
void build(VIPairList &objCenters, int from, int to, const VolumeList &objBoxes, int dim)
void init(Iter begin, Iter end)
std::vector< int > children
Array< int, Dynamic, 1 > v
The matrix class, also used for vectors and row-vectors.
std::vector< VIPair, aligned_allocator< VIPair > > VIPairList
static const EIGEN_DEPRECATED end_t end
std::vector< Object, aligned_allocator< Object > > ObjectList
internal::vector_int_pair< Scalar, Dim > VIPair
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:38