Move insert call out of variable scope
This commit is contained in:
parent
8cb414c262
commit
4e56f75541
1 changed files with 63 additions and 58 deletions
|
@ -115,12 +115,15 @@ void remove_spikes(ExPolygons &expolygons, const SpikeDesc &spike_desc);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &spike_desc) {
|
bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &spike_desc) {
|
||||||
|
|
||||||
|
std::optional<Point> add;
|
||||||
Points &pts = polygon.points;
|
Points &pts = polygon.points;
|
||||||
|
{
|
||||||
size_t pts_size = pts.size();
|
size_t pts_size = pts.size();
|
||||||
if (pts_size < 3)
|
if (pts_size < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Point &a = (index == 0) ? pts.back() : pts[index-1];
|
const Point &a = (index == 0) ? pts.back() : pts[index - 1];
|
||||||
const Point &b = pts[index];
|
const Point &b = pts[index];
|
||||||
const Point &c = (index == (pts_size - 1)) ? pts.front() : pts[index + 1];
|
const Point &c = (index == (pts_size - 1)) ? pts.front() : pts[index + 1];
|
||||||
|
|
||||||
|
@ -144,7 +147,7 @@ bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &sp
|
||||||
// Due to preccission of floating point number could be sligtly out of range
|
// Due to preccission of floating point number could be sligtly out of range
|
||||||
if (cos_angle > 1.)
|
if (cos_angle > 1.)
|
||||||
cos_angle = 1.;
|
cos_angle = 1.;
|
||||||
//if (cos_angle < -1.)
|
// if (cos_angle < -1.)
|
||||||
// cos_angle = -1.;
|
// cos_angle = -1.;
|
||||||
|
|
||||||
// Current Spike angle
|
// Current Spike angle
|
||||||
|
@ -177,15 +180,17 @@ bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &sp
|
||||||
} else {
|
} else {
|
||||||
// move point B on C-side and add point on A-side(left - before)
|
// move point B on C-side and add point on A-side(left - before)
|
||||||
pts[index] = c_side();
|
pts[index] = c_side();
|
||||||
Point add = a_side();
|
add = a_side();
|
||||||
if (add == pts[index]) {
|
if (add == pts[index]) {
|
||||||
// should be very rare, when SpikeDesc has small base
|
// should be very rare, when SpikeDesc has small base
|
||||||
// will be fixed by remove B point
|
// will be fixed by remove B point
|
||||||
pts.erase(pts.begin() + index);
|
pts.erase(pts.begin() + index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pts.insert(pts.begin() + index, add);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (add.has_value())
|
||||||
|
pts.insert(pts.begin() + index, *add);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue