move erase operation out of scope
This commit is contained in:
parent
4e56f75541
commit
db290d8e8d
1 changed files with 11 additions and 7 deletions
|
@ -117,7 +117,8 @@ 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;
|
std::optional<Point> add;
|
||||||
Points &pts = polygon.points;
|
bool do_erase = false;
|
||||||
|
Points &pts = polygon.points;
|
||||||
{
|
{
|
||||||
size_t pts_size = pts.size();
|
size_t pts_size = pts.size();
|
||||||
if (pts_size < 3)
|
if (pts_size < 3)
|
||||||
|
@ -169,8 +170,7 @@ bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &sp
|
||||||
|
|
||||||
if (is_ba_short && is_bc_short) {
|
if (is_ba_short && is_bc_short) {
|
||||||
// remove short spike
|
// remove short spike
|
||||||
pts.erase(pts.begin() + index);
|
do_erase = true;
|
||||||
return true;
|
|
||||||
} else if (is_ba_short) {
|
} else if (is_ba_short) {
|
||||||
// move point B on C-side
|
// move point B on C-side
|
||||||
pts[index] = c_side();
|
pts[index] = c_side();
|
||||||
|
@ -181,14 +181,18 @@ bool priv::remove_when_spike(Polygon &polygon, size_t index, const SpikeDesc &sp
|
||||||
// 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();
|
||||||
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);
|
add.reset();
|
||||||
return true;
|
do_erase = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (do_erase) {
|
||||||
|
pts.erase(pts.begin() + index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (add.has_value())
|
if (add.has_value())
|
||||||
pts.insert(pts.begin() + index, *add);
|
pts.insert(pts.begin() + index, *add);
|
||||||
return false;
|
return false;
|
||||||
|
@ -554,9 +558,9 @@ ExPolygons Emboss::heal_shape(const Polygons &shape)
|
||||||
|
|
||||||
#include "libslic3r/SVG.hpp"
|
#include "libslic3r/SVG.hpp"
|
||||||
void priv::visualize_heal(const std::string &svg_filepath, const ExPolygons &expolygons) {
|
void priv::visualize_heal(const std::string &svg_filepath, const ExPolygons &expolygons) {
|
||||||
double svg_scale = SHAPE_SCALE / unscale<double>(1.);
|
|
||||||
Points pts = to_points(expolygons);
|
Points pts = to_points(expolygons);
|
||||||
BoundingBox bb(pts);
|
BoundingBox bb(pts);
|
||||||
|
//double svg_scale = SHAPE_SCALE / unscale<double>(1.);
|
||||||
// bb.scale(svg_scale);
|
// bb.scale(svg_scale);
|
||||||
SVG svg(svg_filepath, bb);
|
SVG svg(svg_filepath, bb);
|
||||||
svg.draw(expolygons);
|
svg.draw(expolygons);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue