Collision Checker
collision_object.h
Go to the documentation of this file.
1 #ifndef COLLISION_OBJECT_H_
2 #define COLLISION_OBJECT_H_
3 
4 #include <iostream>
5 #include <list>
6 #include <memory>
7 #include <sstream>
8 #include <unordered_map>
9 
10 #include <map>
11 
13 
14 #if ENABLE_SERIALIZER
16 #endif
17 
19 
20 #include <Eigen/Dense>
21 
23 #include "collision/line_segment.h"
24 
25 namespace collision {
26 
27 class Shape;
28 class Point;
29 class RectangleAABB;
30 class RectangleOBB;
31 class Sphere;
32 class Triangle;
33 class TimeVariantCollisionObject;
34 class CollisionObject;
35 class ShapeGroup;
36 class Polygon;
37 
39 
40 typedef std::shared_ptr<CollisionObject> CollisionObjectPtr;
41 typedef std::shared_ptr<const CollisionObject> CollisionObjectConstPtr;
42 
47 class CollisionObject : public std::enable_shared_from_this<CollisionObject> {
48  public:
49  virtual ~CollisionObject() {}
50 #if ENABLE_SERIALIZER
51  virtual serialize::ICollisionObjectExport *exportThis(void) const {
52  return nullptr;
53  }
54 
55  int serialize(std::ostream &output_stream) const;
56  static CollisionObjectConstPtr deserialize(std::istream &output_stream);
57 
58 #endif
59 
62  }
65  }
66 
67  virtual bool collide(
68  const CollisionObject &c,
69  const collision::CollisionRequest &req = CollisionRequest()) const = 0;
70 
71  virtual void print(std::ostringstream &stream) const { return; }
72 
73  virtual void toString(std::ostringstream &stream) const { print(stream); }
74 
75  virtual bool BVCheck(CollisionObjectConstPtr obj2) const = 0;
76 
77  virtual std::shared_ptr<const collision::RectangleAABB> getAABB() const = 0;
78 
79  virtual void addParentMap(
80  std::unordered_map<const CollisionObject *,
81  std::list<CollisionObjectConstPtr>> &parent_map) const;
82  virtual void addParentMap(
83  std::unordered_map<const CollisionObject *,
84  std::list<CollisionObjectConstPtr>> &parent_map,
85  CollisionObjectConstPtr parent) const;
86 
87  virtual CollisionObjectConstPtr timeSlice(
88  int time_idx, CollisionObjectConstPtr shared_ptr_this) const = 0;
89 
90  virtual bool rayTrace(const Eigen::Vector2d &point1,
91  const Eigen::Vector2d &point2,
92  std::vector<LineSegment> &intersect) const {
93  return false;
94  }
95 };
96 
97 typedef std::shared_ptr<Shape> ShapePtr;
98 typedef std::shared_ptr<const Shape> ShapeConstPtr;
99 
100 typedef std::shared_ptr<RectangleAABB> RectangleAABBPtr;
101 typedef std::shared_ptr<const RectangleAABB> RectangleAABBConstPtr;
102 
103 typedef std::shared_ptr<RectangleOBB> RectangleOBBPtr;
104 typedef std::shared_ptr<const RectangleOBB> RectangleOBBConstPtr;
105 
106 } // namespace collision
107 
108 #endif
std::shared_ptr< RectangleOBB > RectangleOBBPtr
std::shared_ptr< const Shape > ShapeConstPtr
virtual CollisionObjectClass getCollisionObjectClass() const
virtual bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const
std::shared_ptr< const RectangleAABB > RectangleAABBConstPtr
virtual void addParentMap(std::unordered_map< const CollisionObject *, std::list< CollisionObjectConstPtr >> &parent_map) const
virtual CollisionObjectConstPtr timeSlice(int time_idx, CollisionObjectConstPtr shared_ptr_this) const =0
std::shared_ptr< const RectangleOBB > RectangleOBBConstPtr
virtual bool collide(const CollisionObject &c, const collision::CollisionRequest &req=CollisionRequest()) const =0
std::shared_ptr< const CollisionObject > CollisionObjectConstPtr
std::shared_ptr< RectangleAABB > RectangleAABBPtr
int deserialize(test::BroadphaseFailureCCObj &bf_object, std::istream &input_stream, const char *format=SERIALIZER_DEFAULT_FORMAT)
Universal structure specifying collision request properties.
virtual CollisionObjectType getCollisionObjectType() const
virtual void print(std::ostringstream &stream) const
std::shared_ptr< CollisionObject > CollisionObjectPtr
int serialize(const test::BroadphaseFailureCCObj &bf_object, std::ostream &output_stream, const char *format=SERIALIZER_DEFAULT_FORMAT)
virtual void toString(std::ostringstream &stream) const
virtual std::shared_ptr< const collision::RectangleAABB > getAABB() const =0
std::shared_ptr< Shape > ShapePtr
Base class for CollisionObjects and some of their groups.
virtual bool BVCheck(CollisionObjectConstPtr obj2) const =0