mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-29 09:33:57 -06:00
[Feature] Enabled gap fill algorithm for all solid fill types (#3412)
* ENH: Enabled gap fill algorithm for all solid fill types * Made gap fill an option & refactored code into its own method * Code comment updates * Converted gap fill to enum and control filter out gap fill in the UI * Update label for consistency * Spelling mistake
This commit is contained in:
parent
c0c05c715b
commit
fe148515ce
9 changed files with 143 additions and 7 deletions
|
@ -67,7 +67,8 @@ Fill* Fill::new_from_type(const InfillPattern type)
|
|||
// BBS: for internal solid infill only
|
||||
case ipConcentricInternal: return new FillConcentricInternal();
|
||||
// BBS: for bottom and top surface only
|
||||
case ipMonotonicLine: return new FillMonotonicLineWGapFill();
|
||||
// Orca: Replace BBS implementation with Prusa implementation
|
||||
case ipMonotonicLine: return new FillMonotonicLines();
|
||||
default: throw Slic3r::InvalidArgument("unknown type");
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +174,66 @@ void Fill::fill_surface_extrusion(const Surface* surface, const FillParams& para
|
|||
for (size_t i = idx; i < eec->entities.size(); i++)
|
||||
eec->entities[i]->set_reverse();
|
||||
}
|
||||
|
||||
// Orca: run gap fill
|
||||
this->_create_gap_fill(surface, params, eec);
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
ExPolygons gaps_ex = diff_ex(
|
||||
opening_ex(gapfill_areas, float(min / 2.)),
|
||||
offset2_ex(gapfill_areas, -float(max / 2.), float(max / 2. + ClipperSafetyOffset)));
|
||||
//BBS: sort the gap_ex to avoid mess travel
|
||||
Points ordering_points;
|
||||
ordering_points.reserve(gaps_ex.size());
|
||||
ExPolygons gaps_ex_sorted;
|
||||
gaps_ex_sorted.reserve(gaps_ex.size());
|
||||
for (const ExPolygon &ex : gaps_ex)
|
||||
ordering_points.push_back(ex.contour.first_point());
|
||||
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);
|
||||
out->append(gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue