1 #include <gtest/gtest.h>     4 #include "../../src/core/geometry_primitives.h"    16                           const Rect &exp_inters, 
double exp_overlap)
 const {
    20     ASSERT_EQ(exp_overlap, r1.
overlap(r2));
    25     auto r1 = 
Rect{-6, 6, -6, 6};
    26     auto out_coffset = 
Point2D{dirs.
horz() * r1.hside_len(),
    27                                dirs.
vert() * r1.vside_len()};
    30       auto r2 = r1.move_center(out_coffset * 0.5);
    31       auto intersection = r1.shrink(2).move_center(out_coffset * 0.25);
    35       auto r2 = r1.move_center(out_coffset);
    36       auto intersection_sides = out_coffset * 0.5;
    37       auto intersection = 
Rect{intersection_sides.y, intersection_sides.y,
    38                                intersection_sides.x, intersection_sides.x};
    42       auto hshift = 
Point2D{dirs.
horz() * -1.0, 0} + out_coffset;
    43       auto intersection_sides = out_coffset * 0.5;
    44       auto intersection = 
Rect{intersection_sides.y, intersection_sides.y,
    45                                (dirs.
right() ? -1 : 0) + intersection_sides.x,
    46                                (dirs.
left() ? 1 : 0) + intersection_sides.x};
    50       auto vshift = 
Point2D{0, dirs.
vert() * -1.0} + out_coffset;
    51       auto intersection_sides = out_coffset * 0.5;
    52       auto intersection = 
Rect{(dirs.
top() ? -1 : 0) + intersection_sides.y,
    53                                (dirs.
bot() ? 1 : 0) + intersection_sides.y,
    54                                intersection_sides.x, intersection_sides.x};
    60     assert(static_cast<bool>(dir.
horz()) ^
    61            static_cast<bool>(dir.
vert()));
    62     auto r1 = 
Rect{-6, 6, -6, 6};
    63     auto out_coffset = 
Point2D{dir.
horz() * r1.hside_len(),
    64                                dir.
vert() * r1.vside_len()};
    67       auto halves = (dir.
horz() ? r1.split_horz() : r1.split_vert());
    68       auto half_r1 = halves[(1 == dir.
horz() || 1 == dir.
vert()) ? 1 : 0];
    70                          half_r1.move_center(out_coffset * 0.25), 0.5);
    73       auto intersection_sides = out_coffset * 0.5;
    74       auto intersection = 
Rect{dir.
horz() ? r1.bot() : intersection_sides.y,
    75                                dir.
horz() ? r1.top() : intersection_sides.y,
    76                                dir.
vert() ? r1.left() : intersection_sides.x,
    77                                dir.
vert() ? r1.right() : intersection_sides.x};
    83                              double exp_outer_overlap)
 const {
    84     auto outer = 
Rect{0, 12, 0, 12};
    86     double inner_left = 4, inner_right = 8,
    87            inner_bot = 4, inner_top = 8;
    89     #define ALIGN_SIDE(side)              \    91         inner_##side = outer.side();   \   101     auto inner = 
Rect{inner_bot, inner_top, inner_left, inner_right};
   112   check_intersection({1, 2, 1, 2}, {3, 4, 3, 4}, {0, 0, 0, 0}, 0);
   116   check_intersection({1, 2, 1, 2}, {3, 5, 3, 5}, {0, 0, 0, 0}, 0);
   244   auto pnt_rect1 = 
Rect{0, 0, 0.5, 0.5}, pnt_rect2 = pnt_rect1;
   249   auto pnt_rect1 = 
Rect{0, 0, 0, 0}, pnt_rect2 = 
Rect{0, 0, 1, 1};
   255   auto pnt_rect = 
Rect{0.5, 0.5, 0.5, 0.5}, rect = 
Rect{0, 1, 0, 1};
   261   auto pnt_rect = 
Rect{2, 2, 2, 2}, rect = 
Rect{0, 1, 0, 1};
   297 int main (
int argc, 
char *argv[]) {
   298   ::testing::InitGoogleTest(&argc, argv);
   299   return RUN_ALL_TESTS();
 TEST_F(LWRIntersectionOverlapTest, noIntersectionSameSize)
 
auto overlap(const LightWeightRectangle &that) const 
 
auto intersect(const LightWeightRectangle &that) const 
 
static constexpr auto Base_Outer_Overlap
 
void check_intersection(const Rect &r1, const Rect &r2, const Rect &exp_inters, double exp_overlap) const 
 
void test_corner_inclusion(const Directions &dirs) const 
 
int main(int argc, char *argv[])
 
LightWeightRectangle Rect
 
void test_proper_inclusion(const Directions &dirs, double exp_outer_overlap) const 
 
void test_edge_inclusion(const Directions &dir)