Filter gap fill using length relative to the actual width. #2781
This commit is contained in:
parent
fd4f5e40ca
commit
36d5272f05
1 changed files with 11 additions and 3 deletions
|
@ -195,6 +195,15 @@ ExPolygon::medial_axis(double max_width, double min_width, ThickPolylines* polyl
|
||||||
svg.Close();
|
svg.Close();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// find the maximum width returned
|
||||||
|
double max_w = 0;
|
||||||
|
if (!pp.empty()) {
|
||||||
|
std::vector<double> widths;
|
||||||
|
for (ThickPolylines::const_iterator it = pp.begin(); it != pp.end(); ++it)
|
||||||
|
widths.insert(widths.end(), it->width.begin(), it->width.end());
|
||||||
|
max_w = *std::max_element(widths.begin(), widths.end());
|
||||||
|
}
|
||||||
|
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (size_t i = 0; i < pp.size(); ++i) {
|
for (size_t i = 0; i < pp.size(); ++i) {
|
||||||
ThickPolyline& polyline = pp[i];
|
ThickPolyline& polyline = pp[i];
|
||||||
|
@ -232,10 +241,9 @@ ExPolygon::medial_axis(double max_width, double min_width, ThickPolylines* polyl
|
||||||
/* remove too short polylines
|
/* remove too short polylines
|
||||||
(we can't do this check before endpoints extension and clipping because we don't
|
(we can't do this check before endpoints extension and clipping because we don't
|
||||||
know how long will the endpoints be extended since it depends on polygon thickness
|
know how long will the endpoints be extended since it depends on polygon thickness
|
||||||
which is variable - extension will be <= max_width/2 on each side)
|
which is variable - extension will be <= max_width/2 on each side) */
|
||||||
Maybe instead of using max_width we should use max_element(polyline.width) */
|
|
||||||
if ((polyline.endpoints.first || polyline.endpoints.second)
|
if ((polyline.endpoints.first || polyline.endpoints.second)
|
||||||
&& polyline.length() < max_width*2) {
|
&& polyline.length() < max_w*2) {
|
||||||
pp.erase(pp.begin() + i);
|
pp.erase(pp.begin() + i);
|
||||||
--i;
|
--i;
|
||||||
removed = true;
|
removed = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue