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

Line Branch Exec Source
1
/*
2
 * Software License Agreement (BSD License)
3
 *
4
 *  Copyright (c) 2011-2014, Willow Garage, Inc.
5
 *  Copyright (c) 2014-2016, Open Source Robotics Foundation
6
 *  All rights reserved.
7
 *
8
 *  Redistribution and use in source and binary forms, with or without
9
 *  modification, are permitted provided that the following conditions
10
 *  are met:
11
 *
12
 *   * Redistributions of source code must retain the above copyright
13
 *     notice, this list of conditions and the following disclaimer.
14
 *   * Redistributions in binary form must reproduce the above
15
 *     copyright notice, this list of conditions and the following
16
 *     disclaimer in the documentation and/or other materials provided
17
 *     with the distribution.
18
 *   * Neither the name of Open Source Robotics Foundation nor the names of its
19
 *     contributors may be used to endorse or promote products derived
20
 *     from this software without specific prior written permission.
21
 *
22
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
 *  POSSIBILITY OF SUCH DAMAGE.
34
 */
35
36
/** @author Jia Pan */
37
38
#ifndef HPP_FCL_BROADPHASE_BROADPHASECOLLISIONMANAGER_H
39
#define HPP_FCL_BROADPHASE_BROADPHASECOLLISIONMANAGER_H
40
41
#include <set>
42
#include <vector>
43
#include <boost/function.hpp>
44
45
#include "hpp/fcl/collision_object.h"
46
#include "hpp/fcl/broadphase/broadphase_callbacks.h"
47
48
namespace hpp {
49
namespace fcl {
50
51
/// @brief Base class for broad phase collision. It helps to accelerate the
52
/// collision/distance between N objects. Also support self collision, self
53
/// distance and collision/distance with another M objects.
54
class HPP_FCL_DLLAPI BroadPhaseCollisionManager {
55
 public:
56
  BroadPhaseCollisionManager();
57
58
  virtual ~BroadPhaseCollisionManager();
59
60
  /// @brief add objects to the manager
61
  virtual void registerObjects(const std::vector<CollisionObject*>& other_objs);
62
63
  /// @brief add one object to the manager
64
  virtual void registerObject(CollisionObject* obj) = 0;
65
66
  /// @brief remove one object from the manager
67
  virtual void unregisterObject(CollisionObject* obj) = 0;
68
69
  /// @brief initialize the manager, related with the specific type of manager
70
  virtual void setup() = 0;
71
72
  /// @brief update the condition of manager
73
  virtual void update() = 0;
74
75
  /// @brief update the manager by explicitly given the object updated
76
  virtual void update(CollisionObject* updated_obj);
77
78
  /// @brief update the manager by explicitly given the set of objects update
79
  virtual void update(const std::vector<CollisionObject*>& updated_objs);
80
81
  /// @brief clear the manager
82
  virtual void clear() = 0;
83
84
  /// @brief return the objects managed by the manager
85
  virtual void getObjects(std::vector<CollisionObject*>& objs) const = 0;
86
87
  /// @brief return the objects managed by the manager
88
  virtual std::vector<CollisionObject*> getObjects() const {
89
    std::vector<CollisionObject*> res(size());
90
    getObjects(res);
91
    return res;
92
  };
93
94
  /// @brief perform collision test between one object and all the objects
95
  /// belonging to the manager
96
  virtual void collide(CollisionObject* obj,
97
                       CollisionCallBackBase* callback) const = 0;
98
99
  /// @brief perform distance computation between one object and all the objects
100
  /// belonging to the manager
101
  virtual void distance(CollisionObject* obj,
102
                        DistanceCallBackBase* callback) const = 0;
103
104
  /// @brief perform collision test for the objects belonging to the manager
105
  /// (i.e., N^2 self collision)
106
  virtual void collide(CollisionCallBackBase* callback) const = 0;
107
108
  /// @brief perform distance test for the objects belonging to the manager
109
  /// (i.e., N^2 self distance)
110
  virtual void distance(DistanceCallBackBase* callback) const = 0;
111
112
  /// @brief perform collision test with objects belonging to another manager
113
  virtual void collide(BroadPhaseCollisionManager* other_manager,
114
                       CollisionCallBackBase* callback) const = 0;
115
116
  /// @brief perform distance test with objects belonging to another manager
117
  virtual void distance(BroadPhaseCollisionManager* other_manager,
118
                        DistanceCallBackBase* callback) const = 0;
119
120
  /// @brief whether the manager is empty
121
  virtual bool empty() const = 0;
122
123
  /// @brief the number of objects managed by the manager
124
  virtual size_t size() const = 0;
125
126
 protected:
127
  /// @brief tools help to avoid repeating collision or distance callback for
128
  /// the pairs of objects tested before. It can be useful for some of the
129
  /// broadphase algorithms.
130
  mutable std::set<std::pair<CollisionObject*, CollisionObject*> > tested_set;
131
  mutable bool enable_tested_set_;
132
133
  bool inTestedSet(CollisionObject* a, CollisionObject* b) const;
134
135
  void insertTestedSet(CollisionObject* a, CollisionObject* b) const;
136
};
137
138
}  // namespace fcl
139
}  // namespace hpp
140
141
#endif