mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-01 02:32:02 +08:00
Make nearest seam position choose from corners first if there are any
This commit is contained in:
parent
65f1a25854
commit
badd01b65d
@ -275,6 +275,36 @@ Point finalize_seam_position(
|
|||||||
return scaled(loop_point);
|
return scaled(loop_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NearestCorner {
|
||||||
|
Vec2d prefered_position;
|
||||||
|
|
||||||
|
std::optional<SeamChoice> operator()(
|
||||||
|
const Perimeters::Perimeter &perimeter,
|
||||||
|
const Perimeters::PointType point_type,
|
||||||
|
const Perimeters::PointClassification point_classification
|
||||||
|
) const {
|
||||||
|
std::optional<SeamChoice> corner_candidate;
|
||||||
|
double min_distance{std::numeric_limits<double>::infinity()};
|
||||||
|
for (std::size_t i{0}; i < perimeter.positions.size(); ++i) {
|
||||||
|
if (perimeter.point_types[i] == point_type &&
|
||||||
|
perimeter.point_classifications[i] == point_classification &&
|
||||||
|
perimeter.angle_types[i] != Perimeters::AngleType::smooth) {
|
||||||
|
const Vec2d &point{perimeter.positions[i]};
|
||||||
|
if (!corner_candidate) {
|
||||||
|
corner_candidate = {i, i, point};
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const double distance{(prefered_position - point).norm()};
|
||||||
|
if (distance < min_distance) {
|
||||||
|
corner_candidate = {i, i, point};
|
||||||
|
min_distance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return corner_candidate;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::pair<SeamChoice, std::size_t> place_seam_near(
|
std::pair<SeamChoice, std::size_t> place_seam_near(
|
||||||
const std::vector<BoundedPerimeter> &layer_perimeters,
|
const std::vector<BoundedPerimeter> &layer_perimeters,
|
||||||
const ExtrusionLoop &loop,
|
const ExtrusionLoop &loop,
|
||||||
@ -292,11 +322,19 @@ std::pair<SeamChoice, std::size_t> place_seam_near(
|
|||||||
const std::size_t choice_index{
|
const std::size_t choice_index{
|
||||||
Geometry::pick_closest_bounding_box(loop_polygon.bounding_box(), choose_from).first};
|
Geometry::pick_closest_bounding_box(loop_polygon.bounding_box(), choose_from).first};
|
||||||
|
|
||||||
Seams::Aligned::Impl::Nearest nearest{unscaled(position), max_detour};
|
const NearestCorner nearest_corner{unscaled(position)};
|
||||||
|
const std::optional<SeamChoice> corner_choice{
|
||||||
|
Seams::maybe_choose_seam_point(layer_perimeters[choice_index].perimeter, nearest_corner)};
|
||||||
|
|
||||||
const SeamChoice choice{Seams::choose_seam_point(layer_perimeters[choice_index].perimeter, nearest)};
|
if (corner_choice) {
|
||||||
|
return {*corner_choice, choice_index};
|
||||||
|
}
|
||||||
|
|
||||||
return {choice, choice_index};
|
const Seams::Aligned::Impl::Nearest nearest{unscaled(position), max_detour};
|
||||||
|
const SeamChoice nearest_choice{
|
||||||
|
Seams::choose_seam_point(layer_perimeters[choice_index].perimeter, nearest)};
|
||||||
|
|
||||||
|
return {nearest_choice, choice_index};
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_perimeter_count(const Layer *layer){
|
int get_perimeter_count(const Layer *layer){
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define slic3r_TopBarMenus_hpp_
|
#define slic3r_TopBarMenus_hpp_
|
||||||
|
|
||||||
#include <wx/menu.h>
|
#include <wx/menu.h>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
class TopBarItemsCtrl;
|
class TopBarItemsCtrl;
|
||||||
class wxString;
|
class wxString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user