1 #include <libmesh/bounding_box.h> 13 LIBMESH_CPPUNIT_TEST_SUITE(
BBoxTest );
15 CPPUNIT_TEST( test_one_degenerate );
16 CPPUNIT_TEST( test_two_degenerate );
17 CPPUNIT_TEST( test_no_degenerate );
18 CPPUNIT_TEST( test_signed_distance );
20 CPPUNIT_TEST_SUITE_END();
43 const Real eps = std::numeric_limits<Real>::epsilon();
52 typedef std::tuple<Real, bool, bool> TestTuple;
53 std::vector<TestTuple> tests =
55 std::make_tuple(0.5,
true,
true),
56 std::make_tuple(1.0 - eps,
true,
true),
57 std::make_tuple(1.0,
true,
true),
58 std::make_tuple(1.0 + eps,
false,
true),
59 std::make_tuple(1.5,
false,
false)
62 for (
unsigned int dir = 0; dir < 3; ++dir)
63 for (
const auto & t : tests)
66 Point dmin = min, dmax = max;
67 dmin(dir) = dmax(dir) = std::get<0>(t);
74 CPPUNIT_ASSERT(non_degenerate.
intersects(degenerate) == std::get<1>(t));
75 CPPUNIT_ASSERT(degenerate.intersects(non_degenerate) == std::get<1>(t));
79 CPPUNIT_ASSERT(degenerate.intersects(non_degenerate,
TOLERANCE) == std::get<2>(t));
96 const Real eps = std::numeric_limits<Real>::epsilon();
105 typedef std::tuple<Real, bool, bool> TestTuple;
106 std::vector<TestTuple> tests =
108 std::make_tuple(0.5,
true,
true),
109 std::make_tuple(0.5 - eps,
false,
true),
110 std::make_tuple(0.5 + eps,
false,
true),
111 std::make_tuple(1.0,
false,
false)
114 for (
unsigned int dir = 0; dir < 3; ++dir)
123 min(
Point(mins[0], mins[1], mins[2])),
124 max(
Point(maxs[0], maxs[1], maxs[2]));
129 for (
const auto & t : tests)
132 Point cmin = min, cmax = max;
133 cmin(dir) = cmax(dir) = std::get<0>(t);
137 CPPUNIT_ASSERT(initial.
intersects(comparison) == std::get<1>(t));
138 CPPUNIT_ASSERT(comparison.intersects(initial) == std::get<1>(t));
142 CPPUNIT_ASSERT(comparison.intersects(initial,
TOLERANCE) == std::get<2>(t));
148 std::rotate(mins.rbegin(), mins.rbegin()+1, mins.rend());
149 std::rotate(maxs.rbegin(), maxs.rbegin()+1, maxs.rend());
158 const Real eps = std::numeric_limits<Real>::epsilon();
172 typedef std::tuple<Real, bool, bool> TestTuple;
173 std::vector<TestTuple> tests =
175 std::make_tuple(1.,
true,
true),
176 std::make_tuple(1. + eps,
false,
true),
177 std::make_tuple(1. - eps,
true,
true),
178 std::make_tuple(1.5,
false,
false),
179 std::make_tuple(0.5,
true,
true)
182 for (
unsigned int dir = 0; dir < 3; ++dir)
191 min(
Point(mins[0], mins[1], mins[2])),
192 max(
Point(maxs[0], maxs[1], maxs[2]));
196 for (
const auto & t : tests)
199 Point cmin = min, cmax = max;
200 cmin(dir) = std::get<0>(t);
206 CPPUNIT_ASSERT(initial.
intersects(comparison) == std::get<1>(t));
207 CPPUNIT_ASSERT(comparison.intersects(initial) == std::get<1>(t));
211 CPPUNIT_ASSERT(comparison.intersects(initial,
TOLERANCE) == std::get<2>(t));
217 std::rotate(mins.rbegin(), mins.rbegin()+1, mins.rend());
218 std::rotate(maxs.rbegin(), maxs.rbegin()+1, maxs.rend());
CPPUNIT_TEST_SUITE_REGISTRATION(BBoxTest)
void test_signed_distance()
static constexpr Real TOLERANCE
bool intersects(const BoundingBox &) const
void test_no_degenerate()
The libMesh namespace provides an interface to certain functionality in the library.
Real signed_distance(const Point &p) const
Computes the signed distance, d, from a given Point p to this BoundingBox.
Defines a Cartesian bounding box by the two corner extremum.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void test_two_degenerate()
A Point defines a location in LIBMESH_DIM dimensional Real space.
void test_one_degenerate()