mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-28 17:13:12 +08:00
FIX: optimize avoid crossing wall
jira: STUDIO-11682 Change-Id: I49b6756a5d3aeb482c019813074d8f6f9cc3c6ef
This commit is contained in:
parent
ca4a2059fe
commit
e9b7006db9
@ -5821,9 +5821,8 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
|
||||
// if a retraction would be needed, try to use reduce_crossing_wall to plan a
|
||||
// multi-hop travel path inside the configuration space
|
||||
// if (
|
||||
if (needs_retraction
|
||||
&& m_config.reduce_crossing_wall
|
||||
&& ! m_avoid_crossing_perimeters.disabled_once()
|
||||
if (m_config.reduce_crossing_wall
|
||||
&& !m_avoid_crossing_perimeters.disabled_once()
|
||||
&& m_writer.is_current_position_clear())
|
||||
//BBS: don't generate detour travel paths when current position is unclea
|
||||
{
|
||||
|
@ -1245,7 +1245,7 @@ static ExPolygons get_boundary(const Layer &layer, float perimeter_spacing)
|
||||
}
|
||||
|
||||
// called by AvoidCrossingPerimeters::travel_to()
|
||||
static ExPolygons get_slice_boundary(const Layer &layer)
|
||||
static ExPolygons get_slice_boundary_internal(const Layer &layer)
|
||||
{
|
||||
auto const *support_layer = dynamic_cast<const SupportLayer *>(&layer);
|
||||
ExPolygons boundary = layer.lslices;
|
||||
@ -1414,22 +1414,27 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &
|
||||
const std::vector<BoundingBox> &lslices_bboxes = gcodegen.layer()->lslices_bboxes;
|
||||
bool is_support_layer = (dynamic_cast<const SupportLayer *>(gcodegen.layer()) != nullptr);
|
||||
if (!use_external && (is_support_layer || (!lslices.empty() && !any_expolygon_contains(lslices, lslices_bboxes, m_grid_lslice, travel)))) {
|
||||
AvoidCrossingPerimeters::Boundary slice_boundary;
|
||||
init_boundary(&slice_boundary, to_polygons(get_slice_boundary(*gcodegen.layer())), {start, end});
|
||||
if (m_lslice_internal.boundaries.empty()) {
|
||||
init_boundary(&m_lslice_internal, to_polygons(get_slice_boundary_internal(*gcodegen.layer())), {start, end});
|
||||
} else if (!(m_lslice_internal.bbox.contains(startf) && m_lslice_internal.bbox.contains(endf))) {
|
||||
// check if start and end are in bbox
|
||||
m_lslice_internal.clear();
|
||||
init_boundary(&m_lslice_internal, to_polygons(get_slice_boundary_internal(*gcodegen.layer())), {start, end});
|
||||
}
|
||||
|
||||
// Initialize m_internal only when it is necessary.
|
||||
if (m_internal.boundaries.empty()) {
|
||||
init_boundary(&m_internal, to_polygons(get_boundary(*gcodegen.layer(), get_perimeter_spacing(*gcodegen.layer()))), get_extents(slice_boundary.boundaries),
|
||||
init_boundary(&m_internal, to_polygons(get_boundary(*gcodegen.layer(), get_perimeter_spacing(*gcodegen.layer()))), get_extents(m_lslice_internal.boundaries),
|
||||
{start, end});
|
||||
} else if (!(m_internal.bbox.contains(startf) && m_internal.bbox.contains(endf))) {
|
||||
// check if start and end are in bbox, if not, merge start and end points to bbox
|
||||
m_internal.clear();
|
||||
init_boundary(&m_internal, to_polygons(get_boundary(*gcodegen.layer(), get_perimeter_spacing(*gcodegen.layer()))), get_extents(slice_boundary.boundaries),
|
||||
init_boundary(&m_internal, to_polygons(get_boundary(*gcodegen.layer(), get_perimeter_spacing(*gcodegen.layer()))), get_extents(m_lslice_internal.boundaries),
|
||||
{start, end});
|
||||
}
|
||||
|
||||
// Trim the travel line by the bounding box.
|
||||
if (!m_internal.boundaries.empty()) {
|
||||
travel_intersection_count = avoid_perimeters(slice_boundary, m_internal, start, end, *gcodegen.layer(), result_pl);
|
||||
travel_intersection_count = avoid_perimeters(m_lslice_internal, m_internal, start, end, *gcodegen.layer(), result_pl);
|
||||
result_pl.points.front() = start;
|
||||
result_pl.points.back() = end;
|
||||
}
|
||||
@ -1491,6 +1496,7 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &
|
||||
void AvoidCrossingPerimeters::init_layer(const Layer &layer)
|
||||
{
|
||||
m_internal.clear();
|
||||
m_lslice_internal.clear();
|
||||
m_external.clear();
|
||||
|
||||
BoundingBox bbox_slice(get_extents(layer.lslices));
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
EdgeGrid::Grid m_grid_lslice;
|
||||
// Store all needed data for travels inside object
|
||||
Boundary m_internal;
|
||||
// Store all needed data for travels inside object without inner offset
|
||||
Boundary m_lslice_internal;
|
||||
// Store all needed data for travels outside object
|
||||
Boundary m_external;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user