switch res for large printer

This commit is contained in:
SoftFever
2024-05-12 23:35:41 +08:00
parent 3e9a46c5bb
commit 5daecf3583
21 changed files with 92 additions and 62 deletions

View File

@@ -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());
@@ -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--) {
@@ -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);
}
}
@@ -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--) {
@@ -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);
}
}

View File

@@ -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)
@@ -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);

View File

@@ -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;