Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix asymmetrical bead widths #1437

Merged
merged 4 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ void LayerPlan::addWall(const LineJunctions& wall, int start_idx, const Settings
for(size_t point_idx = 1; point_idx < max_index; point_idx++)
{
const ExtrusionJunction& p1 = wall[(wall.size() + start_idx + point_idx * direction) % wall.size()];
const coord_t line_width = (p0.w + p1.w) / 2; //For lines which in itself vary in width, use the average width of the variable line.

if (!bridge_wall_mask.empty())
{
Expand All @@ -881,11 +882,11 @@ void LayerPlan::addWall(const LineJunctions& wall, int start_idx, const Settings
if (is_small_feature)
{
constexpr bool spiralize = false;
addExtrusionMove(p1.p, non_bridge_config, SpaceFillType::Polygons, flow_ratio * (p1.w * nominal_line_width_multiplier), spiralize, small_feature_speed_factor);
addExtrusionMove(p1.p, non_bridge_config, SpaceFillType::Polygons, flow_ratio * (line_width * nominal_line_width_multiplier), spiralize, small_feature_speed_factor);
}
else
{
addWallLine(p0.p, p1.p, settings, non_bridge_config, bridge_config, flow_ratio * (p1.w * nominal_line_width_multiplier), non_bridge_line_volume, speed_factor, distance_to_bridge_start);
addWallLine(p0.p, p1.p, settings, non_bridge_config, bridge_config, flow_ratio * (line_width * nominal_line_width_multiplier), non_bridge_line_volume, speed_factor, distance_to_bridge_start);
}
}
else
Expand Down
13 changes: 6 additions & 7 deletions src/SkeletalTrapezoidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ void SkeletalTrapezoidation::generateSegments()
propagateBeadingsUpward(upward_quad_mids, node_beadings);

propagateBeadingsDownward(upward_quad_mids, node_beadings);

ptr_vector_t<LineJunctions> edge_junctions; // junctions ordered high R to low R
generateJunctions(node_beadings, edge_junctions);

Expand Down Expand Up @@ -1727,9 +1727,9 @@ void SkeletalTrapezoidation::generateJunctions(ptr_vector_t<BeadingPropagation>&
Point ab = b - a;

const size_t num_junctions = beading->toolpath_locations.size();
coord_t junction_idx;
size_t junction_idx;
// Compute starting junction_idx for this segment
for (junction_idx = (std::max(size_t(1), beading->toolpath_locations.size()) - 1) / 2; junction_idx >= 0 && junction_idx < coord_t(num_junctions); junction_idx--)
for (junction_idx = (std::max(size_t(1), beading->toolpath_locations.size()) - 1) / 2; junction_idx < num_junctions; junction_idx--)
{
coord_t bead_R = beading->toolpath_locations[junction_idx];
if (bead_R <= start_R)
Expand All @@ -1740,15 +1740,15 @@ void SkeletalTrapezoidation::generateJunctions(ptr_vector_t<BeadingPropagation>&

// Robustness against odd segments which might lie just slightly outside of the range due to rounding errors
// not sure if this is really needed (TODO)
if (junction_idx + 1 < coord_t(num_junctions)
if (junction_idx + 1 < num_junctions
&& beading->toolpath_locations[junction_idx + 1] <= start_R + 5
&& beading->total_thickness < start_R + 5
)
{
junction_idx++;
}

for (; junction_idx >= 0 && junction_idx < coord_t(num_junctions); junction_idx--)
for (; junction_idx < num_junctions; junction_idx--) //When junction_idx underflows, it'll be more than num_junctions too.
{
coord_t bead_R = beading->toolpath_locations[junction_idx];
assert(bead_R >= 0);
Expand Down Expand Up @@ -1955,7 +1955,7 @@ void SkeletalTrapezoidation::connectJunctions(ptr_vector_t<LineJunctions>& edge_
to_junctions.reserve(to_junctions.size() + to_next_junctions.size());
to_junctions.insert(to_junctions.end(), to_next_junctions.begin(), to_next_junctions.end());
assert(!edge_from_peak->next->next);
if(edge_to_peak->next->next)
if(edge_from_peak->next->next)
{
RUN_ONCE(logWarning("The edge we're about to connect is already connected!\n"));
}
Expand All @@ -1966,7 +1966,6 @@ void SkeletalTrapezoidation::connectJunctions(ptr_vector_t<LineJunctions>& edge_
logWarning("Can't create a transition when connecting two perimeters where the number of beads differs too much! %i vs. %i", from_junctions.size(), to_junctions.size());
}


size_t segment_count = std::min(from_junctions.size(), to_junctions.size());
for (size_t junction_rev_idx = 0; junction_rev_idx < segment_count; junction_rev_idx++)
{
Expand Down