mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-27 09:19:11 -07:00
fix centroid error for two points and merge with dev.
This commit is contained in:
@@ -357,10 +357,20 @@ inline ExPolygons unify(const ExPolygons& shapes) {
|
||||
}
|
||||
|
||||
inline Point centroid(Points& pp) {
|
||||
Polygon p;
|
||||
p.points.swap(pp);
|
||||
Point c = p.centroid();
|
||||
pp.swap(p.points);
|
||||
Point c;
|
||||
switch(pp.size()) {
|
||||
case 0: break;
|
||||
case 1: c = pp.front(); break;
|
||||
case 2: c = (pp[0] + pp[1]) / 2; break;
|
||||
default: {
|
||||
Polygon p;
|
||||
p.points.swap(pp);
|
||||
c = p.centroid();
|
||||
pp.swap(p.points);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user