mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 05:05:56 +08:00
Follow-up to 3713f09a8e461435d66cb375ddd41fb5f22bf7ef
30fbdd123525e1ea04d4af7593efc20a4b223147 Fixed duplication of infills.
This commit is contained in:
parent
da00cedc84
commit
423503a6c5
@ -403,7 +403,7 @@ static void insert_fills_into_islands(Layer &layer, uint32_t fill_region_id, uin
|
|||||||
}
|
}
|
||||||
assert(island);
|
assert(island);
|
||||||
if (island)
|
if (island)
|
||||||
island->fills.push_back(LayerExtrusionRange{ fill_region_id, { fill_begin, fill_end }});
|
island->add_fill_range(LayerExtrusionRange{ fill_region_id, { fill_begin, fill_end }});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,14 +550,14 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
|||||||
collection.entities.reserve(island.thin_fills.size());
|
collection.entities.reserve(island.thin_fills.size());
|
||||||
for (uint32_t fill_id : island.thin_fills)
|
for (uint32_t fill_id : island.thin_fills)
|
||||||
collection.entities.push_back(layerm.thin_fills().entities[fill_id]->clone());
|
collection.entities.push_back(layerm.thin_fills().entities[fill_id]->clone());
|
||||||
island.fills.push_back({ island.perimeters.region(), { uint32_t(layerm.m_fills.entities.size() - 1), uint32_t(layerm.m_fills.entities.size()) } });
|
island.add_fill_range({ island.perimeters.region(), { uint32_t(layerm.m_fills.entities.size() - 1), uint32_t(layerm.m_fills.entities.size()) } });
|
||||||
}
|
}
|
||||||
// Sort the fills by region ID.
|
// Sort the fills by region ID.
|
||||||
std::sort(island.fills.begin(), island.fills.end(), [](auto &l, auto &r){ return l.region() < r.region() || (l.region() == r.region() && *l.begin() < *r.begin()); });
|
std::sort(island.fills.begin(), island.fills.end(), [](auto &l, auto &r){ return l.region() < r.region() || (l.region() == r.region() && *l.begin() < *r.begin()); });
|
||||||
// Compress continuous fill ranges of the same region.
|
// Compress continuous fill ranges of the same region.
|
||||||
{
|
{
|
||||||
size_t k = 0;
|
size_t k = 0;
|
||||||
for (size_t i = 0; i < island.fills.size(); ++ i) {
|
for (size_t i = 0; i < island.fills.size();) {
|
||||||
uint32_t region_id = island.fills[i].region();
|
uint32_t region_id = island.fills[i].region();
|
||||||
uint32_t begin = *island.fills[i].begin();
|
uint32_t begin = *island.fills[i].begin();
|
||||||
uint32_t end = *island.fills[i].end();
|
uint32_t end = *island.fills[i].end();
|
||||||
@ -565,6 +565,7 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
|||||||
for (; j < island.fills.size() && island.fills[j].region() == region_id && *island.fills[j].begin() == end; ++ j)
|
for (; j < island.fills.size() && island.fills[j].region() == region_id && *island.fills[j].begin() == end; ++ j)
|
||||||
end = *island.fills[j].end();
|
end = *island.fills[j].end();
|
||||||
island.fills[k ++] = { region_id, { begin, end } };
|
island.fills[k ++] = { region_id, { begin, end } };
|
||||||
|
i = j;
|
||||||
}
|
}
|
||||||
island.fills.erase(island.fills.begin() + k, island.fills.end());
|
island.fills.erase(island.fills.begin() + k, island.fills.end());
|
||||||
}
|
}
|
||||||
|
@ -2430,12 +2430,13 @@ void GCode::process_layer_single_object(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto process_infill = [&]() {
|
auto process_infill = [&]() {
|
||||||
for (auto it = island.fills.begin(); it != island.fills.end(); ++ it) {
|
for (auto it = island.fills.begin(); it != island.fills.end();) {
|
||||||
// Gather range of fill ranges with the same region.
|
// Gather range of fill ranges with the same region.
|
||||||
auto it_end = it;
|
auto it_end = it;
|
||||||
for (++ it_end; it_end != island.fills.end() && it->region() == it_end->region(); ++ it_end) ;
|
for (++ it_end; it_end != island.fills.end() && it->region() == it_end->region(); ++ it_end) ;
|
||||||
const LayerRegion &layerm = *layer->get_region(it->region());
|
const LayerRegion &layerm = *layer->get_region(it->region());
|
||||||
extrude_infill_range(layerm, layerm.fills(), it, it_end, false /* normal extrusions, not ironing */);
|
extrude_infill_range(layerm, layerm.fills(), it, it_end, false /* normal extrusions, not ironing */);
|
||||||
|
it = it_end;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (print.config().infill_first) {
|
if (print.config().infill_first) {
|
||||||
@ -2451,12 +2452,13 @@ void GCode::process_layer_single_object(
|
|||||||
// First Ironing changes extrusion rate quickly, second single ironing may be done over multiple perimeter regions.
|
// First Ironing changes extrusion rate quickly, second single ironing may be done over multiple perimeter regions.
|
||||||
// Ironing in a second phase is safer, but it may be less efficient.
|
// Ironing in a second phase is safer, but it may be less efficient.
|
||||||
for (const LayerIsland &island : lslice.islands) {
|
for (const LayerIsland &island : lslice.islands) {
|
||||||
for (auto it = island.fills.begin(); it != island.fills.end(); ++ it) {
|
for (auto it = island.fills.begin(); it != island.fills.end();) {
|
||||||
// Gather range of fill ranges with the same region.
|
// Gather range of fill ranges with the same region.
|
||||||
auto it_end = it;
|
auto it_end = it;
|
||||||
for (++ it_end; it_end != island.fills.end() && it->region() == it_end->region(); ++ it_end) ;
|
for (++ it_end; it_end != island.fills.end() && it->region() == it_end->region(); ++ it_end) ;
|
||||||
const LayerRegion &layerm = *layer->get_region(it->region());
|
const LayerRegion &layerm = *layer->get_region(it->region());
|
||||||
extrude_infill_range(layerm, layerm.fills(), it, it_end, true /* ironing, not normal extrusions */);
|
extrude_infill_range(layerm, layerm.fills(), it, it_end, true /* ironing, not normal extrusions */);
|
||||||
|
it = it_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G
|
|||||||
if (axis != NUM_AXES_WITH_UNKNOWN) {
|
if (axis != NUM_AXES_WITH_UNKNOWN) {
|
||||||
// Try to parse the numeric value.
|
// Try to parse the numeric value.
|
||||||
double v;
|
double v;
|
||||||
c = skip_whitespaces(++c);
|
c = skip_whitespaces(++ c);
|
||||||
auto [pend, ec] = fast_float::from_chars(c, end, v);
|
auto [pend, ec] = fast_float::from_chars(c, end, v);
|
||||||
if (pend != c && is_end_of_word(*pend)) {
|
if (pend != c && is_end_of_word(*pend)) {
|
||||||
// The axis value has been parsed correctly.
|
// The axis value has been parsed correctly.
|
||||||
|
@ -256,6 +256,14 @@ public:
|
|||||||
// Point centroid;
|
// Point centroid;
|
||||||
|
|
||||||
bool has_extrusions() const { return ! this->perimeters.empty() || ! this->fills.empty(); }
|
bool has_extrusions() const { return ! this->perimeters.empty() || ! this->fills.empty(); }
|
||||||
|
|
||||||
|
void add_fill_range(const LayerExtrusionRange &new_fill_range) {
|
||||||
|
// Compress ranges.
|
||||||
|
if (! this->fills.empty() && this->fills.back().region() == new_fill_range.region() && *this->fills.back().end() == *new_fill_range.begin())
|
||||||
|
this->fills.back() = { new_fill_range.region(), { *this->fills.back().begin(), *new_fill_range.end() } };
|
||||||
|
else
|
||||||
|
this->fills.push_back(new_fill_range);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr const size_t LayerIslandsStaticSize = 1;
|
static constexpr const size_t LayerIslandsStaticSize = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user