GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/box_box_collision.cpp Lines: 21 21 100.0 %
Date: 2024-02-09 12:57:42 Branches: 72 144 50.0 %

Line Branch Exec Source
1
#define BOOST_TEST_MODULE BOX_BOX_COLLISION
2
#include <boost/test/included/unit_test.hpp>
3
4
#include <Eigen/Geometry>
5
#include <hpp/fcl/narrowphase/narrowphase.h>
6
#include <hpp/fcl/shape/geometric_shapes.h>
7
#include <hpp/fcl/internal/tools.h>
8
9
#include "utility.h"
10
11
using hpp::fcl::Box;
12
using hpp::fcl::collide;
13
using hpp::fcl::CollisionRequest;
14
using hpp::fcl::CollisionResult;
15
using hpp::fcl::ComputeCollision;
16
using hpp::fcl::FCL_REAL;
17
using hpp::fcl::Transform3f;
18
using hpp::fcl::Vec3f;
19
20
















4
BOOST_AUTO_TEST_CASE(box_box_collision) {
21
  // Define boxes
22
4
  Box shape1(1, 1, 1);
23
4
  Box shape2(1, 1, 1);
24
25
  // Define transforms
26
2
  Transform3f T1 = Transform3f::Identity();
27
2
  Transform3f T2 = Transform3f::Identity();
28
29
  // Compute collision
30
2
  CollisionRequest req;
31
2
  req.enable_cached_gjk_guess = true;
32
2
  req.distance_upper_bound = 1e-6;
33
4
  CollisionResult res;
34
4
  ComputeCollision collide_functor(&shape1, &shape2);
35
36

2
  T1.setTranslation(Vec3f(0, 0, 0));
37
2
  res.clear();
38



2
  BOOST_CHECK(collide(&shape1, T1, &shape2, T2, req, res) == true);
39
2
  res.clear();
40



2
  BOOST_CHECK(collide_functor(T1, T2, req, res) == true);
41
42

2
  T1.setTranslation(Vec3f(2, 0, 0));
43
2
  res.clear();
44



2
  BOOST_CHECK(collide(&shape1, T1, &shape2, T2, req, res) == false);
45
2
  res.clear();
46



2
  BOOST_CHECK(collide_functor(T1, T2, req, res) == false);
47
2
}