TreeTest< Dim > Struct Template Reference

Public Types

typedef Matrix< double, Dim, 1 > VectorType
 
typedef std::vector< VectorType, aligned_allocator< VectorType > > VectorTypeList
 
typedef Ball< Dim > BallType
 
typedef std::vector< BallType, aligned_allocator< BallType > > BallTypeList
 
typedef AlignedBox< double, Dim > BoxType
 

Public Member Functions

void testIntersect1 ()
 
void testMinimize1 ()
 
void testIntersect2 ()
 
void testMinimize2 ()
 

Member Typedef Documentation

◆ BallType

template<int Dim>
typedef Ball<Dim> TreeTest< Dim >::BallType

◆ BallTypeList

template<int Dim>
typedef std::vector<BallType, aligned_allocator<BallType> > TreeTest< Dim >::BallTypeList

◆ BoxType

template<int Dim>
typedef AlignedBox<double, Dim> TreeTest< Dim >::BoxType

◆ VectorType

template<int Dim>
typedef Matrix<double, Dim, 1> TreeTest< Dim >::VectorType

◆ VectorTypeList

template<int Dim>
typedef std::vector<VectorType, aligned_allocator<VectorType> > TreeTest< Dim >::VectorTypeList

Member Function Documentation

◆ testIntersect1()

template<int Dim>
void TreeTest< Dim >::testIntersect1 ( )
inline
138  {
139  BallTypeList b;
140  for (int i = 0; i < 500; ++i) {
141  b.push_back(BallType(VectorType::Random(), 0.5 * internal::random(0., 1.)));
142  }
143  KdBVH<double, Dim, BallType> tree(b.begin(), b.end());
144 
145  VectorType pt = VectorType::Random();
146  BallPointStuff<Dim> i1(pt), i2(pt);
147 
148  for (int i = 0; i < (int)b.size(); ++i) i1.intersectObject(b[i]);
149 
150  BVIntersect(tree, i2);
151 
152  VERIFY(i1.count == i2.count);
153  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
A simple bounding volume hierarchy based on AlignedBox.
Definition: KdBVH.h:68
return int(ret)+1
#define VERIFY(a)
Definition: main.h:362
void BVIntersect(const BVH &tree, Intersector &intersector)
Definition: BVAlgorithms.h:79
Definition: BVH.cpp:46
Ball< Dim > BallType
Definition: BVH.cpp:134
std::vector< BallType, aligned_allocator< BallType > > BallTypeList
Definition: BVH.cpp:135
Definition: fft_test_shared.h:66

References b, Eigen::BVIntersect(), BallPointStuff< Dim >::count, i, int(), and VERIFY.

Referenced by EIGEN_DECLARE_TEST().

◆ testIntersect2()

template<int Dim>
void TreeTest< Dim >::testIntersect2 ( )
inline
174  {
175  BallTypeList b;
177 
178  for (int i = 0; i < 50; ++i) {
179  b.push_back(BallType(VectorType::Random(), 0.5 * internal::random(0., 1.)));
180  for (int j = 0; j < 3; ++j) v.push_back(VectorType::Random());
181  }
182 
183  KdBVH<double, Dim, BallType> tree(b.begin(), b.end());
184  KdBVH<double, Dim, VectorType> vTree(v.begin(), v.end());
185 
186  BallPointStuff<Dim> i1, i2;
187 
188  for (int i = 0; i < (int)b.size(); ++i)
189  for (int j = 0; j < (int)v.size(); ++j) i1.intersectObjectObject(b[i], v[j]);
190 
191  BVIntersect(tree, vTree, i2);
192 
193  VERIFY(i1.count == i2.count);
194  }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int count
Definition: BVH.cpp:127
bool intersectObjectObject(const BallType &b1, const BallType &b2)
Definition: BVH.cpp:77
std::vector< VectorType, aligned_allocator< VectorType > > VectorTypeList
Definition: BVH.cpp:133
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References b, Eigen::BVIntersect(), BallPointStuff< Dim >::count, i, int(), BallPointStuff< Dim >::intersectObjectObject(), j, v, and VERIFY.

Referenced by EIGEN_DECLARE_TEST().

◆ testMinimize1()

template<int Dim>
void TreeTest< Dim >::testMinimize1 ( )
inline
155  {
156  BallTypeList b;
157  for (int i = 0; i < 500; ++i) {
158  b.push_back(BallType(VectorType::Random(), 0.01 * internal::random(0., 1.)));
159  }
160  KdBVH<double, Dim, BallType> tree(b.begin(), b.end());
161 
162  VectorType pt = VectorType::Random();
163  BallPointStuff<Dim> i1(pt), i2(pt);
164 
165  double m1 = (std::numeric_limits<double>::max)(), m2 = m1;
166 
167  for (int i = 0; i < (int)b.size(); ++i) m1 = (std::min)(m1, i1.minimumOnObject(b[i]));
168 
169  m2 = BVMinimize(tree, i2);
170 
172  }
Matrix3d m1
Definition: IOFormat.cpp:2
MatrixType m2(n_dims)
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer)
Definition: BVAlgorithms.h:217

References b, Eigen::BVMinimize(), i, int(), m1, m2(), max, min, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().

◆ testMinimize2()

template<int Dim>
void TreeTest< Dim >::testMinimize2 ( )
inline
196  {
197  BallTypeList b;
199 
200  for (int i = 0; i < 50; ++i) {
201  b.push_back(BallType(VectorType::Random(), 1e-7 + 1e-6 * internal::random(0., 1.)));
202  for (int j = 0; j < 3; ++j) v.push_back(VectorType::Random());
203  }
204 
205  KdBVH<double, Dim, BallType> tree(b.begin(), b.end());
206  KdBVH<double, Dim, VectorType> vTree(v.begin(), v.end());
207 
208  BallPointStuff<Dim> i1, i2;
209 
210  double m1 = (std::numeric_limits<double>::max)(), m2 = m1;
211 
212  for (int i = 0; i < (int)b.size(); ++i)
213  for (int j = 0; j < (int)v.size(); ++j) m1 = (std::min)(m1, i1.minimumOnObjectObject(b[i], v[j]));
214 
215  m2 = BVMinimize(tree, vTree, i2);
216 
218  }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
double minimumOnObjectObject(const BallType &b1, const BallType &b2)
Definition: BVH.cpp:112

References b, Eigen::BVMinimize(), e(), i, int(), j, m1, m2(), max, min, BallPointStuff< Dim >::minimumOnObjectObject(), v, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().


The documentation for this struct was generated from the following file: