Robotics Library  0.7.0
Scene.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_SG_FCL_SCENE_H
28 #define RL_SG_FCL_SCENE_H
29 
30 #include <unordered_map>
31 #include <fcl/collision.h>
32 #include <fcl/broadphase/broadphase.h>
33 
34 #include "../DepthScene.h"
35 #include "../DistanceScene.h"
36 #include "../SimpleScene.h"
37 
38 namespace rl
39 {
40  namespace sg
41  {
47  namespace fcl
48  {
50  {
51  public:
52  Scene();
53 
54  virtual ~Scene();
55 
56  void add(::rl::sg::Model* model);
57 
58  void addCollisionObject(::fcl::CollisionObject* collisionObject, Body* body);
59 
60  bool areColliding(::rl::sg::Body* first, ::rl::sg::Body* second);
61 
62  bool areColliding(::rl::sg::Model* first, ::rl::sg::Model* second);
63 
64  bool areColliding(::rl::sg::Shape* first, ::rl::sg::Shape* second);
65 
67 
68  ::rl::math::Real depth(::rl::sg::Shape* first, ::rl::sg::Shape* second, ::rl::math::Vector3& point1, ::rl::math::Vector3& point2);
69 
70  ::rl::math::Real distance(::rl::sg::Body* first, ::rl::sg::Body* second, ::rl::math::Vector3& point1, ::rl::math::Vector3& point2);
71 
73 
75 
77 
78  bool isColliding();
79 
80  void remove(::rl::sg::Model* model);
81 
82  void removeCollisionObject(::fcl::CollisionObject* collisionObject);
83 
84  ::fcl::DynamicAABBTreeCollisionManager manager;
85 
86  protected:
87 
88  private:
90  {
91  CollisionData(const ::std::unordered_map< ::fcl::CollisionObject*, Body*>& bodyForObj) :
93  done(false),
94  request(),
95  result()
96  {
97  }
98 
99  const ::std::unordered_map< ::fcl::CollisionObject*, Body*>& bodyForObj;
100 
101  bool done;
102 
103  ::fcl::CollisionRequest request;
104 
105  ::fcl::CollisionResult result;
106  };
107 
109  {
110  DistanceData(const ::std::unordered_map< ::fcl::CollisionObject*, Body*>& bodyForObj) :
112  done(false),
113  request(true),
114  result()
115  {
116  }
117 
118  const ::std::unordered_map< ::fcl::CollisionObject*, Body*>& bodyForObj;
119 
120  bool done;
121 
122  ::fcl::DistanceRequest request;
123 
124  ::fcl::DistanceResult result;
125  };
126 
127  static bool defaultCollisionFunction(::fcl::CollisionObject* o1, ::fcl::CollisionObject* o2, void* data);
128 
129  static bool defaultDistanceFunction(::fcl::CollisionObject* o1, ::fcl::CollisionObject* o2, void* data, ::fcl::FCL_REAL& dist);
130 
131  ::std::unordered_map< ::fcl::CollisionObject*, Body*> bodyForObj;
132  };
133  }
134  }
135 }
136 
137 #endif // RL_SG_FCL_SCENE_H
rl::sg::DistanceScene
Definition: DistanceScene.h:44
rl::sg::fcl::Scene::Scene
Scene()
Definition: Scene.cpp:46
rl::sg::fcl::Scene::isColliding
bool isColliding()
Definition: Scene.cpp:313
rl::sg::fcl::Body
Definition: Body.h:44
rl::sg::fcl::Scene::areColliding
bool areColliding(::rl::sg::Body *first, ::rl::sg::Body *second)
Definition: Scene.cpp:85
rl::sg::fcl::Scene::defaultDistanceFunction
static bool defaultDistanceFunction(::fcl::CollisionObject *o1, ::fcl::CollisionObject *o2, void *data, ::fcl::FCL_REAL &dist)
Definition: Scene.cpp:159
rl::sg::fcl::Scene::CollisionData::CollisionData
CollisionData(const ::std::unordered_map< ::fcl::CollisionObject *, Body * > &bodyForObj)
Definition: Scene.h:91
rl::sg::fcl::Scene::manager
::fcl::DynamicAABBTreeCollisionManager manager
Definition: Scene.h:84
rl::sg::fcl::Scene::defaultCollisionFunction
static bool defaultCollisionFunction(::fcl::CollisionObject *o1, ::fcl::CollisionObject *o2, void *data)
Definition: Scene.cpp:132
rl::sg::fcl::Scene::DistanceData::done
bool done
Definition: Scene.h:120
rl::sg::fcl::Scene::DistanceData::result
::fcl::DistanceResult result
Definition: Scene.h:124
rl::math::Vector3
::Eigen::Matrix< Real, 3, 1 > Vector3
Definition: Vector.h:46
rl::sg::fcl::Scene::create
::rl::sg::Model * create()
Definition: Scene.cpp:126
rl::sg::fcl::Scene::DistanceData
Definition: Scene.h:109
rl::sg::Body
Definition: Body.h:45
rl::sg::fcl::Scene::CollisionData::bodyForObj
const ::std::unordered_map< ::fcl::CollisionObject *, Body * > & bodyForObj
Definition: Scene.h:99
rl::sg::fcl::Scene::~Scene
virtual ~Scene()
Definition: Scene.cpp:55
rl::sg::fcl::Scene::add
void add(::rl::sg::Model *model)
Definition: Scene.cpp:64
rl::sg::fcl::Scene::CollisionData::request
::fcl::CollisionRequest request
Definition: Scene.h:103
rl::sg::fcl::Scene::DistanceData::request
::fcl::DistanceRequest request
Definition: Scene.h:122
rl::sg::Model
Definition: Model.h:43
rl::sg::fcl::Scene::CollisionData
Definition: Scene.h:90
rl::sg::fcl::Scene
Definition: Scene.h:50
rl::sg::fcl::Scene::distance
::rl::math::Real distance(::rl::sg::Body *first, ::rl::sg::Body *second, ::rl::math::Vector3 &point1, ::rl::math::Vector3 &point2)
Definition: Scene.cpp:220
rl::sg::fcl::Scene::bodyForObj
::std::unordered_map< ::fcl::CollisionObject *, Body * > bodyForObj
Definition: Scene.h:131
rl::sg::fcl::Scene::removeCollisionObject
void removeCollisionObject(::fcl::CollisionObject *collisionObject)
Definition: Scene.cpp:340
rl::sg::fcl::Scene::addCollisionObject
void addCollisionObject(::fcl::CollisionObject *collisionObject, Body *body)
Definition: Scene.cpp:78
rl::sg::fcl::Scene::depth
::rl::math::Real depth(::rl::sg::Shape *first, ::rl::sg::Shape *second, ::rl::math::Vector3 &point1, ::rl::math::Vector3 &point2)
Definition: Scene.cpp:191
rl::sg::fcl::Scene::CollisionData::done
bool done
Definition: Scene.h:101
rl::sg::fcl::Scene::DistanceData::DistanceData
DistanceData(const ::std::unordered_map< ::fcl::CollisionObject *, Body * > &bodyForObj)
Definition: Scene.h:110
rl::sg::fcl::Scene::DistanceData::bodyForObj
const ::std::unordered_map< ::fcl::CollisionObject *, Body * > & bodyForObj
Definition: Scene.h:118
rl::sg::fcl::Scene::CollisionData::result
::fcl::CollisionResult result
Definition: Scene.h:105
rl::sg::Shape
Definition: Shape.h:41
rl::sg::DepthScene
Definition: DepthScene.h:42
rl::math::Real
double Real
Definition: Real.h:42
rl::sg::SimpleScene
Definition: SimpleScene.h:41
rl::sg::fcl::Scene::remove
void remove(::rl::sg::Model *model)
Definition: Scene.cpp:322
rl
Robotics Library.
Definition: AnalogInput.cpp:30