mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Updates in the C++ infill code.
This commit is contained in:
parent
b2a6f43923
commit
a5b7f14dfa
14 changed files with 645 additions and 305 deletions
|
@ -6,17 +6,21 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
Polylines FillConcentric::fill_surface(const Surface *surface, const FillParams ¶ms)
|
||||
void FillConcentric::_fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon &expolygon,
|
||||
Polylines &polylines_out)
|
||||
{
|
||||
// no rotation is supported for this infill pattern
|
||||
ExPolygon expolygon = surface->expolygon;
|
||||
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) {
|
||||
distance = this->adjust_solid_spacing(bounding_box.size().x, distance);
|
||||
distance = this->_adjust_solid_spacing(bounding_box.size().x, distance);
|
||||
this->spacing = unscale(distance);
|
||||
}
|
||||
|
||||
|
@ -32,29 +36,27 @@ Polylines FillConcentric::fill_surface(const Surface *surface, const FillParams
|
|||
union_pt_chained(loops, &loops, false);
|
||||
|
||||
// split paths using a nearest neighbor search
|
||||
Polylines paths;
|
||||
size_t iPathFirst = polylines_out.size();
|
||||
Point last_pos(0, 0);
|
||||
for (Polygons::const_iterator it_loop = loops.begin(); it_loop != loops.end(); ++ it_loop) {
|
||||
paths.push_back(it_loop->split_at_index(last_pos.nearest_point_index(*it_loop)));
|
||||
last_pos = paths.back().last_point();
|
||||
polylines_out.push_back(it_loop->split_at_index(last_pos.nearest_point_index(*it_loop)));
|
||||
last_pos = polylines_out.back().last_point();
|
||||
}
|
||||
|
||||
// clip the paths to prevent the extruder from getting exactly on the first point of the loop
|
||||
// Keep valid paths only.
|
||||
size_t j = 0;
|
||||
for (size_t i = 0; i < paths.size(); ++ i) {
|
||||
paths[i].clip_end(this->loop_clipping);
|
||||
if (paths[i].is_valid()) {
|
||||
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()) {
|
||||
if (j < i)
|
||||
std::swap(paths[j], paths[i]);
|
||||
std::swap(polylines_out[j], polylines_out[i]);
|
||||
++ j;
|
||||
}
|
||||
}
|
||||
if (j < paths.size())
|
||||
paths.erase(paths.begin() + j, paths.end());
|
||||
|
||||
if (j < polylines_out.size())
|
||||
polylines_out.erase(polylines_out.begin() + j, polylines_out.end());
|
||||
// TODO: return ExtrusionLoop objects to get better chained paths
|
||||
return paths;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue