ENH: [tree support] use layer_nr_next for calculate_avoidance

Previously we used layer_nr-1 as the next support layer below layer_nr,
which was not right when we used independent support layer heights.
And this would make it difficult for the tree branche to avoid the object.

Change-Id: Ic705fbd093e4bd555470646044380703ca259904
(cherry picked from commit 245e1cf4fd071b1f1fea4c5d616ff87432a76911)
This commit is contained in:
Arthur 2023-01-05 20:25:55 +08:00 committed by Lane.Wei
parent de6ba75f40
commit d16dee04af
2 changed files with 51 additions and 27 deletions

View file

@ -21,6 +21,15 @@ namespace Slic3r
class PrintObject;
class TreeSupport;
struct LayerHeightData
{
coordf_t print_z = 0;
coordf_t height = 0;
size_t next_layer_nr = 0;
LayerHeightData() = default;
LayerHeightData(coordf_t z, coordf_t h, size_t next_layer) : print_z(z), height(h), next_layer_nr(next_layer) {}
};
/*!
* \brief Lazily generates tree guidance volumes.
*
@ -79,6 +88,8 @@ public:
Polygons get_contours(size_t layer_nr) const;
Polygons get_contours_with_holes(size_t layer_nr) const;
std::vector<LayerHeightData> layer_heights;
private:
/*!
* \brief Convenience typedef for the keys to the caches
@ -423,7 +434,7 @@ private:
*
*/
std::vector<std::pair<coordf_t, coordf_t>> plan_layer_heights(std::vector<std::vector<Node*>>& contact_nodes);
std::vector<LayerHeightData> plan_layer_heights(std::vector<std::vector<Node *>> &contact_nodes);
/*!
* \brief Creates points where support contacts the model.
*