Reworked the algorithm for avoid crossing perimeters for multiple objects

This commit is contained in:
Lukáš Hejl 2020-10-16 01:57:26 +02:00
parent 69658a57d8
commit c16aad7e0b
4 changed files with 167 additions and 35 deletions

View file

@ -140,6 +140,17 @@ bool MultiPoint::first_intersection(const Line& line, Point* intersection) const
return found;
}
bool MultiPoint::intersections(const Line &line, Points *intersections) const
{
size_t intersections_size = intersections->size();
for (const Line &polygon_line : this->lines()) {
Point intersection;
if (polygon_line.intersection(line, &intersection))
intersections->emplace_back(std::move(intersection));
}
return intersections->size() > intersections_size;
}
std::vector<Point> MultiPoint::_douglas_peucker(const std::vector<Point>& pts, const double tolerance)
{
std::vector<Point> result_pts;