Collision Checker
shape_group.h
Go to the documentation of this file.
1 #ifndef SHAPE_GROUP_H_
2 #define SHAPE_GROUP_H_
3 
4 #include <iostream>
5 #include <memory>
6 #include <sstream>
7 #include <vector>
8 
9 #include <set>
10 #include <utility>
11 
12 #include "collision/application.h"
17 
19 
20 namespace collision {
21 
22 typedef std::shared_ptr<ShapeGroup> ShapeGroupPtr;
23 typedef std::shared_ptr<const ShapeGroup> ShapeGroupConstPtr;
24 
34  public ICollisionContainer,
36 #if ENABLE_COLLISION_TESTS == 1
38 #endif
39 
40  public:
41  virtual const ISolverEntity_FCL *getFclInterface() const override {
42  return this;
43  }
44 
47  }
48 
50  &obj_vec) const override;
51 
54  }
57  }
58 
59  std::shared_ptr<const collision::RectangleAABB> getAABB() const;
60 
61  ShapeGroupConstPtr windowQuery(collision::RectangleAABBConstPtr aabb) const;
62 
64 
65  virtual ~ShapeGroup() {}
66 
67  void toString(std::ostringstream &stream) const;
68 
69  bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2,
70  std::vector<LineSegment> &intersect) const;
71 
72  int elementCount(void) const;
73 
74  std::vector<std::set<int>> overlapMap(const ShapeGroup &sg) const;
75  std::vector<std::pair<int, int>> overlap(const ShapeGroup &sg) const;
76 
77  virtual void print(std::ostringstream &stream) const;
79  int time_idx, CollisionObjectConstPtr shared_ptr_this) const;
80 
81  void addToGroup(ShapeConstPtr shape);
82  std::vector<ShapeConstPtr> unpack() const;
83 #if ENABLE_SERIALIZER
84  serialize::ICollisionObjectExport *exportThis(void) const;
85 #endif
86 
87  const ICollisionContainer *getContainerInterface(void) const override {
88  return this;
89  }
90 
91  virtual void addParentMap(
92  std::unordered_map<const CollisionObject *,
93  std::list<CollisionObjectConstPtr>> &parent_map) const;
94  virtual void addParentMap(
95  std::unordered_map<const CollisionObject *,
96  std::list<CollisionObjectConstPtr>> &parent_map,
97  CollisionObjectConstPtr parent) const;
98 
100  std::list<int> &retlist) const override;
101 
102  private:
103  std::vector<ShapeConstPtr> shapes_;
104  std::unordered_map<const CollisionObject *, std::list<int>> shapes_map_;
105 
106  int addToIndex(const CollisionObject &, int idx);
107 
108  ShapeGroup(const ShapeGroup &);
109  ShapeGroup &operator=(const ShapeGroup &) { return *this; };
110 };
111 
112 } // namespace collision
113 
114 #endif
int getCollisionObjects(std::vector< fcl::CollisionObject< FCL_PRECISION > *> &obj_vec) const override
Definition: shape_group.cc:47
std::vector< std::set< int > > overlapMap(const ShapeGroup &sg) const
Returns lists of all objects from the other ShapeGroup that collide with each object of this ShapeGro...
Definition: shape_group.cc:73
virtual CollisionObjectConstPtr timeSlice(int time_idx, CollisionObjectConstPtr shared_ptr_this) const
Definition: shape_group.cc:159
std::shared_ptr< const Shape > ShapeConstPtr
std::vector< ShapeConstPtr > unpack() const
Returns Vector of all shapes contained inside the ShapeGroup.
Definition: shape_group.cc:187
std::shared_ptr< const RectangleAABB > RectangleAABBConstPtr
std::shared_ptr< const collision::RectangleAABB > getAABB() const
Definition: shape_group.cc:21
ShapeGroup can contain simple shapes.
Definition: shape_group.h:33
virtual CollisionObjectType getCollisionObjectType() const
Definition: shape_group.h:52
bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const
Definition: shape_group.cc:93
std::shared_ptr< const CollisionObject > CollisionObjectConstPtr
void toString(std::ostringstream &stream) const
Definition: shape_group.cc:150
int elementCount(void) const
Returns count of contained objects.
Definition: shape_group.cc:91
ShapeGroupConstPtr windowQuery(collision::RectangleAABBConstPtr aabb) const
Definition: shape_group.cc:10
virtual FCL_COLLISION_ENTITY_TYPE getFclEntityType(void) const
Definition: shape_group.h:45
std::shared_ptr< const ShapeGroup > ShapeGroupConstPtr
Definition: polygon.h:20
std::vector< std::pair< int, int > > overlap(const ShapeGroup &sg) const
Returns Vector of pairs of indexes of the intersecting objects within the ShapeGroup and another Shap...
Definition: shape_group.cc:111
virtual void print(std::ostringstream &stream) const
Definition: shape_group.cc:148
std::shared_ptr< ShapeGroup > ShapeGroupPtr
Definition: polygon.h:17
int queryContainedObjectIndexList(const CollisionObject *, std::list< int > &retlist) const override
Definition: shape_group.cc:137
virtual const ISolverEntity_FCL * getFclInterface() const override
Definition: shape_group.h:41
Base class for CollisionObjects and some of their groups.
void addToGroup(ShapeConstPtr shape)
Adds a simple shape to the ShapeGroup.
Definition: shape_group.cc:176
const ICollisionContainer * getContainerInterface(void) const override
Definition: shape_group.h:87
virtual void addParentMap(std::unordered_map< const CollisionObject *, std::list< CollisionObjectConstPtr >> &parent_map) const
Definition: shape_group.cc:198
Provides functionality to use different collision solvers.
CollisionObjectClass getCollisionObjectClass() const
Definition: shape_group.h:55