add FillConcentricinternal update solidinfill

This commit is contained in:
Wang YB
2024-04-27 16:09:27 +08:00
parent 9c52fb3733
commit 04ad174e91
10 changed files with 604 additions and 114 deletions

View File

@@ -81,6 +81,52 @@ Points collect_duplicates(Points pts /* Copy */)
}
return duplicits;
}
//w29
int Point::nearest_point_index(const Points &points) const
{
PointConstPtrs p;
p.reserve(points.size());
for (Points::const_iterator it = points.begin(); it != points.end(); ++it)
p.push_back(&*it);
return this->nearest_point_index(p);
}
int Point::nearest_point_index(const PointConstPtrs &points) const
{
int idx = -1;
double distance = -1; // double because long is limited to 2147483647 on some platforms and it's not enough
for (PointConstPtrs::const_iterator it = points.begin(); it != points.end(); ++it) {
/* If the X distance of the candidate is > than the total distance of the
best previous candidate, we know we don't want it */
double d = sqr<double>((*this) (0) - (*it)->x());
if (distance != -1 && d > distance)
continue;
/* If the Y distance of the candidate is > than the total distance of the
best previous candidate, we know we don't want it */
d += sqr<double>((*this) (1) - (*it)->y());
if (distance != -1 && d > distance)
continue;
idx = it - points.begin();
distance = d;
if (distance < EPSILON)
break;
}
return idx;
}
int Point::nearest_point_index(const PointPtrs &points) const
{
PointConstPtrs p;
p.reserve(points.size());
for (PointPtrs::const_iterator it = points.begin(); it != points.end(); ++it)
p.push_back(*it);
return this->nearest_point_index(p);
}
template<bool IncludeBoundary>
BoundingBox get_extents(const Points &pts)