2016-04-11 15:08:30 +00:00
|
|
|
#include "../ClipperUtils.hpp"
|
|
|
|
#include "../ExPolygon.hpp"
|
|
|
|
#include "../Surface.hpp"
|
|
|
|
|
|
|
|
#include "FillConcentric.hpp"
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2016-09-13 09:26:38 +00:00
|
|
|
void FillConcentric::_fill_surface_single(
|
|
|
|
const FillParams ¶ms,
|
|
|
|
unsigned int thickness_layers,
|
|
|
|
const std::pair<float, Point> &direction,
|
|
|
|
ExPolygon &expolygon,
|
|
|
|
Polylines &polylines_out)
|
2016-04-11 15:08:30 +00:00
|
|
|
{
|
|
|
|
// no rotation is supported for this infill pattern
|
|
|
|
BoundingBox bounding_box = expolygon.contour.bounding_box();
|
|
|
|
|
|
|
|
coord_t min_spacing = scale_(this->spacing);
|
|
|
|
coord_t distance = coord_t(min_spacing / params.density);
|
|
|
|
|
|
|
|
if (params.density > 0.9999f && !params.dont_adjust) {
|
2018-08-17 13:53:43 +00:00
|
|
|
distance = this->_adjust_solid_spacing(bounding_box.size()(0), distance);
|
2018-08-21 15:43:05 +00:00
|
|
|
this->spacing = unscale<double>(distance);
|
2016-04-11 15:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Polygons loops = (Polygons)expolygon;
|
|
|
|
Polygons last = loops;
|
|
|
|
while (! last.empty()) {
|
|
|
|
last = offset2(last, -(distance + min_spacing/2), +min_spacing/2);
|
|
|
|
loops.insert(loops.end(), last.begin(), last.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate paths from the outermost to the innermost, to avoid
|
|
|
|
// adhesion problems of the first central tiny loops
|
2016-12-13 18:22:23 +00:00
|
|
|
loops = union_pt_chained(loops, false);
|
2016-04-11 15:08:30 +00:00
|
|
|
|
|
|
|
// split paths using a nearest neighbor search
|
2016-09-13 09:26:38 +00:00
|
|
|
size_t iPathFirst = polylines_out.size();
|
2016-04-11 15:08:30 +00:00
|
|
|
Point last_pos(0, 0);
|
2017-07-27 08:39:43 +00:00
|
|
|
for (const Polygon &loop : loops) {
|
|
|
|
polylines_out.push_back(loop.split_at_index(last_pos.nearest_point_index(loop)));
|
2016-09-13 09:26:38 +00:00
|
|
|
last_pos = polylines_out.back().last_point();
|
2016-04-11 15:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// clip the paths to prevent the extruder from getting exactly on the first point of the loop
|
|
|
|
// Keep valid paths only.
|
2016-09-13 09:26:38 +00:00
|
|
|
size_t j = iPathFirst;
|
|
|
|
for (size_t i = iPathFirst; i < polylines_out.size(); ++ i) {
|
|
|
|
polylines_out[i].clip_end(this->loop_clipping);
|
|
|
|
if (polylines_out[i].is_valid()) {
|
2016-04-11 15:08:30 +00:00
|
|
|
if (j < i)
|
2017-07-27 08:39:43 +00:00
|
|
|
polylines_out[j] = std::move(polylines_out[i]);
|
2016-04-11 15:08:30 +00:00
|
|
|
++ j;
|
|
|
|
}
|
|
|
|
}
|
2016-09-13 09:26:38 +00:00
|
|
|
if (j < polylines_out.size())
|
|
|
|
polylines_out.erase(polylines_out.begin() + j, polylines_out.end());
|
2017-07-27 08:39:43 +00:00
|
|
|
//TODO: return ExtrusionLoop objects to get better chained paths,
|
|
|
|
// otherwise the outermost loop starts at the closest point to (0, 0).
|
|
|
|
// We want the loops to be split inside the G-code generator to get optimum path planning.
|
2016-04-11 15:08:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Slic3r
|