mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-11 21:08:59 +08:00
optimisation/fix for FillRectilinear2Peri
This commit is contained in:
parent
389d3ee4d5
commit
76b6f9a12b
@ -1474,8 +1474,6 @@ Polylines FillCubic::fill_surface(const Surface *surface, const FillParams ¶
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Polylines FillRectilinear2Peri::fill_surface(const Surface *surface, const FillParams ¶ms) {
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FillRectilinear2Peri::fill_surface_extrusion(const Surface *surface, const FillParams ¶ms,
|
FillRectilinear2Peri::fill_surface_extrusion(const Surface *surface, const FillParams ¶ms,
|
||||||
const Flow &flow, const ExtrusionRole &role, ExtrusionEntitiesPtr &out)
|
const Flow &flow, const ExtrusionRole &role, ExtrusionEntitiesPtr &out)
|
||||||
@ -1484,10 +1482,10 @@ FillRectilinear2Peri::fill_surface_extrusion(const Surface *surface, const FillP
|
|||||||
//you don't want to sort the extrusions: big infill first, small second
|
//you don't want to sort the extrusions: big infill first, small second
|
||||||
eecroot->no_sort = true;
|
eecroot->no_sort = true;
|
||||||
|
|
||||||
|
// === extrude perimeter ===
|
||||||
Polylines polylines_1;
|
Polylines polylines_1;
|
||||||
//generate perimeter:
|
//generate perimeter:
|
||||||
//TODO: better optimize start/end point?
|
ExPolygons path_perimeter = offset2_ex(surface->expolygon, scale_(-this->spacing), scale_(this->spacing / 2));
|
||||||
ExPolygons path_perimeter = offset_ex(surface->expolygon, scale_(-this->spacing/2));
|
|
||||||
for (ExPolygon &expolygon : path_perimeter) {
|
for (ExPolygon &expolygon : path_perimeter) {
|
||||||
expolygon.contour.make_counter_clockwise();
|
expolygon.contour.make_counter_clockwise();
|
||||||
polylines_1.push_back(expolygon.contour.split_at_index(0));
|
polylines_1.push_back(expolygon.contour.split_at_index(0));
|
||||||
@ -1497,53 +1495,78 @@ FillRectilinear2Peri::fill_surface_extrusion(const Surface *surface, const FillP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save into layer.
|
if (!polylines_1.empty()) {
|
||||||
auto *eec = new ExtrusionEntityCollection();
|
// Save into layer.
|
||||||
/// pass the no_sort attribute to the extrusion path
|
ExtrusionEntityCollection *eec = new ExtrusionEntityCollection();
|
||||||
eec->no_sort = this->no_sort();
|
/// pass the no_sort attribute to the extrusion path
|
||||||
/// add it into the collection
|
eec->no_sort = this->no_sort();
|
||||||
eecroot->entities.push_back(eec);
|
/// add it into the collection
|
||||||
//get the role
|
eecroot->entities.push_back(eec);
|
||||||
ExtrusionRole good_role = role;
|
//get the role
|
||||||
if (good_role == erNone || good_role == erCustom) {
|
ExtrusionRole good_role = role;
|
||||||
good_role = flow.bridge ?
|
if (good_role == erNone || good_role == erCustom) {
|
||||||
erBridgeInfill :
|
good_role = flow.bridge ?
|
||||||
(surface->is_solid() ?
|
erBridgeInfill :
|
||||||
((surface->is_top()) ? erTopSolidInfill : erSolidInfill) :
|
(surface->is_solid() ?
|
||||||
erInternalInfill);
|
((surface->is_top()) ? erTopSolidInfill : erSolidInfill) :
|
||||||
|
erInternalInfill);
|
||||||
|
}
|
||||||
|
/// push the path
|
||||||
|
extrusion_entities_append_paths(
|
||||||
|
eec->entities,
|
||||||
|
polylines_1,
|
||||||
|
good_role,
|
||||||
|
flow.mm3_per_mm() * params.flow_mult,
|
||||||
|
flow.width * params.flow_mult,
|
||||||
|
flow.height);
|
||||||
}
|
}
|
||||||
/// push the path
|
|
||||||
extrusion_entities_append_paths(
|
|
||||||
eec->entities, STDMOVE(polylines_1),
|
|
||||||
good_role,
|
|
||||||
flow.mm3_per_mm() * params.flow_mult,
|
|
||||||
flow.width * params.flow_mult,
|
|
||||||
flow.height);
|
|
||||||
|
|
||||||
|
|
||||||
|
// === extrude dense infill ===
|
||||||
Polylines polylines_2;
|
Polylines polylines_2;
|
||||||
|
bool canFill = true;
|
||||||
//50% overlap with the new perimeter
|
//50% overlap with the new perimeter
|
||||||
ExPolygons path_inner = offset2_ex(surface->expolygon, scale_(-this->spacing * 1.5), scale_(this->spacing));
|
ExPolygons path_inner = offset2_ex(surface->expolygon, scale_(-this->spacing * 1.5), scale_(this->spacing));
|
||||||
for (ExPolygon &expolygon : path_inner) {
|
for (ExPolygon &expolygon : path_inner) {
|
||||||
Surface surfInner(*surface, expolygon);
|
Surface surfInner(*surface, expolygon);
|
||||||
if (!fill_surface_by_lines(&surfInner, params, 0.f, 0.f, polylines_2)) {
|
if (!fill_surface_by_lines(&surfInner, params, 0.f, 0.f, polylines_2)) {
|
||||||
printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
|
printf("FillRectilinear2::fill_surface() failed to fill a region.\n");
|
||||||
|
canFill = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Save into layer.
|
if (canFill && !polylines_2.empty()) {
|
||||||
eec = new ExtrusionEntityCollection();
|
// Save into layer.
|
||||||
/// pass the no_sort attribute to the extrusion path
|
ExtrusionEntityCollection *eec = new ExtrusionEntityCollection();
|
||||||
eec->no_sort = this->no_sort();
|
/// pass the no_sort attribute to the extrusion path
|
||||||
/// add it into the collection
|
eec->no_sort = this->no_sort();
|
||||||
eecroot->entities.push_back(eec);
|
/// add it into the collection
|
||||||
/// push the path
|
eecroot->entities.push_back(eec);
|
||||||
extrusion_entities_append_paths(
|
//get the role
|
||||||
eec->entities, STDMOVE(polylines_2),
|
ExtrusionRole good_role = role;
|
||||||
good_role,
|
if (good_role == erNone || good_role == erCustom) {
|
||||||
flow.mm3_per_mm() * params.flow_mult,
|
good_role = flow.bridge ?
|
||||||
flow.width * params.flow_mult,
|
erBridgeInfill :
|
||||||
flow.height);
|
(surface->is_solid() ?
|
||||||
|
((surface->is_top()) ? erTopSolidInfill : erSolidInfill) :
|
||||||
|
erInternalInfill);
|
||||||
|
}
|
||||||
|
/// push the path
|
||||||
|
extrusion_entities_append_paths(
|
||||||
|
eec->entities,
|
||||||
|
polylines_2,
|
||||||
|
good_role,
|
||||||
|
flow.mm3_per_mm() * params.flow_mult,
|
||||||
|
flow.width * params.flow_mult,
|
||||||
|
flow.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// === end ===
|
||||||
|
if (!eecroot->empty()) {
|
||||||
|
out.push_back(eecroot);
|
||||||
|
} else {
|
||||||
|
delete eecroot;
|
||||||
|
}
|
||||||
|
|
||||||
out.push_back(eecroot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
Loading…
x
Reference in New Issue
Block a user