GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/hpp/fcl/broadphase/broadphase_callbacks.h Lines: 6 6 100.0 %
Date: 2024-02-09 12:57:42 Branches: 0 0 - %

Line Branch Exec Source
1
/*
2
 * Software License Agreement (BSD License)
3
 *
4
 *  Copyright (c) 2022, INRIA
5
 *  All rights reserved.
6
 *
7
 *  Redistribution and use in source and binary forms, with or without
8
 *  modification, are permitted provided that the following conditions
9
 *  are met:
10
 *
11
 *   * Redistributions of source code must retain the above copyright
12
 *     notice, this list of conditions and the following disclaimer.
13
 *   * Redistributions in binary form must reproduce the above
14
 *     copyright notice, this list of conditions and the following
15
 *     disclaimer in the documentation and/or other materials provided
16
 *     with the distribution.
17
 *   * Neither the name of the copyright holder nor the names of its
18
 *     contributors may be used to endorse or promote products derived
19
 *     from this software without specific prior written permission.
20
 *
21
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
 *  POSSIBILITY OF SUCH DAMAGE.
33
 */
34
35
/** @author Justin Carpentier (justin.carpentier@inria.fr) */
36
37
#ifndef HPP_FCL_BROADPHASE_BROAD_PHASE_CALLBACKS_H
38
#define HPP_FCL_BROADPHASE_BROAD_PHASE_CALLBACKS_H
39
40
#include "hpp/fcl/fwd.hh"
41
#include "hpp/fcl/data_types.h"
42
43
namespace hpp {
44
namespace fcl {
45
46
/// @brief Base callback class for collision queries.
47
/// This class can be supersed by child classes to provide desired behaviors
48
/// according to the application (e.g, only listing the potential
49
/// CollisionObjects in collision).
50
struct HPP_FCL_DLLAPI CollisionCallBackBase {
51
  /// @brief Initialization of the callback before running the collision
52
  /// broadphase manager.
53
8
  virtual void init(){};
54
55
  /// @brief Collision evaluation between two objects in collision.
56
  ///        This callback will cause the broadphase evaluation to stop if it
57
  ///        returns true.
58
  ///
59
  /// @param[in] o1 Collision object #1.
60
  /// @param[in] o2 Collision object #2.
61
  virtual bool collide(CollisionObject* o1, CollisionObject* o2) = 0;
62
63
  /// @brief Functor call associated to the collide operation.
64
1224486
  virtual bool operator()(CollisionObject* o1, CollisionObject* o2) {
65
1224486
    return collide(o1, o2);
66
  }
67
};
68
69
/// @brief Base callback class for distance queries.
70
/// This class can be supersed by child classes to provide desired behaviors
71
/// according to the application (e.g, only listing the potential
72
/// CollisionObjects in collision).
73
struct HPP_FCL_DLLAPI DistanceCallBackBase {
74
  /// @brief Initialization of the callback before running the collision
75
  /// broadphase manager.
76
8
  virtual void init(){};
77
78
  /// @brief Distance evaluation between two objects in collision.
79
  ///        This callback will cause the broadphase evaluation to stop if it
80
  ///        returns true.
81
  ///
82
  /// @param[in] o1 Collision object #1.
83
  /// @param[in] o2 Collision object #2.
84
  /// @param[out] dist Distance between the two collision geometries.
85
  virtual bool distance(CollisionObject* o1, CollisionObject* o2,
86
                        FCL_REAL& dist) = 0;
87
88
  /// @brief Functor call associated to the distance operation.
89
17238
  virtual bool operator()(CollisionObject* o1, CollisionObject* o2,
90
                          FCL_REAL& dist) {
91
17238
    return distance(o1, o2, dist);
92
  }
93
};
94
95
}  // namespace fcl
96
}  // namespace hpp
97
98
#endif  // HPP_FCL_BROADPHASE_BROAD_PHASE_CALLBACKS_H