hpp-fcl 2.4.1
HPP fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
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
49namespace hpp {
50namespace fcl {
51
53template <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
68
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
100 void collide(CollisionCallBackBase* callback) const;
101
104 void distance(DistanceCallBackBase* callback) const;
105
107 void collide(BroadPhaseCollisionManager* other_manager,
108 CollisionCallBackBase* callback) const;
109
111 void distance(BroadPhaseCollisionManager* other_manager,
112 DistanceCallBackBase* callback) const;
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
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:
156 enum ObjectStatus { Inside, PartiallyPenetrating, Outside };
157
158 template <typename Container>
159 bool distanceObjectToObjects(CollisionObject* obj, const Container& objs,
160 DistanceCallBackBase* callback,
161 FCL_REAL& min_dist) const;
162};
163
164} // namespace fcl
165
166} // namespace hpp
167
169
170#endif
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition: AABB.h:54
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: broadphase_collision_manager.h:54
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: broadphase_collision_manager.h:88
the object for collision or distance computation, contains the geometry and the transform information
Definition: collision_object.h:215
spatial hashing collision mananger
Definition: broadphase_spatialhash.h:55
std::list< CollisionObject * > objs_outside_scene_limit
objects outside the scene limit are in another list
Definition: broadphase_spatialhash.h:142
AABB scene_limit
the size of the scene
Definition: broadphase_spatialhash.h:145
std::list< CollisionObject * > objs_partially_penetrating_scene_limit
objects partially penetrating (not totally inside nor outside) the scene limit are in another list
Definition: broadphase_spatialhash.h:139
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: broadphase_collision_manager.h:88
virtual void update()
update the condition of manager
Definition: broadphase_spatialhash-inl.h:112
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const
perform distance computation between one object and all the objects belonging ot the manager
Definition: broadphase_spatialhash-inl.h:263
void setup()
initialize the manager, related with the specific type of manager
Definition: broadphase_spatialhash-inl.h:106
BroadPhaseCollisionManager Base
Definition: broadphase_spatialhash.h:57
void unregisterObject(CollisionObject *obj)
remove one object from the manager
Definition: broadphase_spatialhash-inl.h:85
std::list< CollisionObject * > objs
all objects in the scene
Definition: broadphase_spatialhash.h:135
size_t size() const
the number of objects managed by the manager
Definition: broadphase_spatialhash-inl.h:496
bool empty() const
whether the manager is empty
Definition: broadphase_spatialhash-inl.h:490
~SpatialHashingCollisionManager()
Definition: broadphase_spatialhash-inl.h:58
HashTable * hash_table
objects in the scene limit (given by scene_min and scene_max) are in the spatial hash table
Definition: broadphase_spatialhash.h:153
void clear()
clear the manager
Definition: broadphase_spatialhash-inl.h:238
bool collide_(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: broadphase_spatialhash-inl.h:272
static void computeBound(std::vector< CollisionObject * > &objs, Vec3f &l, Vec3f &u)
compute the bound for the environent
Definition: broadphase_spatialhash-inl.h:502
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: broadphase_spatialhash-inl.h:255
std::map< CollisionObject *, AABB > obj_aabb_map
store the map between objects and their aabbs. will make update more convenient
Definition: broadphase_spatialhash.h:149
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
Definition: broadphase_spatialhash-inl.h:311
void registerObject(CollisionObject *obj)
add one object to the manager
Definition: broadphase_spatialhash-inl.h:64
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:66
double FCL_REAL
Definition: data_types.h:65
Main namespace.
Definition: broadphase_bruteforce.h:44
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: broadphase_callbacks.h:50
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: broadphase_callbacks.h:73