mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
ENH: add rectilinear interface pattern for organic support
1. add rectilinear interface pattern for organic support jira: STUDIO-7181 2. add tree support optgroup Change-Id: I94882bc34a61c6adc06b8ecbc9f2323f9b039aac (cherry picked from commit a8142ab3f37e0bd140a31a7e635b8475f471d7e3) (cherry picked from commit 69cf816b9431bc21ca0187c7db1148e2d2e898ab)
This commit is contained in:
parent
f00bdfeca8
commit
532dcae37a
10 changed files with 130 additions and 230 deletions
|
@ -1,23 +1,27 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "MinimumSpanningTree.hpp"
|
||||
#include "TreeSupport.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "Layer.hpp"
|
||||
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Fill/FillBase.hpp"
|
||||
#include "Fill/FillBase.hpp"
|
||||
#include "Fill/FillConcentric.hpp"
|
||||
#include "CurveAnalyzer.hpp"
|
||||
#include "SVG.hpp"
|
||||
#include "ShortestPath.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "Layer.hpp"
|
||||
#include "MinimumSpanningTree.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "ShortestPath.hpp"
|
||||
#include "SupportCommon.hpp"
|
||||
#include "SVG.hpp"
|
||||
#include "TreeSupportCommon.hpp"
|
||||
#include "TreeSupport.hpp"
|
||||
#include "TreeSupport3D.hpp"
|
||||
#include <libnest2d/backends/libslic3r/geometries.hpp>
|
||||
#include <libnest2d/placers/nfpplacer.hpp>
|
||||
#include "TreeSupport3D.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <tbb/concurrent_vector.h>
|
||||
#include <tbb/concurrent_unordered_set.h>
|
||||
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/concurrent_unordered_set.h>
|
||||
#include <tbb/concurrent_vector.h>
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
|
@ -1646,28 +1650,25 @@ void TreeSupport::generate()
|
|||
m_ts_data = m_object->alloc_tree_support_preview_cache();
|
||||
m_ts_data->is_slim = is_slim;
|
||||
|
||||
// Generate contact points of tree support
|
||||
std::vector<std::vector<SupportNode*>> contact_nodes(m_object->layers().size());
|
||||
|
||||
std::vector<TreeSupport3D::SupportElements> move_bounds(m_highest_overhang_layer + 1);
|
||||
profiler.stage_start(STAGE_GENERATE_CONTACT_NODES);
|
||||
m_object->print()->set_status(56, _u8L("Support: generate contact points"));
|
||||
generate_contact_points(contact_nodes);
|
||||
generate_contact_points();
|
||||
profiler.stage_finish(STAGE_GENERATE_CONTACT_NODES);
|
||||
|
||||
|
||||
//Drop nodes to lower layers.
|
||||
profiler.stage_start(STAGE_DROP_DOWN_NODES);
|
||||
m_object->print()->set_status(60, _u8L("Generating support"));
|
||||
drop_nodes(contact_nodes);
|
||||
drop_nodes();
|
||||
profiler.stage_finish(STAGE_DROP_DOWN_NODES);
|
||||
|
||||
smooth_nodes(contact_nodes); // , tree_support_3d_config);
|
||||
smooth_nodes();// , tree_support_3d_config);
|
||||
|
||||
//Generate support areas.
|
||||
profiler.stage_start(STAGE_DRAW_CIRCLES);
|
||||
m_object->print()->set_status(65, _u8L("Generating support"));
|
||||
draw_circles(contact_nodes);
|
||||
draw_circles();
|
||||
profiler.stage_finish(STAGE_DRAW_CIRCLES);
|
||||
|
||||
|
||||
|
@ -1714,7 +1715,6 @@ coordf_t TreeSupport::calc_branch_radius(coordf_t base_radius, coordf_t mm_to_to
|
|||
{
|
||||
radius = mm_to_top;// this is a 45 degree tip
|
||||
}
|
||||
|
||||
radius = std::max(radius, MIN_BRANCH_RADIUS);
|
||||
radius = std::min(radius, MAX_BRANCH_RADIUS);
|
||||
// if have interface layers, radius should be larger
|
||||
|
@ -1876,7 +1876,7 @@ Polygons TreeSupport::get_trim_support_regions(
|
|||
return polygons_trimming;
|
||||
}
|
||||
|
||||
void TreeSupport::draw_circles(const std::vector<std::vector<SupportNode*>>& contact_nodes)
|
||||
void TreeSupport::draw_circles()
|
||||
{
|
||||
const PrintObjectConfig &config = m_object->config();
|
||||
const Print* print = m_object->print();
|
||||
|
@ -1980,11 +1980,11 @@ void TreeSupport::draw_circles(const std::vector<std::vector<SupportNode*>>& con
|
|||
}
|
||||
};
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "circles at layer " << layer_nr << " contact nodes size=" << contact_nodes[layer_nr].size();
|
||||
BOOST_LOG_TRIVIAL(debug) << "circles at layer " << layer_nr << " contact nodes size=" << curr_layer_nodes.size();
|
||||
//Draw the support areas and add the roofs appropriately to the support roof instead of normal areas.
|
||||
ts_layer->lslices.reserve(contact_nodes[layer_nr].size());
|
||||
ts_layer->lslices.reserve(curr_layer_nodes.size());
|
||||
ExPolygons area_poly; // the polygon node area which will be printed as normal support
|
||||
for (const SupportNode* p_node : contact_nodes[layer_nr])
|
||||
for (const SupportNode* p_node : curr_layer_nodes)
|
||||
{
|
||||
if (print->canceled())
|
||||
break;
|
||||
|
@ -2366,7 +2366,7 @@ void TreeSupport::draw_circles(const std::vector<std::vector<SupportNode*>>& con
|
|||
|
||||
double SupportNode::diameter_angle_scale_factor;
|
||||
|
||||
void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nodes)
|
||||
void TreeSupport::drop_nodes()
|
||||
{
|
||||
const PrintObjectConfig &config = m_object->config();
|
||||
// Use Minimum Spanning Tree to connect the points on each layer and move them while dropping them down.
|
||||
|
@ -2405,7 +2405,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nod
|
|||
return move_dist;
|
||||
};
|
||||
|
||||
m_ts_data->layer_heights = plan_layer_heights(contact_nodes);
|
||||
m_ts_data->layer_heights = plan_layer_heights();
|
||||
std::vector<LayerHeightData> &layer_heights = m_ts_data->layer_heights;
|
||||
if (layer_heights.empty()) return;
|
||||
|
||||
|
@ -2468,7 +2468,6 @@ void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nod
|
|||
coordf_t height_next = layer_heights[layer_nr_next].height;
|
||||
|
||||
std::deque<std::pair<size_t, SupportNode*>> unsupported_branch_leaves; // All nodes that are leaves on this layer that would result in unsupported ('mid-air') branches.
|
||||
const Layer* ts_layer = m_object->get_support_layer(layer_nr);
|
||||
|
||||
m_object->print()->set_status(60 + int(10 * (1 - float(layer_nr) / contact_nodes.size())), _u8L("Generating support"));// (boost::format(_u8L("Support: propagate branches at layer %d")) % layer_nr).str());
|
||||
|
||||
|
@ -2731,7 +2730,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nod
|
|||
// 1. do not merge neighbors under 5mm
|
||||
// 2. Only merge node with single neighbor in distance between [max_move_distance, 10mm/layer_height]
|
||||
float dist2_to_first_neighbor = neighbours.empty() ? 0 : vsize2_with_unscale(neighbours[0] - node.position);
|
||||
if (ts_layer->print_z > DO_NOT_MOVER_UNDER_MM &&
|
||||
if (node.print_z > DO_NOT_MOVER_UNDER_MM &&
|
||||
(neighbours.size() > 1 || (neighbours.size() == 1 && dist2_to_first_neighbor >= max_move_distance2))) // Only nodes that aren't about to collapse.
|
||||
{
|
||||
// Move towards the average position of all neighbours.
|
||||
|
@ -2747,7 +2746,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nod
|
|||
|
||||
coordf_t branch_bottom_radius = calc_branch_radius(branch_radius, node.dist_mm_to_top + node.print_z, diameter_angle_scale_factor);
|
||||
coordf_t neighbour_bottom_radius = calc_branch_radius(branch_radius, neighbour_node->dist_mm_to_top + neighbour_node->print_z, diameter_angle_scale_factor);
|
||||
double max_converge_distance = tan_angle * (ts_layer->print_z - DO_NOT_MOVER_UNDER_MM) + std::max(branch_bottom_radius, neighbour_bottom_radius);
|
||||
double max_converge_distance = tan_angle * (p_node->print_z - DO_NOT_MOVER_UNDER_MM) + std::max(branch_bottom_radius, neighbour_bottom_radius);
|
||||
if (dist2_to_neighbor > max_converge_distance * max_converge_distance) continue;
|
||||
|
||||
if (is_line_cut_by_contour(node.position, neighbour)) continue;
|
||||
|
@ -2892,7 +2891,7 @@ void TreeSupport::drop_nodes(std::vector<std::vector<SupportNode*>>& contact_nod
|
|||
BOOST_LOG_TRIVIAL(debug) << "after m_avoidance_cache.size()=" << m_ts_data->m_avoidance_cache.size();
|
||||
}
|
||||
|
||||
void TreeSupport::smooth_nodes(std::vector<std::vector<SupportNode *>> &contact_nodes)
|
||||
void TreeSupport::smooth_nodes()
|
||||
{
|
||||
for (int layer_nr = 0; layer_nr < contact_nodes.size(); layer_nr++) {
|
||||
std::vector<SupportNode *> &curr_layer_nodes = contact_nodes[layer_nr];
|
||||
|
@ -2963,7 +2962,7 @@ void TreeSupport::smooth_nodes(std::vector<std::vector<SupportNode *>> &contact_
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<LayerHeightData> TreeSupport::plan_layer_heights(std::vector<std::vector<SupportNode *>> &contact_nodes)
|
||||
std::vector<LayerHeightData> TreeSupport::plan_layer_heights()
|
||||
{
|
||||
std::vector<LayerHeightData> layer_heights(contact_nodes.size());
|
||||
std::map<int, std::pair<coordf_t,coordf_t>> bounds; // layer_nr:(print_z, height)
|
||||
|
@ -3061,7 +3060,7 @@ std::vector<LayerHeightData> TreeSupport::plan_layer_heights(std::vector<std::ve
|
|||
return layer_heights;
|
||||
}
|
||||
|
||||
void TreeSupport::generate_contact_points(std::vector<std::vector<SupportNode*>>& contact_nodes)
|
||||
void TreeSupport::generate_contact_points()
|
||||
{
|
||||
const PrintObjectConfig &config = m_object->config();
|
||||
const coordf_t point_spread = scale_(config.tree_support_branch_distance.value);
|
||||
|
@ -3119,8 +3118,11 @@ void TreeSupport::generate_contact_points(std::vector<std::vector<SupportNode*>>
|
|||
// fix bug of generating support for very thin objects
|
||||
if (m_object->layers().size() <= z_distance_top_layers + 1)
|
||||
return;
|
||||
//if (m_object->support_layer_count() <= m_raft_layers)
|
||||
// return;
|
||||
|
||||
contact_nodes.clear();
|
||||
contact_nodes.resize(m_object->layers().size());
|
||||
|
||||
tbb::spin_mutex mtx;
|
||||
|
||||
int nonempty_layers = 0;
|
||||
tbb::concurrent_vector<Slic3r::Vec3f> all_nodes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue