coal/broadphase/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 COAL_BROADPHASE_BROADPAHSESPATIALHASH_H
39 #define COAL_BROADPHASE_BROADPAHSESPATIALHASH_H
40 
41 #include <list>
42 #include <map>
43 #include "coal/BV/AABB.h"
48 
49 namespace coal {
50 
52 template <typename HashTable = detail::SimpleHashTable<AABB, CollisionObject*,
53  detail::SpatialHash> >
55  public:
57  using Base::getObjects;
58 
59  SpatialHashingCollisionManager(CoalScalar cell_size, const Vec3s& scene_min,
60  const Vec3s& scene_max,
61  unsigned int default_table_size = 1000);
62 
64 
67 
70 
72  void setup();
73 
75  virtual void update();
76 
78  void update(CollisionObject* updated_obj);
79 
81  void update(const std::vector<CollisionObject*>& updated_objs);
82 
84  void clear();
85 
87  void getObjects(std::vector<CollisionObject*>& objs) const;
88 
92 
96 
100 
104 
106  void collide(BroadPhaseCollisionManager* other_manager,
108 
110  void distance(BroadPhaseCollisionManager* other_manager,
112 
114  bool empty() const;
115 
117  size_t size() const;
118 
120  static void computeBound(std::vector<CollisionObject*>& objs, Vec3s& l,
121  Vec3s& u);
122 
123  protected:
127 
131  CoalScalar& min_dist) const;
132 
134  std::list<CollisionObject*> objs;
135 
138  std::list<CollisionObject*> objs_partially_penetrating_scene_limit;
139 
141  std::list<CollisionObject*> objs_outside_scene_limit;
142 
145 
148  std::map<CollisionObject*, AABB> obj_aabb_map;
149 
152  HashTable* hash_table;
153 
154  private:
156 
157  template <typename Container>
158  bool distanceObjectToObjects(CollisionObject* obj, const Container& objs,
160  CoalScalar& min_dist) const;
161 };
162 
163 } // namespace coal
164 
166 
167 #endif
coal::SpatialHashingCollisionManager
spatial hashing collision mananger
Definition: coal/broadphase/broadphase_spatialhash.h:54
coal::SpatialHashingCollisionManager::PartiallyPenetrating
@ PartiallyPenetrating
Definition: coal/broadphase/broadphase_spatialhash.h:155
coal::SpatialHashingCollisionManager::~SpatialHashingCollisionManager
~SpatialHashingCollisionManager()
Definition: coal/broadphase/broadphase_spatialhash-inl.h:57
coal::SpatialHashingCollisionManager::objs
std::list< CollisionObject * > objs
all objects in the scene
Definition: coal/broadphase/broadphase_spatialhash.h:134
coal::Vec3s
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
Definition: coal/data_types.h:77
collision_manager.callback
callback
Definition: collision_manager.py:27
broadphase_spatialhash-inl.h
simple_hash_table.h
coal::SpatialHashingCollisionManager::distanceObjectToObjects
bool distanceObjectToObjects(CollisionObject *obj, const Container &objs, DistanceCallBackBase *callback, CoalScalar &min_dist) const
Definition: coal/broadphase/broadphase_spatialhash-inl.h:513
coal::BroadPhaseCollisionManager
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: coal/broadphase/broadphase_collision_manager.h:53
coal::SpatialHashingCollisionManager::collide_
bool collide_(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:271
coal::SpatialHashingCollisionManager::objs_outside_scene_limit
std::list< CollisionObject * > objs_outside_scene_limit
objects outside the scene limit are in another list
Definition: coal/broadphase/broadphase_spatialhash.h:141
coal::SpatialHashingCollisionManager::distance
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const
perform distance computation between one object and all the objects belonging ot the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:262
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
spatial_hash.h
coal::SpatialHashingCollisionManager::distance_
bool distance_(CollisionObject *obj, DistanceCallBackBase *callback, CoalScalar &min_dist) const
perform distance computation between one object and all the objects belonging ot the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:310
coal::BroadPhaseCollisionManager::getObjects
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: coal/broadphase/broadphase_collision_manager.h:87
coal::SpatialHashingCollisionManager::size
size_t size() const
the number of objects managed by the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:495
broadphase_collision_manager.h
coal::AABB
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition: coal/BV/AABB.h:55
coal::SpatialHashingCollisionManager::unregisterObject
void unregisterObject(CollisionObject *obj)
remove one object from the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:84
sparse_hash_table.h
coal::SpatialHashingCollisionManager::obj_aabb_map
std::map< CollisionObject *, AABB > obj_aabb_map
store the map between objects and their aabbs. will make update more convenient
Definition: coal/broadphase/broadphase_spatialhash.h:148
coal::SpatialHashingCollisionManager::SpatialHashingCollisionManager
SpatialHashingCollisionManager(CoalScalar cell_size, const Vec3s &scene_min, const Vec3s &scene_max, unsigned int default_table_size=1000)
Definition: coal/broadphase/broadphase_spatialhash-inl.h:47
coal::SpatialHashingCollisionManager::update
virtual void update()
update the condition of manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:111
coal::DistanceCallBackBase
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: coal/broadphase/broadphase_callbacks.h:72
coal::CollisionObject
the object for collision or distance computation, contains the geometry and the transform information
Definition: coal/collision_object.h:214
coal::SpatialHashingCollisionManager::registerObject
void registerObject(CollisionObject *obj)
add one object to the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:63
coal::SpatialHashingCollisionManager::collide
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:254
coal::SpatialHashingCollisionManager::hash_table
HashTable * hash_table
objects in the scene limit (given by scene_min and scene_max) are in the spatial hash table
Definition: coal/broadphase/broadphase_spatialhash.h:152
coal::SpatialHashingCollisionManager::Inside
@ Inside
Definition: coal/broadphase/broadphase_spatialhash.h:155
coal::SpatialHashingCollisionManager::ObjectStatus
ObjectStatus
Definition: coal/broadphase/broadphase_spatialhash.h:155
coal::SpatialHashingCollisionManager::computeBound
static void computeBound(std::vector< CollisionObject * > &objs, Vec3s &l, Vec3s &u)
compute the bound for the environent
Definition: coal/broadphase/broadphase_spatialhash-inl.h:501
coal::SpatialHashingCollisionManager::scene_limit
AABB scene_limit
the size of the scene
Definition: coal/broadphase/broadphase_spatialhash.h:144
coal::SpatialHashingCollisionManager::empty
bool empty() const
whether the manager is empty
Definition: coal/broadphase/broadphase_spatialhash-inl.h:489
coal::SpatialHashingCollisionManager::objs_partially_penetrating_scene_limit
std::list< CollisionObject * > objs_partially_penetrating_scene_limit
objects partially penetrating (not totally inside nor outside) the scene limit are in another list
Definition: coal/broadphase/broadphase_spatialhash.h:138
coal::SpatialHashingCollisionManager::Base
BroadPhaseCollisionManager Base
Definition: coal/broadphase/broadphase_spatialhash.h:56
coal::CollisionCallBackBase
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: coal/broadphase/broadphase_callbacks.h:49
coal::SpatialHashingCollisionManager::setup
void setup()
initialize the manager, related with the specific type of manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:105
coal::SpatialHashingCollisionManager::Outside
@ Outside
Definition: coal/broadphase/broadphase_spatialhash.h:155
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
AABB.h
coal::SpatialHashingCollisionManager::clear
void clear()
clear the manager
Definition: coal/broadphase/broadphase_spatialhash-inl.h:237


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57