Refactored FillEsuring to support switching between BoundedRectilinear and Concentric infill for the ensure vertical shell thickness.
This commit is contained in:
parent
1268856f6a
commit
df01923631
1 changed files with 84 additions and 74 deletions
|
@ -10,41 +10,46 @@ namespace Slic3r {
|
||||||
|
|
||||||
ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const FillParams ¶ms)
|
ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const FillParams ¶ms)
|
||||||
{
|
{
|
||||||
|
assert(params.use_arachne);
|
||||||
|
assert(this->print_config != nullptr && this->print_object_config != nullptr && this->print_region_config != nullptr);
|
||||||
|
|
||||||
|
const coord_t scaled_spacing = scaled<coord_t>(this->spacing);
|
||||||
|
const bool is_bounded_rectilinear = true;
|
||||||
|
|
||||||
// Perform offset.
|
// Perform offset.
|
||||||
Slic3r::ExPolygons expp = this->overlap != 0. ? offset_ex(surface->expolygon, scaled<float>(this->overlap)) : ExPolygons{surface->expolygon};
|
Slic3r::ExPolygons expp = this->overlap != 0. ? offset_ex(surface->expolygon, scaled<float>(this->overlap)) : ExPolygons{surface->expolygon};
|
||||||
// Create the infills for each of the regions.
|
// Create the infills for each of the regions.
|
||||||
ThickPolylines thick_polylines_out;
|
ThickPolylines thick_polylines_out;
|
||||||
for (ExPolygon &ex_poly : expp)
|
for (ExPolygon &ex_poly : expp) {
|
||||||
fill_surface_single_arachne(Surface(*surface, std::move(ex_poly)), params, thick_polylines_out);
|
Point bbox_size = ex_poly.contour.bounding_box().size();
|
||||||
|
coord_t loops_count = is_bounded_rectilinear ? 1 : std::max(bbox_size.x(), bbox_size.y()) / scaled_spacing + 1;
|
||||||
return thick_polylines_out;
|
Polygons polygons = to_polygons(ex_poly);
|
||||||
|
Arachne::WallToolPaths wall_tool_paths(polygons, scaled_spacing, scaled_spacing, loops_count, 0, params.layer_height, *this->print_object_config, *this->print_config);
|
||||||
|
if (std::vector<Arachne::VariableWidthLines> loops = wall_tool_paths.getToolPaths(); !loops.empty()) {
|
||||||
|
assert(!is_bounded_rectilinear || loops.size() == 1);
|
||||||
|
std::vector<const Arachne::ExtrusionLine *> all_extrusions;
|
||||||
|
for (Arachne::VariableWidthLines &loop : loops) {
|
||||||
|
if (loop.empty())
|
||||||
|
continue;
|
||||||
|
for (const Arachne::ExtrusionLine &wall : loop)
|
||||||
|
all_extrusions.emplace_back(&wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillEnsuring::fill_surface_single_arachne(const Surface &surface, const FillParams ¶ms, ThickPolylines &thick_polylines_out)
|
// Split paths using a nearest neighbor search.
|
||||||
{
|
|
||||||
assert(params.use_arachne);
|
|
||||||
assert(this->print_config != nullptr && this->print_object_config != nullptr && this->print_region_config != nullptr);
|
|
||||||
|
|
||||||
coord_t scaled_spacing = scaled<coord_t>(this->spacing);
|
|
||||||
Polygons polygons = to_polygons(surface.expolygon);
|
|
||||||
Arachne::WallToolPaths wall_tool_paths(polygons, scaled_spacing, scaled_spacing, 1, 0, params.layer_height, *this->print_object_config, *this->print_config);
|
|
||||||
if (std::vector<Arachne::VariableWidthLines> loop = wall_tool_paths.getToolPaths(); !loop.empty()) {
|
|
||||||
assert(loop.size() == 1);
|
|
||||||
|
|
||||||
size_t firts_poly_idx = thick_polylines_out.size();
|
size_t firts_poly_idx = thick_polylines_out.size();
|
||||||
Point last_pos(0, 0);
|
Point last_pos(0, 0);
|
||||||
for (const Arachne::ExtrusionLine &extrusion : loop.front()) {
|
for (const Arachne::ExtrusionLine *extrusion : all_extrusions) {
|
||||||
if (extrusion.empty())
|
if (extrusion->empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ThickPolyline thick_polyline = Arachne::to_thick_polyline(extrusion);
|
ThickPolyline thick_polyline = Arachne::to_thick_polyline(*extrusion);
|
||||||
if (thick_polyline.length() == 0.)
|
if (thick_polyline.length() == 0.)
|
||||||
//FIXME this should not happen.
|
//FIXME this should not happen.
|
||||||
continue;
|
continue;
|
||||||
assert(thick_polyline.size() > 1);
|
assert(thick_polyline.size() > 1);
|
||||||
assert(thick_polyline.length() > 0.);
|
assert(thick_polyline.length() > 0.);
|
||||||
//assert(thick_polyline.points.size() == thick_polyline.width.size());
|
//assert(thick_polyline.points.size() == thick_polyline.width.size());
|
||||||
if (extrusion.is_closed)
|
if (extrusion->is_closed)
|
||||||
thick_polyline.start_at_index(nearest_point_index(thick_polyline.points, last_pos));
|
thick_polyline.start_at_index(nearest_point_index(thick_polyline.points, last_pos));
|
||||||
|
|
||||||
assert(thick_polyline.size() > 1);
|
assert(thick_polyline.size() > 1);
|
||||||
|
@ -72,6 +77,7 @@ void FillEnsuring::fill_surface_single_arachne(const Surface &surface, const Fil
|
||||||
thick_polylines_out.erase(thick_polylines_out.begin() + int(j), thick_polylines_out.end());
|
thick_polylines_out.erase(thick_polylines_out.begin() + int(j), thick_polylines_out.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_bounded_rectilinear) {
|
||||||
// Remaining infill area will be filled with classic Rectilinear infill.
|
// Remaining infill area will be filled with classic Rectilinear infill.
|
||||||
ExPolygons infill_contour = union_ex(wall_tool_paths.getInnerContour());
|
ExPolygons infill_contour = union_ex(wall_tool_paths.getInnerContour());
|
||||||
if (offset_ex(infill_contour, -float(scaled_spacing / 2.)).empty())
|
if (offset_ex(infill_contour, -float(scaled_spacing / 2.)).empty())
|
||||||
|
@ -86,10 +92,14 @@ void FillEnsuring::fill_surface_single_arachne(const Surface &surface, const Fil
|
||||||
const auto infill_overlap = coord_t(scale_(this->print_region_config->get_abs_value("infill_overlap", this->spacing)));
|
const auto infill_overlap = coord_t(scale_(this->print_region_config->get_abs_value("infill_overlap", this->spacing)));
|
||||||
for (ExPolygon &ex_poly : offset2_ex(union_ex(pp), float(-min_perimeter_infill_spacing / 2.), float(infill_overlap + min_perimeter_infill_spacing / 2.))) {
|
for (ExPolygon &ex_poly : offset2_ex(union_ex(pp), float(-min_perimeter_infill_spacing / 2.), float(infill_overlap + min_perimeter_infill_spacing / 2.))) {
|
||||||
Polylines polylines;
|
Polylines polylines;
|
||||||
if (Surface new_surface(surface, std::move(ex_poly)); !fill_surface_by_lines(&new_surface, params, 0.f, 0.f, polylines))
|
if (Surface new_surface(*surface, std::move(ex_poly)); !fill_surface_by_lines(&new_surface, params, 0.f, 0.f, polylines))
|
||||||
BOOST_LOG_TRIVIAL(error) << "FillEnsuring::fill_surface() failed to fill a region.";
|
BOOST_LOG_TRIVIAL(error) << "FillBoundedRectilinear::fill_surface() failed to fill a region.";
|
||||||
append(thick_polylines_out, to_thick_polylines(std::move(polylines), scaled<coord_t>(this->spacing)));
|
append(thick_polylines_out, to_thick_polylines(std::move(polylines), scaled<coord_t>(this->spacing)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thick_polylines_out;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue