4 #include <boost/foreach.hpp> 5 #include <boost/geometry.hpp> 6 #include <boost/geometry/geometries/multi_polygon.hpp> 14 using namespace detail::accelerators;
17 namespace solverBoost {
29 return polyg1.
within(polyg2);
50 std::vector<bg_polygon_type> output;
56 boost::geometry::union_(*boostp_1, *boostp_2, output);
58 if (output.size() != 1) {
75 std::vector<bg_polygon_type> output;
81 boost::geometry::union_(*boostp_1, *boostp_2, output);
83 if (output.size() != 1) {
138 std::vector<bg_polygon_type>& mpoly) {
139 bg_mpolygon_type mpoly_res;
140 bg_mpolygon_type tmp_union;
142 for (
auto obj : sg.
unpack()) {
143 if (obj->getCollisionObjectType() !=
149 if (obj_poly->
getAABB()->collide(shape)) {
153 mpoly.push_back(poly_tmp);
162 std::vector<bg_polygon_type> poly_vec;
170 bg_mpolygon_type output;
172 output.push_back(cur_poly);
174 bg_mpolygon_type tmp_union;
177 BOOST_FOREACH (polygon, poly_vec) {
178 boost::geometry::clear(tmp_union);
179 boost::geometry::difference(output, polygon, tmp_union);
183 if (boost::geometry::is_empty(output) ||
192 template <
typename T>
198 std::vector<bg_polygon_type> poly_vec;
202 for (
auto el : candidates) {
203 poly_vec.push_back(*(polygons[el]->getInternal()));
206 bg_mpolygon_type output;
208 output.push_back(cur_poly);
210 bg_mpolygon_type tmp_union;
213 BOOST_FOREACH (polygon, poly_vec) {
214 boost::geometry::clear(tmp_union);
215 boost::geometry::difference(output, polygon, tmp_union);
219 if (boost::geometry::is_empty(output) ||
229 template int boost_polygon_enclosure_grid<ContainerGrid<HorizontalGrid>>(
232 template int boost_polygon_enclosure_grid<ContainerGrid<VerticalGrid>>(
240 std::vector<bg_polygon_type> poly_vec;
256 aabb = resPoly->getAABB();
262 bg_mpolygon_type output;
264 output.push_back(cur_poly);
266 bg_mpolygon_type tmp_union;
269 BOOST_FOREACH (polygon, poly_vec) {
270 boost::geometry::clear(tmp_union);
271 boost::geometry::difference(output, polygon, tmp_union);
275 if (boost::geometry::is_empty(output) ||
288 std::vector<bg_polygon_type> poly_vec;
std::vector< T, boost::alignment::aligned_allocator< T, 16 > > aligned_vector
int boost_ccd_obb_sum_collision(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
int boost_ccd_convex_hull_polygon_enclosure(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
int boost_polygon_enclosure(const ShapeGroup &sg, const RectangleOBB &obb, bool &res)
std::vector< ShapeConstPtr > unpack() const
Returns Vector of all shapes contained inside the ShapeGroup.
int windowQuery(ContainerGrid< DIRECTION > &container, AABB &aabb, aligned_vector< int > &candidates)
std::shared_ptr< const RectangleAABB > RectangleAABBConstPtr
boost::geometry::model::multi_polygon< bg_polygon_type > bg_mpolygon_type
BoostPolygonConstPtr convexHull(void) const
Computes a convex hull of the given BoostPolygon.
ShapeGroup can contain simple shapes.
RectangleOBBConstPtr ccd_merge_entities(const RectangleOBB *first, const RectangleOBB *second)
std::shared_ptr< const RectangleOBB > RectangleOBBConstPtr
int boost_ccd_convex_hull_collision(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
Checks if the convex hull of the Boolean union of two given OBB boxes collides with any of the ShapeG...
boost::geometry::model::polygon< bg_point_type > bg_polygon_type
std::shared_ptr< const Polygon > PolygonConstPtr
int boost_polygon_enclosure_grid(T &grid, std::vector< BoostPolygon *> polygons, AABB &aabb, const BoostPolygon *obj_poly, bool &res)
bool within(const BoostPolygon &other) const
Returns true if the BoostPolygon is completely contained within another BoostPolygon object...
virtual std::shared_ptr< const collision::RectangleAABB > getAABB() const
virtual bool collide(const CollisionObject &c, const collision::CollisionRequest &req=CollisionRequest()) const
int boost_ccd_obb_sum_polygon_enclosure(const ShapeGroup &sg, const RectangleOBB &pos1, const RectangleOBB &pos2, bool &res)
bg_polygon_type * getInternal(void) const
Returns the contained boost.Geometry polygon object.
int boost_get_candidate_polygons_no_merge(const ShapeGroup &sg, const Shape &shape, std::vector< bg_polygon_type > &mpoly)
Base prototype for the shape of an obstacle.
int boost_poly_poly_convex_hull(const Polygon &pos1, const Polygon &pos2, collision::PolygonConstPtr &resPoly)
Creates a collision Polygon of two RectangleOBB objects. The convex hull of the boolean union of the ...
int boost_obb_obb_convex_hull(const RectangleOBB &pos1, const RectangleOBB &pos2, collision::PolygonConstPtr &resPoly)
Polygon contains Triangles and Vertices.
bool boost_within(const BoostPolygon &polyg1, const BoostPolygon &polyg2)
Returns true if the BoostPolygon polyg1 is completely contained within the other BoostPolygon object ...
BoostPolygon allows to use boost.Geometry functions for Polygon objects.
#define TIMER_polygon_enclosure