mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-04 03:00:39 +08:00
Fix kdBVH unit test
(transplanted from cb64e587c559131047906e6b5da2093fa5946fda )
This commit is contained in:
parent
9e84d135db
commit
c8271df0ec
@ -69,7 +69,7 @@ struct get_boxes_helper<ObjectList, VolumeList, int> {
|
|||||||
*
|
*
|
||||||
* \param _Scalar The underlying scalar type of the bounding boxes
|
* \param _Scalar The underlying scalar type of the bounding boxes
|
||||||
* \param _Dim The dimension of the space in which the hierarchy lives
|
* \param _Dim The dimension of the space in which the hierarchy lives
|
||||||
* \param _Object The object type that lives in the hierarchy. It must have value semantics. Either internal::bounding_box(_Object) must
|
* \param _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.
|
* 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.
|
* This class provides a simple (as opposed to optimized) implementation of a bounding volume hierarchy analogous to a Kd-tree.
|
||||||
@ -92,14 +92,14 @@ public:
|
|||||||
|
|
||||||
KdBVH() {}
|
KdBVH() {}
|
||||||
|
|
||||||
/** Given an iterator range over \a Object references, constructs the BVH. Requires that internal::bounding_box(Object) return a Volume. */
|
/** Given an iterator range over \a Object references, constructs the BVH. Requires that bounding_box(Object) return a Volume. */
|
||||||
template<typename Iter> KdBVH(Iter begin, Iter end) { init(begin, end, 0, 0); } //int is recognized by init as not being an iterator type
|
template<typename Iter> KdBVH(Iter begin, Iter end) { init(begin, end, 0, 0); } //int is recognized by init as not being an iterator type
|
||||||
|
|
||||||
/** Given an iterator range over \a Object references and an iterator range over their bounding boxes, constructs the BVH */
|
/** Given an iterator range over \a Object references and an iterator range over their bounding boxes, constructs the BVH */
|
||||||
template<typename OIter, typename BIter> KdBVH(OIter begin, OIter end, BIter boxBegin, BIter boxEnd) { init(begin, end, boxBegin, boxEnd); }
|
template<typename OIter, typename BIter> KdBVH(OIter begin, OIter end, BIter boxBegin, BIter boxEnd) { init(begin, end, boxBegin, boxEnd); }
|
||||||
|
|
||||||
/** Given an iterator range over \a Object references, constructs the BVH, overwriting whatever is in there currently.
|
/** Given an iterator range over \a Object references, constructs the BVH, overwriting whatever is in there currently.
|
||||||
* Requires that internal::bounding_box(Object) return a Volume. */
|
* Requires that bounding_box(Object) return a Volume. */
|
||||||
template<typename Iter> void init(Iter begin, Iter end) { init(begin, end, 0, 0); }
|
template<typename Iter> void init(Iter begin, Iter end) { init(begin, end, 0, 0); }
|
||||||
|
|
||||||
/** Given an iterator range over \a Object references and an iterator range over their bounding boxes,
|
/** Given an iterator range over \a Object references and an iterator range over their bounding boxes,
|
||||||
|
@ -24,9 +24,15 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/StdVector>
|
#include <Eigen/StdVector>
|
||||||
|
#include <Eigen/Geometry>
|
||||||
#include <unsupported/Eigen/BVH>
|
#include <unsupported/Eigen/BVH>
|
||||||
|
|
||||||
inline double SQR(double x) { return x * x; }
|
namespace Eigen {
|
||||||
|
|
||||||
|
template<typename Scalar, int Dim> AlignedBox<Scalar, Dim> bounding_box(const Matrix<Scalar, Dim, 1> &v) { return AlignedBox<Scalar, Dim>(v); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<int Dim>
|
template<int Dim>
|
||||||
struct Ball
|
struct Ball
|
||||||
@ -41,16 +47,10 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(double, Dim)
|
|||||||
VectorType center;
|
VectorType center;
|
||||||
double radius;
|
double radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template<typename Scalar, int Dim> AlignedBox<Scalar, Dim> bounding_box(const Matrix<Scalar, Dim, 1> &v) { return AlignedBox<Scalar, Dim>(v); }
|
|
||||||
template<int Dim> AlignedBox<double, Dim> bounding_box(const Ball<Dim> &b)
|
template<int Dim> AlignedBox<double, Dim> bounding_box(const Ball<Dim> &b)
|
||||||
{ return AlignedBox<double, Dim>(b.center.array() - b.radius, b.center.array() + b.radius); }
|
{ return AlignedBox<double, Dim>(b.center.array() - b.radius, b.center.array() + b.radius); }
|
||||||
|
|
||||||
} // end namespace internal
|
inline double SQR(double x) { return x * x; }
|
||||||
}
|
|
||||||
|
|
||||||
template<int Dim>
|
template<int Dim>
|
||||||
struct BallPointStuff //this class provides functions to be both an intersector and a minimizer, both for a ball and a point and for two trees
|
struct BallPointStuff //this class provides functions to be both an intersector and a minimizer, both for a ball and a point and for two trees
|
||||||
|
Loading…
x
Reference in New Issue
Block a user