Skip to content

Commit 83945d3

Browse files
committed
Merge remote-tracking branch 'remotes/local/dev_27_61' into superslicer_variant
2 parents f64013b + 9ce6e81 commit 83945d3

File tree

5 files changed

+58
-4
lines changed

5 files changed

+58
-4
lines changed

src/libslic3r/Fill/Fill.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,29 @@ static LayerIsland *get_fill_island(Layer &layer,
672672
// Sort the extrusion range into its LayerIsland.
673673
// Traverse the slices in an increasing order of bounding box size, so that the islands inside another islands are tested first,
674674
// so we can just test a point inside ExPolygon::contour and we may skip testing the holes.
675+
// That is because layer.lslices() is topologically sorted.
675676
auto point_inside_surface = [&layer](const size_t lslice_idx, const Point &point) {
676677
const BoundingBox &bbox = layer.lslices_ex[lslice_idx].bbox;
677678
return point.x() >= bbox.min.x() && point.x() < bbox.max.x() && point.y() >= bbox.min.y() && point.y() < bbox.max.y() &&
678679
layer.lslices()[lslice_idx].contour.contains(point);
679680
};
681+
#ifdef _DEBUG
682+
// check topological sort
683+
if (layer.lslices().size() > 1) {
684+
std::vector<BoundingBox> bboxes;
685+
bboxes.emplace_back(layer.lslices()[0].contour.points);
686+
for (size_t check_idx = 1; check_idx < layer.lslices().size(); ++check_idx) {
687+
assert(bboxes.size() == check_idx);
688+
bboxes.emplace_back(layer.lslices()[check_idx].contour.points);
689+
for (size_t bigger_idx = 0; bigger_idx < check_idx; ++bigger_idx) {
690+
// higher idx can be inside holes, but not the opposite!
691+
if (bboxes[check_idx].contains(bboxes[bigger_idx])) {
692+
assert(!layer.lslices()[check_idx].contour.contains(layer.lslices()[bigger_idx].contour.first_point()));
693+
}
694+
}
695+
}
696+
}
697+
#endif
680698
int lslice_idx = int(layer.lslices_ex.size()) - 1;
681699
for (; lslice_idx >= 0; --lslice_idx)
682700
if (point_inside_surface(lslice_idx, point))
@@ -759,6 +777,7 @@ static void insert_ironings_into_islands(Layer &layer, uint32_t layer_region_id,
759777
// Sort the extrusion range into its LayerIsland.
760778
// Traverse the slices in an increasing order of bounding box size, so that the islands inside another islands are tested first,
761779
// so we can just test a point inside ExPolygon::contour and we may skip testing the holes.
780+
// That is because layer.lslices() is topologically sorted.
762781
auto point_inside_surface = [&layer](const size_t lslice_idx, const Point &point) {
763782
const BoundingBox &bbox = layer.lslices_ex[lslice_idx].bbox;
764783
return point.x() >= bbox.min.x() && point.x() < bbox.max.x() &&

src/libslic3r/GCode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5870,8 +5870,10 @@ void GCodeGenerator::extrude_ironing(const ExtrudeArgs &print_args, const LayerI
58705870
}
58715871
if (!temp_fill_extrusions.empty()) {
58725872
set_region_for_extrude(print, nullptr, &layerm, gcode);
5873-
for (const ExtrusionEntityReference &fill : chain_extrusion_references(temp_fill_extrusions, last_pos_defined() ? &last_pos() : nullptr))
5873+
for (const ExtrusionEntityReference &fill :
5874+
chain_extrusion_references(temp_fill_extrusions, last_pos_defined() ? &last_pos() : nullptr)) {
58745875
gcode += this->extrude_entity(fill, "ironing"sv);
5876+
}
58755877
}
58765878
it = it_end;
58775879
m_region = nullptr;

src/libslic3r/Layer.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ void Layer::make_slices()
6868
ensure_valid(slices, std::max(scale_t(this->object()->print()->config().resolution), SCALED_EPSILON));
6969
for (ExPolygon &poly : slices) poly.assert_valid();
7070
// lslices are sorted by topological order from outside to inside from the clipper union used above
71+
#ifdef _DEBUG
72+
if (slices.size() > 1) {
73+
std::vector<BoundingBox> bboxes;
74+
bboxes.emplace_back(slices[0].contour.points);
75+
for (size_t check_idx = 1; check_idx < slices.size(); ++check_idx) {
76+
assert(bboxes.size() == check_idx);
77+
bboxes.emplace_back(slices[check_idx].contour.points);
78+
for (size_t bigger_idx = 0; bigger_idx < check_idx; ++bigger_idx) {
79+
// higher idx can be inside holes, but not the opposite!
80+
if (bboxes[check_idx].contains(bboxes[bigger_idx])) {
81+
assert(!slices[check_idx].contour.contains(slices[bigger_idx].contour.first_point()));
82+
}
83+
}
84+
}
85+
}
86+
#endif
7187
this->set_lslices() = slices;
7288
}
7389

src/libslic3r/Layer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ struct LayerIsland
312312
}
313313
void add_ironing_range(const LayerExtrusionRange &new_ironing_range) {
314314
// Compress ranges.
315-
if (!this->ironings.empty() && this->fills.back().region() == new_ironing_range.region() &&
316-
*this->fills.back().end() == *new_ironing_range.begin())
317-
this->ironings.back() = {new_ironing_range.region(), {*this->fills.back().begin(), *new_ironing_range.end()}};
315+
if (!this->ironings.empty() && this->ironings.back().region() == new_ironing_range.region() &&
316+
*this->ironings.back().end() == *new_ironing_range.begin())
317+
this->ironings.back() = {new_ironing_range.region(), {*this->ironings.back().begin(), *new_ironing_range.end()}};
318318
else
319319
this->ironings.push_back(new_ironing_range);
320320
}

src/libslic3r/PrintObjectSlice.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,23 @@ void PrintObject::_max_overhang_threshold() {
895895
ExPolygons new_lslices = intersection_ex(my_layer->lslices(), all_region_modified, ApplySafetyOffset::Yes);
896896
ensure_valid(new_lslices, resolution);
897897
assert_valid(new_lslices);
898+
// lslices are sorted by topological order from outside to inside from the clipper intersection_ex used above
899+
#ifdef _DEBUG
900+
if (new_lslices.size() > 1) {
901+
std::vector<BoundingBox> bboxes;
902+
bboxes.emplace_back(new_lslices[0].contour.points);
903+
for (size_t check_idx = 1; check_idx < new_lslices.size(); ++check_idx) {
904+
assert(bboxes.size() == check_idx);
905+
bboxes.emplace_back(new_lslices[check_idx].contour.points);
906+
for (size_t bigger_idx = 0; bigger_idx < check_idx; ++bigger_idx) {
907+
// higher idx can be inside holes, but not the opposite!
908+
if (bboxes[check_idx].contains(bboxes[bigger_idx])) {
909+
assert(!new_lslices[check_idx].contour.contains(new_lslices[bigger_idx].contour.first_point()));
910+
}
911+
}
912+
}
913+
}
914+
#endif
898915
my_layer->set_lslices() = std::move(new_lslices);
899916
my_layer->lslice_indices_sorted_by_print_order = chain_expolygons(my_layer->lslices());
900917
assert(my_layer->lslices().size() == my_layer->lslice_indices_sorted_by_print_order.size());

0 commit comments

Comments
 (0)