mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 17:21:11 -06:00
fix centroid error for two points and merge with dev.
This commit is contained in:
commit
1c4574d42e
39 changed files with 849 additions and 132 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue