13 for (
auto el : this->shapes_) {
14 if (el->BVCheck(aabb)) {
15 sg_new->addToGroup(el);
22 if (shapes_.size() == 0)
25 double min_x = std::numeric_limits<double>::max();
26 double max_x = std::numeric_limits<double>::min();
27 double min_y = std::numeric_limits<double>::max();
28 double max_y = std::numeric_limits<double>::min();
29 for (
auto el : shapes_) {
30 auto cur_aabb = el->getAABB();
31 double cur_min_x = cur_aabb->min()(0);
32 double cur_min_y = cur_aabb->min()(1);
33 double cur_max_x = cur_aabb->max()(0);
34 double cur_max_y = cur_aabb->max()(1);
35 min_x = std::min(min_x, cur_min_x);
36 min_y = std::min(min_y, cur_min_y);
37 max_x = std::max(max_x, cur_max_x);
38 max_y = std::max(max_y, cur_max_y);
40 Eigen::Vector2d center((min_x + max_x) / 2, (min_y + max_y) / 2);
41 double radius_x = (max_x - min_x) / 2;
42 double radius_y = (max_y - min_y) / 2;
50 for (
auto i : shapes_) {
55 obj_vec.push_back(obj);
74 int first_el_count = shapes_.size();
75 std::vector<std::set<int>> ret(first_el_count);
76 std::vector<std::pair<int, int>> collid_list =
overlap(sg);
77 for (
auto el : collid_list) {
78 int first_val = el.first;
79 if (first_val > -1 && first_val < first_el_count) {
80 ret[first_val].insert(el.second);
94 const Eigen::Vector2d &point2,
95 std::vector<LineSegment> &intersect)
const {
97 for (
auto &obj : shapes_) {
98 res = obj->rayTrace(point1, point2, intersect) || res;
116 if (!fcl_gr_ptr_this || !fcl_gr_ptr_sg) {
119 std::vector<std::pair<int, int>> ret;
126 auto el = shapes_map_.find(&obj);
127 if (el != shapes_map_.end()) {
128 el->second.push_back(idx);
130 std::list<int> new_list;
131 new_list.push_back(idx);
132 shapes_map_.emplace(&obj, new_list);
138 std::list<int> &retlist)
const {
139 auto el = shapes_map_.find(pObj);
140 if (el != shapes_map_.end()) {
141 retlist.insert(retlist.end(), el->second.begin(), el->second.end());
151 stream <<
"ShapeGroup " 153 for (
auto &shape : shapes_) {
154 shape->toString(stream);
156 stream <<
"\\ShapeGroup " << std::endl;
161 return shared_ptr_this;
177 shapes_.push_back(shape);
178 addToIndex(*shape, shapes_.size() - 1);
191 std::list<CollisionObjectConstPtr>> &parent_map,
193 for (
auto &shape : shapes_) {
194 shape->addParentMap(parent_map, parent);
200 std::list<CollisionObjectConstPtr>> &parent_map)
const {
201 for (
auto &shape : shapes_) {
202 shape->addParentMap(parent_map, shared_from_this());
205 #if ENABLE_SERIALIZER 212 return serialize::exportObject(*
this);
int getCollisionObjects(std::vector< fcl::CollisionObject< FCL_PRECISION > *> &obj_vec) const override
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...
virtual CollisionObjectConstPtr timeSlice(int time_idx, CollisionObjectConstPtr shared_ptr_this) const
std::shared_ptr< const Shape > ShapeConstPtr
std::vector< ShapeConstPtr > unpack() const
Returns Vector of all shapes contained inside the ShapeGroup.
std::shared_ptr< const RectangleAABB > RectangleAABBConstPtr
std::shared_ptr< const collision::RectangleAABB > getAABB() const
ShapeGroup can contain simple shapes.
void invalidateCollisionEntityCache(void)
bool rayTrace(const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect) const
std::shared_ptr< const CollisionObject > CollisionObjectConstPtr
const FCLCollisionObject * get_fcl_object_ptr(const CollisionObject *obj)
void toString(std::ostringstream &stream) const
int elementCount(void) const
Returns count of contained objects.
ShapeGroupConstPtr windowQuery(collision::RectangleAABBConstPtr aabb) const
std::shared_ptr< fcl::CollisionObject< FCL_PRECISION > > getCollisionObject_fcl(void) const
std::shared_ptr< const ShapeGroup > ShapeGroupConstPtr
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...
virtual void print(std::ostringstream &stream) const
std::shared_ptr< ShapeGroup > ShapeGroupPtr
int queryContainedObjectIndexList(const CollisionObject *, std::list< int > &retlist) const override
int serialize(const test::BroadphaseFailureCCObj &bf_object, std::ostream &output_stream, const char *format=SERIALIZER_DEFAULT_FORMAT)
int fcl_group_overlap(const FCLCollisionObjectGroup &group_first, const FCLCollisionObjectGroup &group_second, std::vector< std::pair< int, int >> &retlist, std::vector< std::pair< int, int >> *missed_col_naive_in=0)
Base class for CollisionObjects and some of their groups.
void addToGroup(ShapeConstPtr shape)
Adds a simple shape to the ShapeGroup.
const FCLCollisionObjectGroup * get_fcl_object_group_ptr(const CollisionObject *obj)
virtual void addParentMap(std::unordered_map< const CollisionObject *, std::list< CollisionObjectConstPtr >> &parent_map) const