Skip to content

Commit

Permalink
switch res for large printer
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed May 12, 2024
1 parent 3e9a46c commit 5daecf3
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 62 deletions.
15 changes: 9 additions & 6 deletions src/libslic3r/Arachne/SkeletalTrapezoidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ void SkeletalTrapezoidation::generateToolpaths(std::vector<VariableWidthLines> &
export_graph_to_svg(debug_out_path("ST-updateIsCentral-final-%d.svg", iRun), this->graph, this->outline);
#endif

filterCentral(central_filter_dist);
filterCentral(central_filter_dist());

#ifdef ARACHNE_DEBUG
export_graph_to_svg(debug_out_path("ST-filterCentral-final-%d.svg", iRun), this->graph, this->outline);
Expand Down Expand Up @@ -729,7 +729,7 @@ void SkeletalTrapezoidation::filterNoncentralRegions()
BOOST_LOG_TRIVIAL(warning) << "Encountered an uninitialized bead at the boundary!";
}
assert(edge.to->data.bead_count >= 0 || edge.to->data.distance_to_boundary == 0);
constexpr coord_t max_dist = scaled<coord_t>(0.4);
const coord_t max_dist = scaled<coord_t>(0.4);
filterNoncentralRegions(&edge, edge.to->data.bead_count, 0, max_dist);
}
}
Expand Down Expand Up @@ -1303,6 +1303,7 @@ static inline Point normal(const Point& p0, coord_t len)

void SkeletalTrapezoidation::applyTransitions(ptr_vector_t<std::list<TransitionEnd>>& edge_transition_ends)
{
const auto _snap_dist = snap_dist();
for (edge_t& edge : graph.edges)
{
if (edge.twin->data.hasTransitionEnds())
Expand Down Expand Up @@ -1348,7 +1349,7 @@ void SkeletalTrapezoidation::applyTransitions(ptr_vector_t<std::list<TransitionE
coord_t new_node_bead_count = transition_end.is_lower_end? transition_end.lower_bead_count : transition_end.lower_bead_count + 1;
coord_t end_pos = transition_end.pos;
node_t* close_node = (end_pos < ab_size / 2)? from : to;
if ((end_pos < snap_dist || end_pos > ab_size - snap_dist)
if ((end_pos < _snap_dist || end_pos > ab_size - _snap_dist)
&& close_node->data.bead_count == new_node_bead_count
)
{
Expand Down Expand Up @@ -1390,6 +1391,7 @@ bool SkeletalTrapezoidation::isEndOfCentral(const edge_t& edge_to) const

void SkeletalTrapezoidation::generateExtraRibs()
{
const auto _snap_dist = snap_dist();
for (auto edge_it = graph.edges.begin(); edge_it != graph.edges.end(); ++edge_it)
{
edge_t& edge = *edge_it;
Expand Down Expand Up @@ -1433,7 +1435,7 @@ void SkeletalTrapezoidation::generateExtraRibs()
assert(end_pos > 0);
assert(end_pos < ab_size);
node_t* close_node = (end_pos < ab_size / 2)? from : to;
if ((end_pos < snap_dist || end_pos > ab_size - snap_dist)
if ((end_pos < _snap_dist || end_pos > ab_size - _snap_dist)
&& close_node->data.bead_count == new_node_bead_count
)
{
Expand Down Expand Up @@ -1593,6 +1595,7 @@ SkeletalTrapezoidation::edge_t* SkeletalTrapezoidation::getQuadMaxRedgeTo(edge_t

void SkeletalTrapezoidation::propagateBeadingsUpward(std::vector<edge_t*>& upward_quad_mids, ptr_vector_t<BeadingPropagation>& node_beadings)
{
const auto _central_filter_dist = central_filter_dist();
for (auto upward_quad_mids_it = upward_quad_mids.rbegin(); upward_quad_mids_it != upward_quad_mids.rend(); ++upward_quad_mids_it)
{
edge_t* upward_edge = *upward_quad_mids_it;
Expand All @@ -1609,7 +1612,7 @@ void SkeletalTrapezoidation::propagateBeadingsUpward(std::vector<edge_t*>& upwar
{ // Only propagate to places where there is place
continue;
}
assert((upward_edge->from->data.distance_to_boundary != upward_edge->to->data.distance_to_boundary || shorter_then(upward_edge->to->p - upward_edge->from->p, central_filter_dist)) && "zero difference R edges should always be central");
assert((upward_edge->from->data.distance_to_boundary != upward_edge->to->data.distance_to_boundary || shorter_then(upward_edge->to->p - upward_edge->from->p, _central_filter_dist)) && "zero difference R edges should always be central");
coord_t length = (upward_edge->to->p - upward_edge->from->p).cast<int64_t>().norm();
BeadingPropagation upper_beading = lower_beading;
upper_beading.dist_to_bottom_source += length;
Expand Down Expand Up @@ -1839,7 +1842,7 @@ std::shared_ptr<SkeletalTrapezoidationJoint::BeadingPropagation> SkeletalTrapezo
{
if (node->data.bead_count == -1)
{ // This bug is due to too small central edges
constexpr coord_t nearby_dist = scaled<coord_t>(0.1);
const coord_t nearby_dist = scaled<coord_t>(0.1);
auto nearest_beading = getNearestBeading(node, nearby_dist);
if (nearest_beading)
{
Expand Down
6 changes: 4 additions & 2 deletions src/libslic3r/Arachne/SkeletalTrapezoidation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class SkeletalTrapezoidation
coord_t transition_filter_dist; //!< Filter transition mids (i.e. anchors) closer together than this
coord_t allowed_filter_deviation; //!< The allowed line width deviation induced by filtering
coord_t beading_propagation_transition_dist; //!< When there are different beadings propagated from below and from above, use this transitioning distance
static constexpr coord_t central_filter_dist = scaled<coord_t>(0.02); //!< Filter areas marked as 'central' smaller than this
static constexpr coord_t snap_dist = scaled<coord_t>(0.02); //!< Generic arithmatic inaccuracy. Only used to determine whether a transition really needs to insert an extra edge.
//!< Filter areas marked as 'central' smaller than this
inline coord_t central_filter_dist() { return scaled<coord_t>(0.02); }
//!< Generic arithmatic inaccuracy. Only used to determine whether a transition really needs to insert an extra edge.
inline coord_t snap_dist() { return scaled<coord_t>(0.02); }

/*!
* The strategy to use to fill a certain shape with lines.
Expand Down
14 changes: 7 additions & 7 deletions src/libslic3r/Arachne/WallToolPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void fixSelfIntersections(const coord_t epsilon, Polygons &thiss)

// Points too close to line segments should be moved a little away from those line segments, but less than epsilon,
// so at least half-epsilon distance between points can still be guaranteed.
constexpr coord_t grid_size = scaled<coord_t>(2.);
const coord_t grid_size = scaled<coord_t>(2.);
auto query_grid = createLocToLineGrid(thiss, grid_size);

const auto move_dist = std::max<int64_t>(2L, half_epsilon - 2);
Expand Down Expand Up @@ -473,11 +473,11 @@ const std::vector<VariableWidthLines> &WallToolPaths::generate()
if (this->inset_count < 1)
return toolpaths;

const coord_t smallest_segment = Slic3r::Arachne::meshfix_maximum_resolution;
const coord_t allowed_distance = Slic3r::Arachne::meshfix_maximum_deviation;
const coord_t smallest_segment = Slic3r::Arachne::meshfix_maximum_resolution();
const coord_t allowed_distance = Slic3r::Arachne::meshfix_maximum_deviation();
const coord_t epsilon_offset = (allowed_distance / 2) - 1;
const double transitioning_angle = Geometry::deg2rad(m_params.wall_transition_angle);
constexpr coord_t discretization_step_size = scaled<coord_t>(0.8);
const coord_t discretization_step_size = scaled<coord_t>(0.8);

// Simplify outline for boost::voronoi consumption. Absolutely no self intersections or near-self intersections allowed:
// TODO: Open question: Does this indeed fix all (or all-but-one-in-a-million) cases for manifold but otherwise possibly complex polygons?
Expand Down Expand Up @@ -692,9 +692,9 @@ void WallToolPaths::simplifyToolPaths(std::vector<VariableWidthLines> &toolpaths
{
for (size_t toolpaths_idx = 0; toolpaths_idx < toolpaths.size(); ++toolpaths_idx)
{
const int64_t maximum_resolution = Slic3r::Arachne::meshfix_maximum_resolution;
const int64_t maximum_deviation = Slic3r::Arachne::meshfix_maximum_deviation;
const int64_t maximum_extrusion_area_deviation = Slic3r::Arachne::meshfix_maximum_extrusion_area_deviation; // unit: μm²
const int64_t maximum_resolution = Slic3r::Arachne::meshfix_maximum_resolution();
const int64_t maximum_deviation = Slic3r::Arachne::meshfix_maximum_deviation();
const int64_t maximum_extrusion_area_deviation = Slic3r::Arachne::meshfix_maximum_extrusion_area_deviation(); // unit: μm²
for (auto& line : toolpaths[toolpaths_idx])
{
line.simplify(maximum_resolution * maximum_resolution, maximum_deviation * maximum_deviation, maximum_extrusion_area_deviation);
Expand Down
6 changes: 3 additions & 3 deletions src/libslic3r/Arachne/WallToolPaths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace Slic3r::Arachne
{

constexpr bool fill_outline_gaps = true;
constexpr coord_t meshfix_maximum_resolution = scaled<coord_t>(0.5);
constexpr coord_t meshfix_maximum_deviation = scaled<coord_t>(0.025);
constexpr coord_t meshfix_maximum_extrusion_area_deviation = scaled<coord_t>(2.);
inline coord_t meshfix_maximum_resolution() { return scaled<coord_t>(0.5); }
inline coord_t meshfix_maximum_deviation() { return scaled<coord_t>(0.025); }
inline coord_t meshfix_maximum_extrusion_area_deviation() { return scaled<coord_t>(2.); }

class WallToolPathsParams
{
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ set(lisbslic3r_sources
Layer.hpp
LayerRegion.cpp
libslic3r.h
libslic3r.cpp
Line.cpp
Line.hpp
BlacklistedLibraryCheck.cpp
Expand Down
14 changes: 8 additions & 6 deletions src/libslic3r/Fill/Lightning/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const Layer& Generator::getTreesForLayer(const size_t& layer_id) const

void Generator::generateTrees(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
{
const auto _locator_cell_size = locator_cell_size();
m_lightning_layers.resize(print_object.layers().size());
bboxs.resize(print_object.layers().size());
std::vector<Polygons> infill_outlines(print_object.layers().size(), Polygons());
Expand All @@ -193,7 +194,7 @@ void Generator::generateTrees(const PrintObject &print_object, const std::functi
// For various operations its beneficial to quickly locate nearby features on the polygon:
const size_t top_layer_id = print_object.layers().size() - 1;
EdgeGrid::Grid outlines_locator(get_extents(infill_outlines[top_layer_id]).inflated(SCALED_EPSILON));
outlines_locator.create(infill_outlines[top_layer_id], locator_cell_size);
outlines_locator.create(infill_outlines[top_layer_id], _locator_cell_size);

// For-each layer from top to bottom:
for (int layer_id = int(top_layer_id); layer_id >= 0; layer_id--) {
Expand Down Expand Up @@ -223,11 +224,11 @@ void Generator::generateTrees(const PrintObject &print_object, const std::functi
below_outlines_bbox.merge(get_extents(current_lightning_layer.tree_roots).inflated(SCALED_EPSILON));

outlines_locator.set_bbox(below_outlines_bbox);
outlines_locator.create(below_outlines, locator_cell_size);
outlines_locator.create(below_outlines, _locator_cell_size);

std::vector<NodeSPtr>& lower_trees = m_lightning_layers[layer_id - 1].tree_roots;
for (auto& tree : current_lightning_layer.tree_roots)
tree->propagateToNextLayer(lower_trees, below_outlines, outlines_locator, m_prune_length, m_straightening_max_distance, locator_cell_size / 2);
tree->propagateToNextLayer(lower_trees, below_outlines, outlines_locator, m_prune_length, m_straightening_max_distance, _locator_cell_size / 2);
}
}

Expand All @@ -238,10 +239,11 @@ void Generator::generateTreesforSupport(std::vector<Polygons>& contours, const s
m_lightning_layers.resize(contours.size());
bboxs.resize(contours.size());

const auto _locator_cell_size = locator_cell_size();
// For various operations its beneficial to quickly locate nearby features on the polygon:
const size_t top_layer_id = contours.size() - 1;
EdgeGrid::Grid outlines_locator(get_extents(contours[top_layer_id]).inflated(SCALED_EPSILON));
outlines_locator.create(contours[top_layer_id], locator_cell_size);
outlines_locator.create(contours[top_layer_id], _locator_cell_size);

// For-each layer from top to bottom:
for (int layer_id = int(top_layer_id); layer_id >= 0; layer_id--) {
Expand Down Expand Up @@ -271,11 +273,11 @@ void Generator::generateTreesforSupport(std::vector<Polygons>& contours, const s
below_outlines_bbox.merge(get_extents(current_lightning_layer.tree_roots).inflated(SCALED_EPSILON));

outlines_locator.set_bbox(below_outlines_bbox);
outlines_locator.create(below_outlines, locator_cell_size);
outlines_locator.create(below_outlines, _locator_cell_size);

std::vector<NodeSPtr>& lower_trees = m_lightning_layers[layer_id - 1].tree_roots;
for (auto& tree : current_lightning_layer.tree_roots)
tree->propagateToNextLayer(lower_trees, below_outlines, outlines_locator, m_prune_length, m_straightening_max_distance, locator_cell_size / 2);
tree->propagateToNextLayer(lower_trees, below_outlines, outlines_locator, m_prune_length, m_straightening_max_distance, _locator_cell_size / 2);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/Fill/Lightning/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Point GroundingLocation::p() const

inline static Point to_grid_point(const Point &point, const BoundingBox &bbox)
{
return (point - bbox.min) / locator_cell_size;
return (point - bbox.min) / locator_cell_size();
}

void Layer::fillLocator(SparseNodeGrid &tree_node_locator, const BoundingBox& current_outlines_bbox)
Expand Down Expand Up @@ -150,7 +150,7 @@ GroundingLocation Layer::getBestGroundingLocation
coord_t current_dist = getWeightedDistance(node_location, unsupported_location);
if (current_dist >= wall_supporting_radius) { // Only reconnect tree roots to other trees if they are not already close to the outlines.
const coord_t search_radius = std::min(current_dist, within_dist);
BoundingBox region(unsupported_location - Point(search_radius, search_radius), unsupported_location + Point(search_radius + locator_cell_size, search_radius + locator_cell_size));
BoundingBox region(unsupported_location - Point(search_radius, search_radius), unsupported_location + Point(search_radius + locator_cell_size(), search_radius + locator_cell_size()));
region.min = to_grid_point(region.min, current_outlines_bbox);
region.max = to_grid_point(region.max, current_outlines_bbox);

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/Lightning/TreeNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace Slic3r::FillLightning
{

constexpr auto locator_cell_size = scaled<coord_t>(4.);
inline coord_t locator_cell_size() { return scaled<coord_t>(4.); }

class Node;

Expand Down
5 changes: 1 addition & 4 deletions src/libslic3r/GCode/ConflictChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ namespace RasterizationImpl {
using IndexPair = std::pair<int64_t, int64_t>;
using Grids = std::vector<IndexPair>;

inline constexpr int64_t RasteXDistance = scale_(1);
inline constexpr int64_t RasteYDistance = scale_(1);

inline IndexPair point_map_grid_index(const Point &pt, int64_t xdist, int64_t ydist)
{
auto x = pt.x() / xdist;
Expand All @@ -25,7 +22,7 @@ inline IndexPair point_map_grid_index(const Point &pt, int64_t xdist, int64_t yd

inline bool nearly_equal(const Point &p1, const Point &p2) { return std::abs(p1.x() - p2.x()) < SCALED_EPSILON && std::abs(p1.y() - p2.y()) < SCALED_EPSILON; }

inline Grids line_rasterization(const Line &line, int64_t xdist = RasteXDistance, int64_t ydist = RasteYDistance)
inline Grids line_rasterization(const Line &line, int64_t xdist = scale_(1), int64_t ydist = scale_(1))
{
Grids res;
Point rayStart = line.a;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/LayerRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
float expansion_bottom = expansion_top;
float expansion_bottom_bridge = expansion_top;
// Expand by waves of expansion_step size (expansion_step is scaled), but with no more steps than max_nr_expansion_steps.
static constexpr const float expansion_step = scaled<float>(0.1);
const auto expansion_step = scaled<float>(0.1);
// Don't take more than max_nr_steps for small expansion_step.
static constexpr const size_t max_nr_expansion_steps = 5;
// Radius (with added epsilon) to absorb empty regions emering from regularization of ensuring, viz const float narrow_ensure_vertical_wall_thickness_region_radius = 0.5f * 0.65f * min_perimeter_infill_spacing;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ void PrintObject::clip_fill_surfaces()
}
// Merge the new overhangs, find new internal infill.
polygons_append(upper_internal, std::move(overhangs));
static constexpr const auto closing_radius = scaled<float>(2.f);
const auto closing_radius = scaled<float>(2.f);
upper_internal = intersection(
// Regularize the overhang regions, so that the infill areas will not become excessively jagged.
smooth_outward(
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/Support/TreeModelVolumes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace FFFTreeSupport
{

static constexpr const double SUPPORT_TREE_EXPONENTIAL_FACTOR = 1.5;
static constexpr const coord_t SUPPORT_TREE_EXPONENTIAL_THRESHOLD = scaled<coord_t>(1. * SUPPORT_TREE_EXPONENTIAL_FACTOR);
static constexpr const coord_t SUPPORT_TREE_COLLISION_RESOLUTION = scaled<coord_t>(0.5);
#define SUPPORT_TREE_EXPONENTIAL_THRESHOLD scaled<coord_t>(1. * SUPPORT_TREE_EXPONENTIAL_FACTOR)
#define SUPPORT_TREE_COLLISION_RESOLUTION scaled<coord_t>(0.5)
static constexpr const bool SUPPORT_TREE_AVOID_SUPPORT_BLOCKER = true;

class TreeModelVolumes
Expand Down
Loading

0 comments on commit 5daecf3

Please sign in to comment.