broadphase_spatialhash.h
Go to the documentation of this file.
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 
38 #ifndef HPP_FCL_BROADPHASE_BROADPAHSESPATIALHASH_H
39 #define HPP_FCL_BROADPHASE_BROADPAHSESPATIALHASH_H
40 
41 #include <list>
42 #include <map>
43 #include "hpp/fcl/BV/AABB.h"
48 
49 namespace hpp {
50 namespace fcl {
51 
53 template <typename HashTable = detail::SimpleHashTable<AABB, CollisionObject*,
54  detail::SpatialHash> >
56  public:
58  using Base::getObjects;
59 
60  SpatialHashingCollisionManager(FCL_REAL cell_size, const Vec3f& scene_min,
61  const Vec3f& scene_max,
62  unsigned int default_table_size = 1000);
63 
65 
67  void registerObject(CollisionObject* obj);
68 
70  void unregisterObject(CollisionObject* obj);
71 
73  void setup();
74 
76  virtual void update();
77 
79  void update(CollisionObject* updated_obj);
80 
82  void update(const std::vector<CollisionObject*>& updated_objs);
83 
85  void clear();
86 
88  void getObjects(std::vector<CollisionObject*>& objs) const;
89 
92  void collide(CollisionObject* obj, CollisionCallBackBase* callback) const;
93 
96  void distance(CollisionObject* obj, DistanceCallBackBase* callback) const;
97 
101 
105 
107  void collide(BroadPhaseCollisionManager* other_manager,
109 
111  void distance(BroadPhaseCollisionManager* other_manager,
113 
115  bool empty() const;
116 
118  size_t size() const;
119 
121  static void computeBound(std::vector<CollisionObject*>& objs, Vec3f& l,
122  Vec3f& u);
123 
124  protected:
127  bool collide_(CollisionObject* obj, CollisionCallBackBase* callback) const;
128 
131  bool distance_(CollisionObject* obj, DistanceCallBackBase* callback,
132  FCL_REAL& min_dist) const;
133 
135  std::list<CollisionObject*> objs;
136 
139  std::list<CollisionObject*> objs_partially_penetrating_scene_limit;
140 
142  std::list<CollisionObject*> objs_outside_scene_limit;
143 
146 
149  std::map<CollisionObject*, AABB> obj_aabb_map;
150 
153  HashTable* hash_table;
154 
155  private:
157 
158  template <typename Container>
159  bool distanceObjectToObjects(CollisionObject* obj, const Container& objs,
161  FCL_REAL& min_dist) const;
162 };
163 
164 } // namespace fcl
165 
166 } // namespace hpp
167 
169 
170 #endif
bool distanceObjectToObjects(CollisionObject *obj, const Container &objs, DistanceCallBackBase *callback, FCL_REAL &min_dist) const
void setup()
initialize the manager, related with the specific type of manager
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Main namespace.
Base callback class for collision queries. This class can be supersed by child classes to provide des...
static void computeBound(std::vector< CollisionObject *> &objs, Vec3f &l, Vec3f &u)
compute the bound for the environent
SpatialHashingCollisionManager(FCL_REAL cell_size, const Vec3f &scene_min, const Vec3f &scene_max, unsigned int default_table_size=1000)
spatial hashing collision mananger
virtual void update()
update the condition of manager
size_t size() const
the number of objects managed by the manager
double FCL_REAL
Definition: data_types.h:65
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const
perform distance computation between one object and all the objects belonging ot the manager ...
std::list< CollisionObject * > objs_partially_penetrating_scene_limit
objects partially penetrating (not totally inside nor outside) the scene limit are in another list ...
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
bool empty() const
whether the manager is empty
bool distance_(CollisionObject *obj, DistanceCallBackBase *callback, FCL_REAL &min_dist) const
perform distance computation between one object and all the objects belonging ot the manager ...
std::list< CollisionObject * > objs_outside_scene_limit
objects outside the scene limit are in another list
void unregisterObject(CollisionObject *obj)
remove one object from the manager
HashTable * hash_table
objects in the scene limit (given by scene_min and scene_max) are in the spatial hash table ...
std::list< CollisionObject * > objs
all objects in the scene
bool collide_(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager ...
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager ...
std::map< CollisionObject *, AABB > obj_aabb_map
store the map between objects and their aabbs. will make update more convenient
void registerObject(CollisionObject *obj)
add one object to the manager


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:00