Merge branch 'master' of https://github.com/Prusa-Development/PrusaSlicerPrivate
This commit is contained in:
commit
9c1f4ef5d3
@ -14,7 +14,7 @@
|
||||
#include "../../../clipper/clipper_z.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
class ThickPolyline;
|
||||
struct ThickPolyline;
|
||||
}
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
|
@ -320,7 +320,9 @@ void ExPolygon::medial_axis(double min_width, double max_width, Polylines* polyl
|
||||
{
|
||||
ThickPolylines tp;
|
||||
this->medial_axis(min_width, max_width, &tp);
|
||||
polylines->insert(polylines->end(), tp.begin(), tp.end());
|
||||
polylines->reserve(polylines->size() + tp.size());
|
||||
for (auto &pl : tp)
|
||||
polylines->emplace_back(pl.points);
|
||||
}
|
||||
|
||||
Lines ExPolygon::lines() const
|
||||
|
@ -498,6 +498,7 @@ void MedialAxis::build(ThickPolylines* polylines)
|
||||
polyline.width.emplace_back(seed_edge_data.width_end);
|
||||
// Grow the polyline in a forward direction.
|
||||
this->process_edge_neighbors(&*seed_edge, &polyline);
|
||||
assert(polyline.width.size() == polyline.points.size() * 2 - 2);
|
||||
|
||||
// Grow the polyline in a backward direction.
|
||||
reverse_polyline.clear();
|
||||
@ -505,7 +506,6 @@ void MedialAxis::build(ThickPolylines* polylines)
|
||||
polyline.points.insert(polyline.points.begin(), reverse_polyline.points.rbegin(), reverse_polyline.points.rend());
|
||||
polyline.width.insert(polyline.width.begin(), reverse_polyline.width.rbegin(), reverse_polyline.width.rend());
|
||||
polyline.endpoints.first = reverse_polyline.endpoints.second;
|
||||
|
||||
assert(polyline.width.size() == polyline.points.size() * 2 - 2);
|
||||
|
||||
// Prevent loop endpoints from being extended.
|
||||
@ -538,7 +538,9 @@ void MedialAxis::build(Polylines* polylines)
|
||||
{
|
||||
ThickPolylines tp;
|
||||
this->build(&tp);
|
||||
polylines->insert(polylines->end(), tp.begin(), tp.end());
|
||||
polylines->reserve(polylines->size() + tp.size());
|
||||
for (auto &pl : tp)
|
||||
polylines->emplace_back(pl.points);
|
||||
}
|
||||
|
||||
void MedialAxis::process_edge_neighbors(const VD::edge_type *edge, ThickPolyline* polyline)
|
||||
|
@ -497,16 +497,19 @@ void Layer::make_perimeters()
|
||||
} else {
|
||||
SurfaceCollection new_slices;
|
||||
// Use the region with highest infill rate, as the make_perimeters() function below decides on the gap fill based on the infill existence.
|
||||
LayerRegion *layerm_config = m_regions[layer_region_ids.front()];
|
||||
uint32_t region_id_config = layer_region_ids.front();
|
||||
LayerRegion* layerm_config = m_regions[region_id_config];
|
||||
{
|
||||
// Merge slices (surfaces) according to number of extra perimeters.
|
||||
for (uint32_t region_id : layer_region_ids) {
|
||||
LayerRegion &layerm = *m_regions[region_id];
|
||||
for (const Surface &surface : layerm.slices())
|
||||
surfaces_to_merge.emplace_back(&surface);
|
||||
if (layerm.region().config().fill_density > layerm_config->region().config().fill_density)
|
||||
if (layerm.region().config().fill_density > layerm_config->region().config().fill_density) {
|
||||
region_id_config = region_id;
|
||||
layerm_config = &layerm;
|
||||
}
|
||||
}
|
||||
std::sort(surfaces_to_merge.begin(), surfaces_to_merge.end(), [](const Surface *l, const Surface *r){ return l->extra_perimeters < r->extra_perimeters; });
|
||||
for (size_t i = 0; i < surfaces_to_merge.size();) {
|
||||
size_t j = i;
|
||||
@ -525,7 +528,7 @@ void Layer::make_perimeters()
|
||||
}
|
||||
// make perimeters
|
||||
layerm_config->make_perimeters(new_slices, perimeter_and_gapfill_ranges, fill_expolygons, fill_expolygons_ranges);
|
||||
this->sort_perimeters_into_islands(new_slices, region_id, perimeter_and_gapfill_ranges, std::move(fill_expolygons), fill_expolygons_ranges, layer_region_ids);
|
||||
this->sort_perimeters_into_islands(new_slices, region_id_config, perimeter_and_gapfill_ranges, std::move(fill_expolygons), fill_expolygons_ranges, layer_region_ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace Slic3r {
|
||||
|
||||
class Polyline;
|
||||
class ThickPolyline;
|
||||
struct ThickPolyline;
|
||||
typedef std::vector<Polyline> Polylines;
|
||||
typedef std::vector<ThickPolyline> ThickPolylines;
|
||||
|
||||
@ -160,20 +160,28 @@ bool remove_degenerate(Polylines &polylines);
|
||||
// Returns index of a segment of a polyline and foot point of pt on polyline.
|
||||
std::pair<int, Point> foot_pt(const Points &polyline, const Point &pt);
|
||||
|
||||
class ThickPolyline : public Polyline {
|
||||
public:
|
||||
ThickPolyline() : endpoints(std::make_pair(false, false)) {}
|
||||
struct ThickPolyline {
|
||||
ThickPolyline() = default;
|
||||
ThickLines thicklines() const;
|
||||
|
||||
const Point& first_point() const { return this->points.front(); }
|
||||
const Point& last_point() const { return this->points.back(); }
|
||||
bool is_valid() const { return this->points.size() >= 2; }
|
||||
double length() const { return Slic3r::length(this->points); }
|
||||
|
||||
void clear() { this->points.clear(); this->width.clear(); }
|
||||
|
||||
void reverse() {
|
||||
Polyline::reverse();
|
||||
std::reverse(this->points.begin(), this->points.end());
|
||||
std::reverse(this->width.begin(), this->width.end());
|
||||
std::swap(this->endpoints.first, this->endpoints.second);
|
||||
}
|
||||
|
||||
void clip_end(double distance);
|
||||
|
||||
Points points;
|
||||
std::vector<coordf_t> width;
|
||||
std::pair<bool,bool> endpoints;
|
||||
std::pair<bool,bool> endpoints { false, false };
|
||||
};
|
||||
|
||||
inline ThickPolylines to_thick_polylines(Polylines &&polylines, const coordf_t width)
|
||||
|
@ -179,8 +179,8 @@ void SVG::draw(const ThickLines &thicklines, const std::string &fill, const std:
|
||||
|
||||
void SVG::draw(const ThickPolylines &polylines, const std::string &stroke, coordf_t stroke_width)
|
||||
{
|
||||
for (ThickPolylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it)
|
||||
this->draw((Polyline)*it, stroke, stroke_width);
|
||||
for (const ThickPolyline &pl : polylines)
|
||||
this->draw(Polyline(pl.points), stroke, stroke_width);
|
||||
}
|
||||
|
||||
void SVG::draw(const ThickPolylines &thickpolylines, const std::string &fill, const std::string &stroke, coordf_t stroke_width)
|
||||
|
@ -617,9 +617,8 @@ std::tuple<ObjectPart, float> build_object_part_from_slice(const LayerSlice &sli
|
||||
}
|
||||
}
|
||||
}
|
||||
const LayerRegion *thin_fill_region = layer->get_region(island.fill_region_id);
|
||||
for (const auto &thin_fill_idx : island.thin_fills) {
|
||||
add_extrusions_to_object(thin_fill_region->thin_fills().entities[thin_fill_idx], perimeter_region);
|
||||
add_extrusions_to_object(perimeter_region->thin_fills().entities[thin_fill_idx], perimeter_region);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user