Organic supports:
Renamed diameter_angle_scale_factor -> branch_radius_increase_per_layer Renamed diameter_scale_bp_radius -> bp_radius_increase_per_layer and removed scaling by branch diameter.
This commit is contained in:
parent
055b0c1e52
commit
53d948f0d0
@ -257,6 +257,8 @@ void TreeModelVolumes::precalculate(const PrintObject& print_object, const coord
|
|||||||
auto it = radius_until_layer.find(r);
|
auto it = radius_until_layer.find(r);
|
||||||
if (it == radius_until_layer.end())
|
if (it == radius_until_layer.end())
|
||||||
radius_until_layer.emplace_hint(it, r, current_layer);
|
radius_until_layer.emplace_hint(it, r, current_layer);
|
||||||
|
else
|
||||||
|
assert(it->second >= current_layer);
|
||||||
};
|
};
|
||||||
// regular radius
|
// regular radius
|
||||||
update_radius_until_layer(ceilRadius(config.getRadius(distance_to_top, 0) + m_current_min_xy_dist_delta));
|
update_radius_until_layer(ceilRadius(config.getRadius(distance_to_top, 0) + m_current_min_xy_dist_delta));
|
||||||
|
@ -70,16 +70,17 @@ TreeSupportSettings::TreeSupportSettings(const TreeSupportMeshGroupSettings& mes
|
|||||||
maximum_move_distance_slow((angle_slow < M_PI / 2.) ? (coord_t)(tan(angle_slow) * layer_height) : std::numeric_limits<coord_t>::max()),
|
maximum_move_distance_slow((angle_slow < M_PI / 2.) ? (coord_t)(tan(angle_slow) * layer_height) : std::numeric_limits<coord_t>::max()),
|
||||||
support_bottom_layers(mesh_group_settings.support_bottom_enable ? (mesh_group_settings.support_bottom_height + layer_height / 2) / layer_height : 0),
|
support_bottom_layers(mesh_group_settings.support_bottom_enable ? (mesh_group_settings.support_bottom_height + layer_height / 2) / layer_height : 0),
|
||||||
tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)), // Ensure lines always stack nicely even if layer height is large
|
tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)), // Ensure lines always stack nicely even if layer height is large
|
||||||
diameter_angle_scale_factor(sin(mesh_group_settings.support_tree_branch_diameter_angle) * layer_height / branch_radius),
|
branch_radius_increase_per_layer(tan(mesh_group_settings.support_tree_branch_diameter_angle) * layer_height),
|
||||||
max_to_model_radius_increase(mesh_group_settings.support_tree_max_diameter_increase_by_merges_when_support_to_model / 2),
|
max_to_model_radius_increase(mesh_group_settings.support_tree_max_diameter_increase_by_merges_when_support_to_model / 2),
|
||||||
min_dtt_to_model(round_up_divide(mesh_group_settings.support_tree_min_height_to_model, layer_height)),
|
min_dtt_to_model(round_up_divide(mesh_group_settings.support_tree_min_height_to_model, layer_height)),
|
||||||
increase_radius_until_radius(mesh_group_settings.support_tree_branch_diameter / 2),
|
increase_radius_until_radius(mesh_group_settings.support_tree_branch_diameter / 2),
|
||||||
increase_radius_until_layer(increase_radius_until_radius <= branch_radius ? tip_layers * (increase_radius_until_radius / branch_radius) : (increase_radius_until_radius - branch_radius) / (branch_radius * diameter_angle_scale_factor)),
|
increase_radius_until_layer(increase_radius_until_radius <= branch_radius ? tip_layers * (increase_radius_until_radius / branch_radius) : (increase_radius_until_radius - branch_radius) / branch_radius_increase_per_layer),
|
||||||
support_rests_on_model(! mesh_group_settings.support_material_buildplate_only),
|
support_rests_on_model(! mesh_group_settings.support_material_buildplate_only),
|
||||||
xy_distance(mesh_group_settings.support_xy_distance),
|
xy_distance(mesh_group_settings.support_xy_distance),
|
||||||
xy_min_distance(std::min(mesh_group_settings.support_xy_distance, mesh_group_settings.support_xy_distance_overhang)),
|
xy_min_distance(std::min(mesh_group_settings.support_xy_distance, mesh_group_settings.support_xy_distance_overhang)),
|
||||||
bp_radius(mesh_group_settings.support_tree_bp_diameter / 2),
|
bp_radius(mesh_group_settings.support_tree_bp_diameter / 2),
|
||||||
diameter_scale_bp_radius(std::min(sin(0.7) * layer_height / branch_radius, 1.0 / (branch_radius / (support_line_width / 2.0)))), // Either 40? or as much as possible so that 2 lines will overlap by at least 50%, whichever is smaller.
|
// Increase by half a line overlap, but not faster than 40 degrees angle (0 degrees means zero increase in radius).
|
||||||
|
bp_radius_increase_per_layer(std::min(tan(0.7) * layer_height, 0.5 * support_line_width)),
|
||||||
z_distance_bottom_layers(size_t(round(double(mesh_group_settings.support_bottom_distance) / double(layer_height)))),
|
z_distance_bottom_layers(size_t(round(double(mesh_group_settings.support_bottom_distance) / double(layer_height)))),
|
||||||
z_distance_top_layers(size_t(round(double(mesh_group_settings.support_top_distance) / double(layer_height)))),
|
z_distance_top_layers(size_t(round(double(mesh_group_settings.support_top_distance) / double(layer_height)))),
|
||||||
performance_interface_skip_layers(round_up_divide(mesh_group_settings.support_interface_skip_height, layer_height)),
|
performance_interface_skip_layers(round_up_divide(mesh_group_settings.support_interface_skip_height, layer_height)),
|
||||||
@ -96,7 +97,7 @@ TreeSupportSettings::TreeSupportSettings(const TreeSupportMeshGroupSettings& mes
|
|||||||
settings(mesh_group_settings),
|
settings(mesh_group_settings),
|
||||||
min_feature_size(mesh_group_settings.min_feature_size)
|
min_feature_size(mesh_group_settings.min_feature_size)
|
||||||
{
|
{
|
||||||
layer_start_bp_radius = (bp_radius - branch_radius) / (branch_radius * diameter_scale_bp_radius);
|
layer_start_bp_radius = (bp_radius - branch_radius) / bp_radius_increase_per_layer;
|
||||||
|
|
||||||
if (TreeSupportSettings::soluble) {
|
if (TreeSupportSettings::soluble) {
|
||||||
// safeOffsetInc can only work in steps of the size xy_min_distance in the worst case => xy_min_distance has to be a bit larger than 0 in this worst case and should be large enough for performance to not suffer extremely
|
// safeOffsetInc can only work in steps of the size xy_min_distance in the worst case => xy_min_distance has to be a bit larger than 0 in this worst case and should be large enough for performance to not suffer extremely
|
||||||
@ -1857,7 +1858,7 @@ static Point move_inside_if_outside(const Polygons &polygons, Point from, int di
|
|||||||
}
|
}
|
||||||
radius = config.getCollisionRadius(current_elem);
|
radius = config.getCollisionRadius(current_elem);
|
||||||
|
|
||||||
const coord_t foot_radius_increase = config.branch_radius * (std::max(config.diameter_scale_bp_radius - config.diameter_angle_scale_factor, 0.0));
|
const coord_t foot_radius_increase = std::max(config.bp_radius_increase_per_layer - config.branch_radius_increase_per_layer, 0.0);
|
||||||
// Is nearly all of the time 1, but sometimes an increase of 1 could cause the radius to become bigger than recommendedMinRadius,
|
// Is nearly all of the time 1, but sometimes an increase of 1 could cause the radius to become bigger than recommendedMinRadius,
|
||||||
// which could cause the radius to become bigger than precalculated.
|
// which could cause the radius to become bigger than precalculated.
|
||||||
double planned_foot_increase = std::min(1.0, double(config.recommendedMinRadius(layer_idx - 1) - config.getRadius(current_elem)) / foot_radius_increase);
|
double planned_foot_increase = std::min(1.0, double(config.recommendedMinRadius(layer_idx - 1) - config.getRadius(current_elem)) / foot_radius_increase);
|
||||||
@ -2015,9 +2016,9 @@ static void increase_areas_one_layer(
|
|||||||
config.recommendedMinRadius(layer_idx - 1) < config.getRadius(elem.effective_radius_height + 1, elem.elephant_foot_increases)) {
|
config.recommendedMinRadius(layer_idx - 1) < config.getRadius(elem.effective_radius_height + 1, elem.elephant_foot_increases)) {
|
||||||
// can guarantee elephant foot radius increase
|
// can guarantee elephant foot radius increase
|
||||||
if (ceiled_parent_radius == volumes.ceilRadius(config.getRadius(parent.state.effective_radius_height + 1, parent.state.elephant_foot_increases + 1), parent.state.use_min_xy_dist))
|
if (ceiled_parent_radius == volumes.ceilRadius(config.getRadius(parent.state.effective_radius_height + 1, parent.state.elephant_foot_increases + 1), parent.state.use_min_xy_dist))
|
||||||
extra_speed += config.branch_radius * config.diameter_scale_bp_radius;
|
extra_speed += config.bp_radius_increase_per_layer;
|
||||||
else
|
else
|
||||||
extra_slow_speed += std::min(coord_t(config.branch_radius * config.diameter_scale_bp_radius),
|
extra_slow_speed += std::min(coord_t(config.bp_radius_increase_per_layer),
|
||||||
config.maximum_move_distance - (config.maximum_move_distance_slow + extra_slow_speed));
|
config.maximum_move_distance - (config.maximum_move_distance_slow + extra_slow_speed));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2236,11 +2237,11 @@ static void increase_areas_one_layer(
|
|||||||
out.to_model_gracious = first.to_model_gracious && second.to_model_gracious; // valid as we do not merge non-gracious with gracious
|
out.to_model_gracious = first.to_model_gracious && second.to_model_gracious; // valid as we do not merge non-gracious with gracious
|
||||||
|
|
||||||
out.elephant_foot_increases = 0;
|
out.elephant_foot_increases = 0;
|
||||||
if (config.diameter_scale_bp_radius > 0) {
|
if (config.bp_radius_increase_per_layer > 0) {
|
||||||
coord_t foot_increase_radius = std::abs(std::max(config.getCollisionRadius(second), config.getCollisionRadius(first)) - config.getCollisionRadius(out));
|
coord_t foot_increase_radius = std::abs(std::max(config.getCollisionRadius(second), config.getCollisionRadius(first)) - config.getCollisionRadius(out));
|
||||||
// elephant_foot_increases has to be recalculated, as when a smaller tree with a larger elephant_foot_increases merge with a larger branch
|
// elephant_foot_increases has to be recalculated, as when a smaller tree with a larger elephant_foot_increases merge with a larger branch
|
||||||
// the elephant_foot_increases may have to be lower as otherwise the radius suddenly increases. This results often in a non integer value.
|
// the elephant_foot_increases may have to be lower as otherwise the radius suddenly increases. This results often in a non integer value.
|
||||||
out.elephant_foot_increases = foot_increase_radius / (config.branch_radius * (config.diameter_scale_bp_radius - config.diameter_angle_scale_factor));
|
out.elephant_foot_increases = foot_increase_radius / (config.bp_radius_increase_per_layer - config.branch_radius_increase_per_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set last settings to the best out of both parents. If this is wrong, it will only cause a small performance penalty instead of weird behavior.
|
// set last settings to the best out of both parents. If this is wrong, it will only cause a small performance penalty instead of weird behavior.
|
||||||
|
@ -302,9 +302,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
size_t tip_layers;
|
size_t tip_layers;
|
||||||
/*!
|
/*!
|
||||||
* \brief Factor by which to increase the branch radius.
|
* \brief How much a branch radius increases with each layer to guarantee the prescribed tree widening.
|
||||||
*/
|
*/
|
||||||
double diameter_angle_scale_factor;
|
double branch_radius_increase_per_layer;
|
||||||
/*!
|
/*!
|
||||||
* \brief How much a branch resting on the model may grow in radius by merging with branches that can reach the buildplate.
|
* \brief How much a branch resting on the model may grow in radius by merging with branches that can reach the buildplate.
|
||||||
*/
|
*/
|
||||||
@ -330,17 +330,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
coord_t xy_distance;
|
coord_t xy_distance;
|
||||||
/*!
|
/*!
|
||||||
* \brief Radius a branch should have when reaching the buildplate.
|
* \brief A minimum radius a tree trunk should expand to at the buildplate if possible.
|
||||||
*/
|
*/
|
||||||
coord_t bp_radius;
|
coord_t bp_radius;
|
||||||
/*!
|
/*!
|
||||||
* \brief The layer index at which an increase in radius may be required to reach the bp_radius.
|
* \brief The layer index at which an increase in radius may be required to reach the bp_radius.
|
||||||
*/
|
*/
|
||||||
coord_t layer_start_bp_radius;
|
LayerIndex layer_start_bp_radius;
|
||||||
/*!
|
/*!
|
||||||
* \brief Factor by which to increase the branch radius to reach the required bp_radius at layer 0. Note that this radius increase will not happen in the tip, to ensure the tip is structurally sound.
|
* \brief How much one is allowed to increase the tree branch radius close to print bed to reach the required bp_radius at layer 0.
|
||||||
|
* Note that this radius increase will not happen in the tip, to ensure the tip is structurally sound.
|
||||||
*/
|
*/
|
||||||
double diameter_scale_bp_radius;
|
double bp_radius_increase_per_layer;
|
||||||
/*!
|
/*!
|
||||||
* \brief minimum xy_distance. Only relevant when Z overrides XY, otherwise equal to xy_distance-
|
* \brief minimum xy_distance. Only relevant when Z overrides XY, otherwise equal to xy_distance-
|
||||||
*/
|
*/
|
||||||
@ -418,7 +419,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool operator==(const TreeSupportSettings& other) const
|
bool operator==(const TreeSupportSettings& other) const
|
||||||
{
|
{
|
||||||
return branch_radius == other.branch_radius && tip_layers == other.tip_layers && diameter_angle_scale_factor == other.diameter_angle_scale_factor && layer_start_bp_radius == other.layer_start_bp_radius && bp_radius == other.bp_radius && diameter_scale_bp_radius == other.diameter_scale_bp_radius && min_radius == other.min_radius && xy_min_distance == other.xy_min_distance && // as a recalculation of the collision areas is required to set a new min_radius.
|
return branch_radius == other.branch_radius && tip_layers == other.tip_layers && branch_radius_increase_per_layer == other.branch_radius_increase_per_layer && layer_start_bp_radius == other.layer_start_bp_radius && bp_radius == other.bp_radius &&
|
||||||
|
// as a recalculation of the collision areas is required to set a new min_radius.
|
||||||
|
bp_radius_increase_per_layer == other.bp_radius_increase_per_layer && min_radius == other.min_radius && xy_min_distance == other.xy_min_distance &&
|
||||||
xy_distance - xy_min_distance == other.xy_distance - other.xy_min_distance && // if the delta of xy_min_distance and xy_distance is different the collision areas have to be recalculated.
|
xy_distance - xy_min_distance == other.xy_distance - other.xy_min_distance && // if the delta of xy_min_distance and xy_distance is different the collision areas have to be recalculated.
|
||||||
support_rests_on_model == other.support_rests_on_model && increase_radius_until_layer == other.increase_radius_until_layer && min_dtt_to_model == other.min_dtt_to_model && max_to_model_radius_increase == other.max_to_model_radius_increase && maximum_move_distance == other.maximum_move_distance && maximum_move_distance_slow == other.maximum_move_distance_slow && z_distance_bottom_layers == other.z_distance_bottom_layers && support_line_width == other.support_line_width &&
|
support_rests_on_model == other.support_rests_on_model && increase_radius_until_layer == other.increase_radius_until_layer && min_dtt_to_model == other.min_dtt_to_model && max_to_model_radius_increase == other.max_to_model_radius_increase && maximum_move_distance == other.maximum_move_distance && maximum_move_distance_slow == other.maximum_move_distance_slow && z_distance_bottom_layers == other.z_distance_bottom_layers && support_line_width == other.support_line_width &&
|
||||||
support_line_spacing == other.support_line_spacing && support_roof_line_width == other.support_roof_line_width && // can not be set on a per-mesh basis currently, so code to enable processing different roof line width in the same iteration seems useless.
|
support_line_spacing == other.support_line_spacing && support_roof_line_width == other.support_roof_line_width && // can not be set on a per-mesh basis currently, so code to enable processing different roof line width in the same iteration seems useless.
|
||||||
@ -470,9 +473,9 @@ public:
|
|||||||
{
|
{
|
||||||
return (distance_to_top <= tip_layers ? min_radius + (branch_radius - min_radius) * distance_to_top / tip_layers : // tip
|
return (distance_to_top <= tip_layers ? min_radius + (branch_radius - min_radius) * distance_to_top / tip_layers : // tip
|
||||||
branch_radius + // base
|
branch_radius + // base
|
||||||
branch_radius * (distance_to_top - tip_layers) * diameter_angle_scale_factor)
|
(distance_to_top - tip_layers) * branch_radius_increase_per_layer)
|
||||||
+ // gradual increase
|
+ // gradual increase
|
||||||
branch_radius * elephant_foot_increases * (std::max(diameter_scale_bp_radius - diameter_angle_scale_factor, 0.0));
|
elephant_foot_increases * (std::max(bp_radius_increase_per_layer - branch_radius_increase_per_layer, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -502,8 +505,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] inline coord_t recommendedMinRadius(LayerIndex layer_idx) const
|
[[nodiscard]] inline coord_t recommendedMinRadius(LayerIndex layer_idx) const
|
||||||
{
|
{
|
||||||
double scale = (layer_start_bp_radius - int(layer_idx)) * diameter_scale_bp_radius;
|
double num_layers_widened = layer_start_bp_radius - layer_idx;
|
||||||
return scale > 0 ? branch_radius + branch_radius * scale : 0;
|
return num_layers_widened > 0 ? branch_radius + num_layers_widened * bp_radius_increase_per_layer : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user