Added various has_duplicate_points() checks, to be used by asserts.

Removed some "extern" function modifiers, they have no meaning in C++.
This commit is contained in:
Vojtech Bubnik 2021-09-24 14:07:46 +02:00
parent 7eea15fdde
commit fec5d92bc8
7 changed files with 183 additions and 27 deletions

View file

@ -179,6 +179,15 @@ Point Point::projection_onto(const Line &line) const
return ((line.a - *this).cast<double>().squaredNorm() < (line.b - *this).cast<double>().squaredNorm()) ? line.a : line.b;
}
bool has_duplicate_points(std::vector<Point> &&pts)
{
std::sort(pts.begin(), pts.end());
for (size_t i = 1; i < pts.size(); ++ i)
if (pts[i - 1] == pts[i])
return true;
return false;
}
BoundingBox get_extents(const Points &pts)
{
return BoundingBox(pts);