Collision Checker
boost_geometry_queries.cc
Go to the documentation of this file.
1 
5 
7 
8 namespace collision {
9 namespace solvers {
10 namespace solverBoost {
12  collision::ShapeGroup &sg_polys, double buf_width, bool triangulate) {
13  collision::ShapeGroupPtr sg_ret = std::make_shared<collision::ShapeGroup>();
14  auto sg_ret_ptr = sg_ret.get();
15 
16  std::vector<collision::BoostPolygon *> candidate_polygons_boost;
17 
18  for (auto obj : sg_polys.unpack()) {
19  if (obj->getCollisionObjectType() == collision::OBJ_TYPE_POLYGON) {
20  auto poly_ptr = static_cast<const collision::Polygon *>(obj.get());
21  candidate_polygons_boost.push_back(static_cast<collision::BoostPolygon *>(
23  ->getCollisionObject_boost()
24  .get()));
25  } else {
26  throw std::invalid_argument(
27  "The shape group for the postprocessing of lane polygons can contain "
28  "only collision::Polygon objects");
29  }
30  }
31 
32  collision::triangulation::TriangulationQuality qual;
33 
34  qual.bb_only = !triangulate;
35 
36  for (auto boost_poly_ptr : candidate_polygons_boost) {
37  std::vector<collision::BoostPolygon> output;
38  if (buf_width) {
39  boost_poly_ptr->extend(output, buf_width);
40  for (auto poly : output) {
41  sg_ret_ptr->addToGroup(poly.toPolygon(qual));
42  }
43  } else {
44  sg_ret_ptr->addToGroup(boost_poly_ptr->toPolygon(qual));
45  }
46  }
47  return sg_ret;
48 }
49 } // namespace solverBoost
50 } // namespace solvers
51 } // namespace collision
std::vector< ShapeConstPtr > unpack() const
Returns Vector of all shapes contained inside the ShapeGroup.
Definition: shape_group.cc:187
ShapeGroup can contain simple shapes.
Definition: shape_group.h:33
const BoostCollisionObject * get_boost_object_ptr(const CollisionObject *obj)
Definition: boost_helpers.h:10
collision::ShapeGroupPtr lane_polygons_postprocess(collision::ShapeGroup &sg_polys, double buf_width, bool triangulate)
std::shared_ptr< ShapeGroup > ShapeGroupPtr
Definition: polygon.h:17
Polygon contains Triangles and Vertices.
Definition: polygon.h:29