mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-07 12:18:59 +08:00
Fixed wrong usage of thickPolyline, added description of what it should actually contain
This commit is contained in:
parent
9d3a7f9f2a
commit
4409743ea4
@ -168,7 +168,7 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
|
|||||||
polygon_sections[section_idx].end());
|
polygon_sections[section_idx].end());
|
||||||
}
|
}
|
||||||
|
|
||||||
double squared_distance_limit_reconnection = 4 * scaled_spacing * scaled_spacing;
|
double squared_distance_limit_reconnection = 4 * double(scaled_spacing) * double(scaled_spacing);
|
||||||
|
|
||||||
Polygons reconstructed_area{};
|
Polygons reconstructed_area{};
|
||||||
// reconstruct polygon from polygon sections
|
// reconstruct polygon from polygon sections
|
||||||
@ -185,7 +185,9 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
|
|||||||
for (TracedPoly &traced_poly : current_traced_polys) {
|
for (TracedPoly &traced_poly : current_traced_polys) {
|
||||||
auto maybe_first_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_poly.lows.back(),
|
auto maybe_first_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_poly.lows.back(),
|
||||||
[](const Point &low, const Line &seg) { return seg.b.y() < low.y(); });
|
[](const Point &low, const Line &seg) { return seg.b.y() < low.y(); });
|
||||||
|
if (maybe_first_overlap != polygon_slice.begin()) {
|
||||||
|
maybe_first_overlap--;
|
||||||
|
}
|
||||||
if (maybe_first_overlap != polygon_slice.end() && // segment exists
|
if (maybe_first_overlap != polygon_slice.end() && // segment exists
|
||||||
segments_overlap(traced_poly.lows.back().y(), traced_poly.highs.back().y(), maybe_first_overlap->a.y(),
|
segments_overlap(traced_poly.lows.back().y(), traced_poly.highs.back().y(), maybe_first_overlap->a.y(),
|
||||||
maybe_first_overlap->b.y())) // segment is overlapping
|
maybe_first_overlap->b.y())) // segment is overlapping
|
||||||
@ -252,22 +254,27 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
|
|||||||
for (ThickPolyline &traced_path : current_traced_paths) {
|
for (ThickPolyline &traced_path : current_traced_paths) {
|
||||||
auto maybe_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_path.last_point(),
|
auto maybe_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_path.last_point(),
|
||||||
[](const Point &low, const Line &seg) { return seg.a.y() < low.y(); });
|
[](const Point &low, const Line &seg) { return seg.a.y() < low.y(); });
|
||||||
bool segment_added = false;
|
if (maybe_overlap != polygon_slice.begin()) {
|
||||||
if (maybe_overlap != polygon_slice.begin())
|
|
||||||
maybe_overlap--;
|
maybe_overlap--;
|
||||||
|
}
|
||||||
|
bool segment_added = false;
|
||||||
while (!segment_added && maybe_overlap != polygon_slice.end()) {
|
while (!segment_added && maybe_overlap != polygon_slice.end()) {
|
||||||
if ((traced_path.last_point() - maybe_overlap->a).cast<double>().squaredNorm() <
|
if ((traced_path.last_point() - maybe_overlap->a).cast<double>().squaredNorm() <
|
||||||
squared_distance_limit_reconnection) {
|
squared_distance_limit_reconnection) {
|
||||||
|
traced_path.width.push_back(scaled_spacing);
|
||||||
traced_path.points.push_back(maybe_overlap->a);
|
traced_path.points.push_back(maybe_overlap->a);
|
||||||
traced_path.width.push_back(scaled_spacing);
|
traced_path.width.push_back(scaled_spacing);
|
||||||
|
traced_path.width.push_back(scaled_spacing);
|
||||||
traced_path.points.push_back(maybe_overlap->b);
|
traced_path.points.push_back(maybe_overlap->b);
|
||||||
traced_path.width.push_back(scaled_spacing);
|
traced_path.width.push_back(scaled_spacing);
|
||||||
used_segments.insert(&(*maybe_overlap));
|
used_segments.insert(&(*maybe_overlap));
|
||||||
segment_added = true;
|
segment_added = true;
|
||||||
} else if ((traced_path.last_point() - maybe_overlap->b).cast<double>().squaredNorm() <
|
} else if ((traced_path.last_point() - maybe_overlap->b).cast<double>().squaredNorm() <
|
||||||
squared_distance_limit_reconnection) {
|
squared_distance_limit_reconnection) {
|
||||||
|
traced_path.width.push_back(scaled_spacing);
|
||||||
traced_path.points.push_back(maybe_overlap->b);
|
traced_path.points.push_back(maybe_overlap->b);
|
||||||
traced_path.width.push_back(scaled_spacing);
|
traced_path.width.push_back(scaled_spacing);
|
||||||
|
traced_path.width.push_back(scaled_spacing);
|
||||||
traced_path.points.push_back(maybe_overlap->a);
|
traced_path.points.push_back(maybe_overlap->a);
|
||||||
traced_path.width.push_back(scaled_spacing);
|
traced_path.width.push_back(scaled_spacing);
|
||||||
used_segments.insert(&(*maybe_overlap));
|
used_segments.insert(&(*maybe_overlap));
|
||||||
@ -287,13 +294,14 @@ ThickPolylines FillEnsuring::fill_surface_arachne(const Surface *surface, const
|
|||||||
[](const ThickPolyline &tp) { return tp.empty(); }),
|
[](const ThickPolyline &tp) { return tp.empty(); }),
|
||||||
current_traced_paths.end());
|
current_traced_paths.end());
|
||||||
|
|
||||||
for (const auto &segment : polygon_slice) {
|
for (const Line &segment : polygon_slice) {
|
||||||
if (used_segments.find(&segment) == used_segments.end()) {
|
if (used_segments.find(&segment) == used_segments.end()) {
|
||||||
ThickPolyline &new_path = current_traced_paths.emplace_back();
|
ThickPolyline &new_path = current_traced_paths.emplace_back();
|
||||||
new_path.points.push_back(segment.a);
|
new_path.points.push_back(segment.a);
|
||||||
new_path.width.push_back(scaled_spacing);
|
new_path.width.push_back(scaled_spacing);
|
||||||
new_path.points.push_back(segment.b);
|
new_path.points.push_back(segment.b);
|
||||||
new_path.width.push_back(scaled_spacing);
|
new_path.width.push_back(scaled_spacing);
|
||||||
|
new_path.endpoints = {true,true};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,6 +206,9 @@ struct ThickPolyline {
|
|||||||
void start_at_index(int index);
|
void start_at_index(int index);
|
||||||
|
|
||||||
Points points;
|
Points points;
|
||||||
|
// vector of startpoint width and endpoint width of each line segment. The size should be always (points.size()-1) * 2
|
||||||
|
// e.g. let four be points a,b,c,d. that are three lines ab, bc, cd. for each line, there should be start width, so the width vector is:
|
||||||
|
// w(a), w(b), w(b), w(c), w(c), w(d)
|
||||||
std::vector<coordf_t> width;
|
std::vector<coordf_t> width;
|
||||||
std::pair<bool,bool> endpoints { false, false };
|
std::pair<bool,bool> endpoints { false, false };
|
||||||
};
|
};
|
||||||
|
@ -2122,8 +2122,10 @@ void PrintObject::bridge_over_infill()
|
|||||||
std::unordered_set<const Line *> used_segments;
|
std::unordered_set<const Line *> used_segments;
|
||||||
for (TracedPoly &traced_poly : current_traced_polys) {
|
for (TracedPoly &traced_poly : current_traced_polys) {
|
||||||
auto maybe_first_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_poly.lows.back(),
|
auto maybe_first_overlap = std::upper_bound(polygon_slice.begin(), polygon_slice.end(), traced_poly.lows.back(),
|
||||||
[](const Point &low, const Line &seg) { return seg.b.y() > low.y(); });
|
[](const Point &low, const Line &seg) { return seg.b.y() < low.y(); });
|
||||||
|
if (maybe_first_overlap != polygon_slice.begin()) {
|
||||||
|
maybe_first_overlap--;
|
||||||
|
}
|
||||||
if (maybe_first_overlap != polygon_slice.end() && // segment exists
|
if (maybe_first_overlap != polygon_slice.end() && // segment exists
|
||||||
segments_overlap(traced_poly.lows.back().y(), traced_poly.highs.back().y(), maybe_first_overlap->a.y(),
|
segments_overlap(traced_poly.lows.back().y(), traced_poly.highs.back().y(), maybe_first_overlap->a.y(),
|
||||||
maybe_first_overlap->b.y())) // segment is overlapping
|
maybe_first_overlap->b.y())) // segment is overlapping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user