mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
switch res for large printer
This commit is contained in:
parent
3e9a46c5bb
commit
5daecf3583
21 changed files with 92 additions and 62 deletions
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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
|
||||
)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
@ -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?
|
||||
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -211,6 +211,7 @@ set(lisbslic3r_sources
|
|||
Layer.hpp
|
||||
LayerRegion.cpp
|
||||
libslic3r.h
|
||||
libslic3r.cpp
|
||||
Line.cpp
|
||||
Line.hpp
|
||||
BlacklistedLibraryCheck.cpp
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -474,7 +474,7 @@ static std::optional<std::pair<Point, size_t>> polyline_sample_next_point_at_dis
|
|||
{
|
||||
const double dist2 = sqr(dist);
|
||||
const auto dist2i = int64_t(dist2);
|
||||
static constexpr const auto eps = scaled<double>(0.01);
|
||||
const auto eps = scaled<double>(0.01);
|
||||
|
||||
for (size_t i = start_idx + 1; i < polyline.size(); ++ i) {
|
||||
const Point p1 = polyline[i];
|
||||
|
@ -836,6 +836,9 @@ public:
|
|||
{
|
||||
m_already_inserted.assign(num_support_layers, {});
|
||||
this->min_xy_dist = this->config.xy_distance > this->config.xy_min_distance;
|
||||
m_base_radius = scaled<coord_t>(0.01);
|
||||
m_base_circle = Polygon{ make_circle(m_base_radius, SUPPORT_TREE_CIRCLE_RESOLUTION) };
|
||||
|
||||
}
|
||||
const TreeModelVolumes &volumes;
|
||||
// Radius of the tree tip is large enough to be covered by an interface.
|
||||
|
@ -971,8 +974,8 @@ private:
|
|||
std::vector<SupportElements> &move_bounds;
|
||||
|
||||
// Temps
|
||||
static constexpr const auto m_base_radius = scaled<coord_t>(0.01);
|
||||
const Polygon m_base_circle { make_circle(m_base_radius, SUPPORT_TREE_CIRCLE_RESOLUTION) };
|
||||
coord_t m_base_radius;
|
||||
Polygon m_base_circle;
|
||||
|
||||
// Mutexes, guards
|
||||
std::mutex m_mutex_movebounds;
|
||||
|
@ -1567,6 +1570,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
current_elem.effective_radius_height += 1;
|
||||
coord_t radius = support_element_collision_radius(config, current_elem);
|
||||
|
||||
const auto _tiny_area_threshold = tiny_area_threshold();
|
||||
if (settings.move) {
|
||||
increased = relevant_offset;
|
||||
if (overspeed > 0) {
|
||||
|
@ -1587,7 +1591,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
|
||||
if (mergelayer || current_elem.to_buildplate) {
|
||||
to_bp_data = safe_union(diff_clipped(increased, volumes.getAvoidance(radius, layer_idx - 1, settings.type, false, settings.use_min_distance)));
|
||||
if (! current_elem.to_buildplate && area(to_bp_data) > tiny_area_threshold) {
|
||||
if (! current_elem.to_buildplate && area(to_bp_data) > _tiny_area_threshold) {
|
||||
// mostly happening in the tip, but with merges one should check every time, just to be sure.
|
||||
current_elem.to_buildplate = true; // sometimes nodes that can reach the buildplate are marked as cant reach, tainting subtrees. This corrects it.
|
||||
BOOST_LOG_TRIVIAL(debug) << "Corrected taint leading to a wrong to model value on layer " << layer_idx - 1 << " targeting " <<
|
||||
|
@ -1599,7 +1603,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
to_model_data = safe_union(diff_clipped(increased, volumes.getAvoidance(radius, layer_idx - 1, settings.type, true, settings.use_min_distance)));
|
||||
|
||||
if (!current_elem.to_model_gracious) {
|
||||
if (mergelayer && area(to_model_data) >= tiny_area_threshold) {
|
||||
if (mergelayer && area(to_model_data) >= _tiny_area_threshold) {
|
||||
current_elem.to_model_gracious = true;
|
||||
BOOST_LOG_TRIVIAL(debug) << "Corrected taint leading to a wrong non gracious value on layer " << layer_idx - 1 << " targeting " <<
|
||||
current_elem.target_height << " with radius " << radius;
|
||||
|
@ -1611,7 +1615,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
|
||||
check_layer_data = current_elem.to_buildplate ? to_bp_data : to_model_data;
|
||||
|
||||
if (settings.increase_radius && area(check_layer_data) > tiny_area_threshold) {
|
||||
if (settings.increase_radius && area(check_layer_data) > _tiny_area_threshold) {
|
||||
auto validWithRadius = [&](coord_t next_radius) {
|
||||
if (volumes.ceilRadius(next_radius, settings.use_min_distance) <= volumes.ceilRadius(radius, settings.use_min_distance))
|
||||
return true;
|
||||
|
@ -1627,7 +1631,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
volumes.getAvoidance(next_radius, layer_idx - 1, settings.type, true, settings.use_min_distance) :
|
||||
volumes.getCollision(next_radius, layer_idx - 1, settings.use_min_distance));
|
||||
Polygons check_layer_data_2 = current_elem.to_buildplate ? to_bp_data_2 : to_model_data_2;
|
||||
return area(check_layer_data_2) > tiny_area_threshold;
|
||||
return area(check_layer_data_2) > _tiny_area_threshold;
|
||||
};
|
||||
coord_t ceil_radius_before = volumes.ceilRadius(radius, settings.use_min_distance);
|
||||
|
||||
|
@ -1670,7 +1674,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
volumes.getCollision(radius, layer_idx - 1, settings.use_min_distance)
|
||||
));
|
||||
check_layer_data = current_elem.to_buildplate ? to_bp_data : to_model_data;
|
||||
if (area(check_layer_data) < tiny_area_threshold) {
|
||||
if (area(check_layer_data) < _tiny_area_threshold) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Lost area by doing catch up from " << ceil_radius_before << " to radius " <<
|
||||
volumes.ceilRadius(support_element_collision_radius(config, current_elem), settings.use_min_distance);
|
||||
tree_supports_show_error("Area lost catching up radius. May not cause visible malformation."sv, true);
|
||||
|
@ -1678,7 +1682,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||
}
|
||||
}
|
||||
|
||||
return area(check_layer_data) > tiny_area_threshold ? std::optional<SupportElementState>(current_elem) : std::optional<SupportElementState>();
|
||||
return area(check_layer_data) > _tiny_area_threshold ? std::optional<SupportElementState>(current_elem) : std::optional<SupportElementState>();
|
||||
}
|
||||
|
||||
struct SupportElementInfluenceAreas {
|
||||
|
@ -2147,13 +2151,14 @@ static bool merge_influence_areas_two_elements(
|
|||
merging_to_bp ? smaller_rad.areas.to_bp_areas : smaller_rad.areas.to_model_areas,
|
||||
merging_to_bp ? bigger_rad.areas.to_bp_areas : bigger_rad.areas.to_model_areas);
|
||||
|
||||
const auto _tiny_area_threshold = tiny_area_threshold();
|
||||
// dont use empty as a line is not empty, but for this use-case it very well may be (and would be one layer down as union does not keep lines)
|
||||
// check if the overlap is large enough (Small ares tend to attract rounding errors in clipper).
|
||||
if (area(intersect) <= tiny_area_threshold)
|
||||
if (area(intersect) <= _tiny_area_threshold)
|
||||
return false;
|
||||
|
||||
// While 0.025 was guessed as enough, i did not have reason to change it.
|
||||
if (area(offset(intersect, scaled<float>(-0.025), jtMiter, 1.2)) <= tiny_area_threshold)
|
||||
if (area(offset(intersect, scaled<float>(-0.025), jtMiter, 1.2)) <= _tiny_area_threshold)
|
||||
return false;
|
||||
|
||||
#ifdef TREES_MERGE_RATHER_LATER
|
||||
|
@ -2417,6 +2422,7 @@ static void create_layer_pathing(const TreeModelVolumes &volumes, const TreeSupp
|
|||
|
||||
LayerIndex last_merge_layer_idx = move_bounds.size();
|
||||
bool new_element = false;
|
||||
const auto _tiny_area_threshold = tiny_area_threshold();
|
||||
|
||||
// Ensures at least one merge operation per 3mm height, 50 layers, 1 mm movement of slow speed or 5mm movement of fast speed (whatever is lowest). Values were guessed.
|
||||
size_t max_merge_every_x_layers = std::min(std::min(5000 / (std::max(config.maximum_move_distance, coord_t(100))), 1000 / std::max(config.maximum_move_distance_slow, coord_t(20))), 3000 / config.layer_height);
|
||||
|
@ -2447,12 +2453,12 @@ static void create_layer_pathing(const TreeModelVolumes &volumes, const TreeSupp
|
|||
// Place already fully constructed elements to the output, remove them from influence_areas.
|
||||
SupportElements &this_layer = move_bounds[layer_idx - 1];
|
||||
influence_areas.erase(std::remove_if(influence_areas.begin(), influence_areas.end(),
|
||||
[&this_layer, layer_idx](SupportElementMerging &elem) {
|
||||
[&this_layer, &_tiny_area_threshold, layer_idx](SupportElementMerging &elem) {
|
||||
if (elem.areas.influence_areas.empty())
|
||||
// This area was removed completely due to collisions.
|
||||
return true;
|
||||
if (elem.areas.to_bp_areas.empty() && elem.areas.to_model_areas.empty()) {
|
||||
if (area(elem.areas.influence_areas) < tiny_area_threshold) {
|
||||
if (area(elem.areas.influence_areas) < _tiny_area_threshold) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Insert Error of Influence area bypass on layer " << layer_idx - 1;
|
||||
tree_supports_show_error("Insert error of area after bypassing merge.\n"sv, true);
|
||||
}
|
||||
|
@ -2485,7 +2491,7 @@ static void create_layer_pathing(const TreeModelVolumes &volumes, const TreeSupp
|
|||
for (SupportElementMerging &elem : influence_areas)
|
||||
if (! elem.areas.influence_areas.empty()) {
|
||||
Polygons new_area = safe_union(elem.areas.influence_areas);
|
||||
if (area(new_area) < tiny_area_threshold) {
|
||||
if (area(new_area) < _tiny_area_threshold) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Insert Error of Influence area on layer " << layer_idx - 1 << ". Origin of " << elem.parents.size() << " areas. Was to bp " << elem.state.to_buildplate;
|
||||
tree_supports_show_error("Insert error of area after merge.\n"sv, true);
|
||||
}
|
||||
|
@ -3050,6 +3056,7 @@ static void drop_non_gracious_areas(
|
|||
std::vector<Polygons> &support_layer_storage,
|
||||
std::function<void()> throw_on_cancel)
|
||||
{
|
||||
const auto _tiny_area_threshold = tiny_area_threshold();
|
||||
std::vector<std::vector<std::pair<LayerIndex, Polygons>>> dropped_down_areas(linear_data.size());
|
||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, linear_data.size()),
|
||||
[&](const tbb::blocked_range<size_t> &range) {
|
||||
|
@ -3058,7 +3065,7 @@ static void drop_non_gracious_areas(
|
|||
if (const DrawArea &draw_element = linear_data[idx]; ! draw_element.element->state.to_model_gracious && draw_element.child_element == nullptr) {
|
||||
Polygons rest_support;
|
||||
const LayerIndex layer_idx_first = draw_element.element->state.layer_idx - 1;
|
||||
for (LayerIndex layer_idx = layer_idx_first; area(rest_support) > tiny_area_threshold && layer_idx >= 0; -- layer_idx) {
|
||||
for (LayerIndex layer_idx = layer_idx_first; area(rest_support) > _tiny_area_threshold && layer_idx >= 0; -- layer_idx) {
|
||||
rest_support = diff_clipped(layer_idx == layer_idx_first ? draw_element.polygons : rest_support, volumes.getCollision(0, layer_idx, false));
|
||||
dropped_down_areas[idx].emplace_back(layer_idx, rest_support);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ static inline void check_self_intersections(const ExPolygon &expoly, const std::
|
|||
#endif // TREE_SUPPORT_SHOW_ERRORS_WIN32
|
||||
}
|
||||
|
||||
static constexpr const auto tiny_area_threshold = sqr(scaled<double>(0.001));
|
||||
// static constexpr const auto tiny_area_threshold = sqr(scaled<double>(0.001));
|
||||
|
||||
static std::vector<std::pair<TreeSupportSettings, std::vector<size_t>>> group_meshes(const Print &print, const std::vector<size_t> &print_object_ids)
|
||||
{
|
||||
|
|
|
@ -452,7 +452,7 @@ private:
|
|||
|
||||
static constexpr const bool polygons_strictly_simple = false;
|
||||
|
||||
static constexpr const auto tiny_area_threshold = sqr(scaled<double>(0.001));
|
||||
inline double tiny_area_threshold() { return sqr(scaled<double>(0.001)); }
|
||||
|
||||
void tree_supports_show_error(std::string_view message, bool critical);
|
||||
|
||||
|
|
|
@ -1832,7 +1832,7 @@ static void make_expolygons(const Polygons &loops, const float closing_radius, c
|
|||
static inline Transform3f make_trafo_for_slicing(const Transform3d &trafo)
|
||||
{
|
||||
auto t = trafo;
|
||||
static constexpr const double s = 1. / SCALING_FACTOR;
|
||||
const double s = 1. / SCALING_FACTOR;
|
||||
t.prescale(Vec3d(s, s, 1.));
|
||||
return t.cast<float>();
|
||||
}
|
||||
|
@ -1846,7 +1846,7 @@ static std::vector<stl_vertex> transform_mesh_vertices_for_slicing(const indexed
|
|||
{
|
||||
// Copy and scale vertices in XY, don't scale in Z.
|
||||
// Possibly apply the transformation.
|
||||
static constexpr const double s = 1. / SCALING_FACTOR;
|
||||
const double s = 1. / SCALING_FACTOR;
|
||||
std::vector<stl_vertex> out(mesh.vertices);
|
||||
if (is_identity(trafo)) {
|
||||
// Identity.
|
||||
|
|
3
src/libslic3r/libslic3r.cpp
Normal file
3
src/libslic3r/libslic3r.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "libslic3r.h"
|
||||
|
||||
double SCALING_FACTOR = SCALING_FACTOR_INTERNAL;
|
|
@ -55,7 +55,13 @@ static constexpr double EPSILON = 1e-4;
|
|||
// 0..4294mm with 1nm resolution
|
||||
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
|
||||
// with int64_t we don't have to worry anymore about the size of the int.
|
||||
static constexpr double SCALING_FACTOR = 0.000001;
|
||||
|
||||
// Orca todo: might be better to use 1e-5 for all, namometer resolution is not needed for 3D printing
|
||||
static constexpr double SCALING_FACTOR_INTERNAL = 0.000001;
|
||||
static constexpr double SCALING_FACTOR_INTERNAL_LARGE_PRINTER = 0.00001;
|
||||
static constexpr double LARGE_BED_THRESHOLD = 2147;
|
||||
|
||||
extern double SCALING_FACTOR;
|
||||
// for creating circles (for brim_ear)
|
||||
#define POLY_SIDES 24
|
||||
static constexpr double PI = 3.141592653589793238;
|
||||
|
|
|
@ -84,9 +84,9 @@ wxString last_used_directory = wxEmptyString;
|
|||
/// <returns>File path to svg</returns>
|
||||
std::string choose_svg_file();
|
||||
|
||||
constexpr double get_tesselation_tolerance(double scale){
|
||||
constexpr double tesselation_tolerance_in_mm = .1; //8e-2;
|
||||
constexpr double tesselation_tolerance_scaled = (tesselation_tolerance_in_mm*tesselation_tolerance_in_mm) / SCALING_FACTOR / SCALING_FACTOR;
|
||||
double get_tesselation_tolerance(double scale){
|
||||
double tesselation_tolerance_in_mm = .1; //8e-2;
|
||||
double tesselation_tolerance_scaled = (tesselation_tolerance_in_mm*tesselation_tolerance_in_mm) / SCALING_FACTOR / SCALING_FACTOR;
|
||||
return tesselation_tolerance_scaled / scale / scale;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,10 @@ namespace Slic3r {
|
|||
|
||||
namespace GUI {
|
||||
|
||||
constexpr double min_delta_area = scale_(scale_(25)); // equal to 25 mm2
|
||||
constexpr double miscalculation = scale_(scale_(1)); // equal to 1 mm2
|
||||
// equal to 25 mm2
|
||||
inline double min_delta_area() { return scale_(scale_(25)); }
|
||||
// equal to 1 mm2
|
||||
inline double miscalculation() { return scale_(scale_(1)); }
|
||||
|
||||
static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar
|
||||
static const float HORIZONTAL_SLIDER_WINDOW_HEIGHT = 64.0f;
|
||||
|
@ -33,7 +35,7 @@ static ImVec4 m_tick_rect;
|
|||
|
||||
bool equivalent_areas(const double& bottom_area, const double& top_area)
|
||||
{
|
||||
return fabs(bottom_area - top_area) <= miscalculation;
|
||||
return fabs(bottom_area - top_area) <= miscalculation();
|
||||
}
|
||||
|
||||
bool check_color_change(PrintObject *object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function<bool(Layer *)> break_condition)
|
||||
|
@ -50,7 +52,7 @@ bool check_color_change(PrintObject *object, size_t frst_layer_id, size_t layers
|
|||
|
||||
// Check percent of the area decrease.
|
||||
// This value have to be more than min_delta_area and more then 10%
|
||||
if ((prev_area - cur_area > min_delta_area) && (cur_area / prev_area < 0.9)) {
|
||||
if ((prev_area - cur_area > min_delta_area()) && (cur_area / prev_area < 0.9)) {
|
||||
detected = true;
|
||||
if (break_condition(layer)) break;
|
||||
}
|
||||
|
|
|
@ -7972,6 +7972,13 @@ bool Plater::priv::show_publish_dlg(bool show)
|
|||
//BBS: add bed exclude area
|
||||
void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_areas, const double printable_height, const std::string& custom_texture, const std::string& custom_model, bool force_as_custom)
|
||||
{
|
||||
//Orca: reduce resolution for large bed printer
|
||||
BoundingBoxf bed_size = get_extents(shape);
|
||||
if (bed_size.size().maxCoeff() <= LARGE_BED_THRESHOLD)
|
||||
SCALING_FACTOR = SCALING_FACTOR_INTERNAL;
|
||||
else
|
||||
SCALING_FACTOR = SCALING_FACTOR_INTERNAL_LARGE_PRINTER;
|
||||
|
||||
//BBS: add shape position
|
||||
Vec2d shape_position = partplate_list.get_current_shape_position();
|
||||
bool new_shape = bed.set_shape(shape, printable_height, custom_model, force_as_custom, shape_position);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue