mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 22:49:04 +08:00
Do not remove permanent point influence in layers out of part.
This commit is contained in:
parent
03d41b5966
commit
a19d00ea14
@ -17,6 +17,12 @@ using namespace Slic3r;
|
|||||||
using namespace Slic3r::sla;
|
using namespace Slic3r::sla;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
bool exist_point_in_distance(const Vec3f &p, float distance, const LayerSupportPoints &pts) {
|
||||||
|
float distance_sq = sqr(distance);
|
||||||
|
return std::any_of(pts.begin(), pts.end(), [&p, distance_sq](const LayerSupportPoint &sp) {
|
||||||
|
return (sp.pos - p).squaredNorm() < distance_sq; });
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Struct to store support points in KD tree to fast search for nearest ones.
|
/// Struct to store support points in KD tree to fast search for nearest ones.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,13 +63,17 @@ public:
|
|||||||
/// Remove support points from KD-Tree which lay out of expolygons
|
/// Remove support points from KD-Tree which lay out of expolygons
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="shapes">Define area where could be support points</param>
|
/// <param name="shapes">Define area where could be support points</param>
|
||||||
void remove_out_of(const ExPolygons &shapes) {
|
/// <param name="current_z">Current layer z coordinate
|
||||||
|
/// to prevent remove permanent points in prev layer influence</param>
|
||||||
|
void remove_out_of(const ExPolygons &shapes, float current_z) {
|
||||||
std::vector<size_t> indices = get_indices();
|
std::vector<size_t> indices = get_indices();
|
||||||
auto it = std::remove_if(indices.begin(), indices.end(),
|
auto it = std::remove_if(indices.begin(), indices.end(),
|
||||||
[&pts = *m_points.m_supports_ptr, &shapes](size_t point_index) {
|
[&pts = *m_points.m_supports_ptr, &shapes, current_z](size_t point_index) {
|
||||||
const Point& p = pts.at(point_index).position_on_layer;
|
const LayerSupportPoint& lsp = pts.at(point_index);
|
||||||
|
if (lsp.is_permanent && lsp.pos.z() >= current_z)
|
||||||
|
return false;
|
||||||
return !std::any_of(shapes.begin(), shapes.end(),
|
return !std::any_of(shapes.begin(), shapes.end(),
|
||||||
[&p](const ExPolygon &shape) {
|
[&p = lsp.position_on_layer](const ExPolygon &shape) {
|
||||||
return shape.contains(p);
|
return shape.contains(p);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -83,6 +93,7 @@ public:
|
|||||||
// IMPROVE: only add to existing tree, do not reconstruct tree
|
// IMPROVE: only add to existing tree, do not reconstruct tree
|
||||||
std::vector<size_t> indices = get_indices();
|
std::vector<size_t> indices = get_indices();
|
||||||
LayerSupportPoints &pts = *m_points.m_supports_ptr;
|
LayerSupportPoints &pts = *m_points.m_supports_ptr;
|
||||||
|
assert(!exist_point_in_distance(point.pos, point.head_front_radius, pts));
|
||||||
size_t index = pts.size();
|
size_t index = pts.size();
|
||||||
pts.emplace_back(std::move(point));
|
pts.emplace_back(std::move(point));
|
||||||
indices.push_back(index);
|
indices.push_back(index);
|
||||||
@ -527,13 +538,13 @@ void prepare_supports_for_layer(LayerSupportPoints &supports, float layer_z,
|
|||||||
/// Wanted Side effect, it supports thiny part of overhangs
|
/// Wanted Side effect, it supports thiny part of overhangs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="near_points"></param>
|
/// <param name="near_points"></param>
|
||||||
/// <param name="part"></param>
|
/// <param name="part">current </param>
|
||||||
/// <param name="config"></param>
|
/// <param name="current_z">Current layer z coordinate
|
||||||
void remove_supports_out_of_part(NearPoints& near_points, const LayerPart &part,
|
/// to prevent remove permanent points in prev layer influence</param>
|
||||||
const SupportPointGeneratorConfig &config) {
|
void remove_supports_out_of_part(NearPoints &near_points, const LayerPart &part, float current_z) {
|
||||||
// Offsetting is made in data preparation - speed up caused by paralelization
|
// Offsetting is made in data preparation - speed up caused by paralelization
|
||||||
//ExPolygons extend_shape = offset_ex(*part.shape, config.removing_delta, ClipperLib::jtSquare);
|
//ExPolygons extend_shape = offset_ex(*part.shape, config.removing_delta, ClipperLib::jtSquare);
|
||||||
near_points.remove_out_of(part.extend_shape);
|
near_points.remove_out_of(part.extend_shape, current_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1192,7 +1203,7 @@ LayerSupportPoints Slic3r::sla::generate_support_points(
|
|||||||
assert(layer_id != 0);
|
assert(layer_id != 0);
|
||||||
const LayerParts &prev_layer_parts = layers[layer_id - 1].parts;
|
const LayerParts &prev_layer_parts = layers[layer_id - 1].parts;
|
||||||
NearPoints near_points = create_near_points(prev_layer_parts, part, prev_grids);
|
NearPoints near_points = create_near_points(prev_layer_parts, part, prev_grids);
|
||||||
remove_supports_out_of_part(near_points, part, config);
|
remove_supports_out_of_part(near_points, part, layer.print_z);
|
||||||
if (!part.peninsulas.empty()) {
|
if (!part.peninsulas.empty()) {
|
||||||
// only get copy of points do not modify permanent_index
|
// only get copy of points do not modify permanent_index
|
||||||
Points permanent = get_permanents(permanent_supports, permanent_index, layer_id, part_id);
|
Points permanent = get_permanents(permanent_supports, permanent_index, layer_id, part_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user