Infill Line Multiplier (#9432)

* Infill Line Multiplier

* Modular Offset Function

* Lightning multiline

* Crosshatch Multiline

ipCrosshatch

* cleaning

Cleaning

clean2

* 3d Honeycomb

cut poliline ends

* Fill Tpmsd Multiline

Fill Tpmsd Multiline

* Update Multiline function

multiline funcion simplify

* Update FillTpmsD

* FillHoneycomb

* Update src/libslic3r/PrintConfig.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix Honeycomb Multiline

Simplify polylines in honeycomb infill generation

* Improve multiline infill support and pattern simplification

Moved multiline infill application after pattern translation and simplification in Fill3DHoneycomb, and added multiline support to FillAdaptive. Updated honeycomb and 3D honeycomb infill to simplify polylines to 5x line width. Extended GUI and config to support multiline for Adaptive Cubic infill pattern and clarified max value comment.

minimum changes

Co-Authored-By: Ian Bassi <12130714+ianalexis@users.noreply.github.com>

* Increase multiline fill spacing in honeycomb infill

Adjusts the spacing parameter in the multiline_fill function to 1.1 times the original spacing, potentially improving infill distribution or print quality.

* Refine fill_multiline tooltip and pattern support logic

Updated the tooltip for the 'fill_multiline' parameter to improve clarity and punctuation. Refactored the logic in ConfigManipulation.cpp to clarify which infill patterns support multiline infill.

* better management of non supported infill patterns

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
Co-authored-by: Ian Bassi <12130714+ianalexis@users.noreply.github.com>
This commit is contained in:
Rodrigo
2025-06-30 12:07:33 -03:00
committed by GitHub
parent 10687085ee
commit a8141ef360
17 changed files with 164 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <numeric>
#include <cmath>
#include "../ClipperUtils.hpp"
#include "../EdgeGrid.hpp"
#include "../Geometry.hpp"
@@ -25,7 +26,6 @@
// BBS: new infill pattern header
#include "FillConcentricInternal.hpp"
#include "FillCrossHatch.hpp"
// #define INFILL_DEBUG_OUTPUT
namespace Slic3r {
@@ -190,22 +190,22 @@ void Fill::fill_surface_extrusion(const Surface* surface, const FillParams& para
// Orca: Dedicated function to calculate gap fill lines for the provided surface, according to the print object parameters
// and append them to the out ExtrusionEntityCollection.
void Fill::_create_gap_fill(const Surface* surface, const FillParams& params, ExtrusionEntityCollection* out){
//Orca: just to be safe, check against null pointer for the print object config and if NULL return.
if (this->print_object_config == nullptr) return;
// Orca: Enable gap fill as per the user preference. Return early if gap fill is to not be applied.
if ((this->print_object_config->gap_fill_target.value == gftNowhere) ||
(surface->surface_type == stInternalSolid && this->print_object_config->gap_fill_target.value != gftEverywhere))
return;
Flow new_flow = params.flow;
ExPolygons unextruded_areas;
unextruded_areas = diff_ex(this->no_overlap_expolygons, union_ex(out->polygons_covered_by_spacing(10)));
ExPolygons gapfill_areas = union_ex(unextruded_areas);
if (!this->no_overlap_expolygons.empty())
gapfill_areas = intersection_ex(gapfill_areas, this->no_overlap_expolygons);
if (gapfill_areas.size() > 0 && params.density >= 1) {
double min = 0.2 * new_flow.scaled_spacing() * (1 - INSET_OVERLAP_TOLERANCE);
double max = 2. * new_flow.scaled_spacing();
@@ -222,20 +222,20 @@ void Fill::_create_gap_fill(const Surface* surface, const FillParams& params, Ex
std::vector<Points::size_type> order2 = chain_points(ordering_points);
for (size_t i : order2)
gaps_ex_sorted.emplace_back(std::move(gaps_ex[i]));
ThickPolylines polylines;
for (ExPolygon& ex : gaps_ex_sorted) {
//BBS: Use DP simplify to avoid duplicated points and accelerate medial-axis calculation as well.
ex.douglas_peucker(SCALED_RESOLUTION * 0.1);
ex.medial_axis(min, max, &polylines);
}
if (!polylines.empty() && !is_bridge(params.extrusion_role)) {
polylines.erase(std::remove_if(polylines.begin(), polylines.end(),
[&](const ThickPolyline& p) {
return p.length() < scale_(params.config->filter_out_gap_fill.value);
}), polylines.end());
ExtrusionEntityCollection gap_fill;
variable_width(polylines, erGapFill, params.flow, gap_fill.entities);
auto gap = std::move(gap_fill.entities);
@@ -2696,4 +2696,55 @@ void Fill::connect_base_support(Polylines &&infill_ordered, const Polygons &boun
connect_base_support(std::move(infill_ordered), polygons_src, bbox, polylines_out, spacing, params);
}
//Fill Multiline
void multiline_fill(Polylines& polylines, const FillParams& params, float spacing)
{
if (params.multiline > 1) {
const int n_lines = params.multiline;
const int n_polylines = static_cast<int>(polylines.size());
Polylines all_polylines;
all_polylines.reserve(n_lines * n_polylines);
const float center = (n_lines - 1) / 2.0f;
for (int line = 0; line < n_lines; ++line) {
float offset = (static_cast<float>(line) - center) * spacing;
for (const Polyline& pl : polylines) {
const size_t n = pl.points.size();
if (n < 2) {
all_polylines.emplace_back(pl);
continue;
}
Points new_points;
new_points.reserve(n);
for (size_t i = 0; i < n; ++i) {
Vec2f tangent;
if (i == 0)
tangent = Vec2f(pl.points[1].x() - pl.points[0].x(), pl.points[1].y() - pl.points[0].y());
else if (i == n - 1)
tangent = Vec2f(pl.points[n - 1].x() - pl.points[n - 2].x(), pl.points[n - 1].y() - pl.points[n - 2].y());
else
tangent = Vec2f(pl.points[i + 1].x() - pl.points[i - 1].x(), pl.points[i + 1].y() - pl.points[i - 1].y());
float len = std::hypot(tangent.x(), tangent.y());
if (len == 0)
len = 1.0f;
tangent /= len;
Vec2f normal(-tangent.y(), tangent.x());
Point p = pl.points[i];
p.x() += scale_(normal.x() * offset);
p.y() += scale_(normal.y() * offset);
new_points.push_back(p);
}
all_polylines.emplace_back(std::move(new_points));
}
}
polylines = std::move(all_polylines);
}
}
} // namespace Slic3r