Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better tree support for pointy overhangs: Cradle Generation #1880

Draft
wants to merge 110 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
108238f
Add feature to better support pointy overhangs. Will create a pull re…
ThomasRahm May 7, 2023
c7b6aaa
Fix support_skin_line_distance setting not working.
ThomasRahm May 7, 2023
0997c3b
Fix support being sprinkled on top of angled interface when tree supp…
ThomasRahm May 7, 2023
12f2572
Fix Tree Support Cradle generation causing a crash.
ThomasRahm May 7, 2023
624991d
Fix crash when support blockers are used.
ThomasRahm May 8, 2023
59531dc
Fix Cradle Tip generation behaving unexpectedly when support interfac…
ThomasRahm May 13, 2023
dc64f93
Improved Tree Support Support Skin Generation and fixed bug causing t…
ThomasRahm May 16, 2023
7e0191e
Fix Support Floor being activated to sometimes cause slicing to freeze.
ThomasRahm Jul 13, 2023
810d6ea
Fix Minimum support area not working always when X/Y overrides Z or i…
ThomasRahm Jul 15, 2023
2538d86
Fix branches being wrongly regarded as an error (and removed because …
ThomasRahm Jul 25, 2023
0d0c841
Merge remote-tracking branch 'upstream/5.6' into tree_support_2
ThomasRahm Nov 18, 2023
f3ff9f4
Fix issues cause by merge and fix issue caused by previous refactor.
ThomasRahm Nov 18, 2023
e0e19ab
Change the way settings are retrieved to enable using a fake plugin t…
ThomasRahm Nov 19, 2023
1a7f9c3
Add first version of support_tree_cradle_xy_distance setting.
ThomasRahm Nov 19, 2023
c216424
Update Conan and GitHub workflows
jellespijker Dec 14, 2023
b7d7316
Revert update of fmt and spdlog
jellespijker Dec 14, 2023
dffcecf
Fix fractional roof not working correctly with cradles
ThomasRahm Dec 17, 2023
8cefce5
Fix cradle xy distance
ThomasRahm Dec 18, 2023
36db8a2
Fix cradle sometimes not being supported correctly
ThomasRahm Dec 18, 2023
c9cda5a
Merge branch '5.6' into tree_support_2
ThomasRahm Dec 24, 2023
b16c159
More cradle fixes
ThomasRahm Dec 25, 2023
1ae92f2
Some fixes to support skin
ThomasRahm Dec 25, 2023
9e61337
Fix crashes caused by tree support.
ThomasRahm Dec 24, 2023
81eff9e
Fix compile error caused by previous commit
ThomasRahm Jan 1, 2024
d357561
Made cradle xy distance a vector to enable more flexibility
ThomasRahm Jan 6, 2024
b25a88e
Changed support skin pattern to ZigZag and reduced support skin wall …
ThomasRahm Jan 6, 2024
c983b58
Fix bug related to cradle and fractional roof again
ThomasRahm Jan 9, 2024
5867e20
Cradle refactoring
ThomasRahm Feb 12, 2024
7eb33bb
Cradle fixes
ThomasRahm Feb 19, 2024
91f6fd5
Work im progress refactoring to enable removing cradle-lines while th…
ThomasRahm Mar 12, 2024
4787452
Fix first and last vertex created by makeCircle being close together,…
ThomasRahm Mar 13, 2024
a533391
Fix branches not merging below anti preferred areas
ThomasRahm Mar 13, 2024
39d2a91
Cradle fixes related to cradle roof type and a bit refactoring
ThomasRahm Mar 14, 2024
20f2755
Ensure cradle lines have no overhang if possible, also performance im…
ThomasRahm Mar 14, 2024
0cfba23
Prevent potential issues with applying anti preferred areas to cause …
ThomasRahm Mar 14, 2024
3d84b94
More cradle fixes.
ThomasRahm Mar 15, 2024
302657c
Made center of the cradle move slightly with the object it supports
ThomasRahm Mar 16, 2024
f275c9c
Some parallelization and performance improvements
ThomasRahm Mar 17, 2024
64f8ef7
More cradle fixes
ThomasRahm Mar 17, 2024
0f4a602
Fix crash causes by missing lock.
ThomasRahm Mar 17, 2024
82835b4
Fix increaseSingleArea bug caused by a previous optimisation
ThomasRahm Mar 17, 2024
ccf229b
Fix another crash caused by missing lock
ThomasRahm Mar 17, 2024
ea35c28
More cradle fixes
ThomasRahm Mar 17, 2024
e2a2833
Shorten cradle lines again if lines were removed that made them longer.
ThomasRahm Mar 17, 2024
79c7e36
Prevent invalid cradle lines from generating and fix for cradle relat…
ThomasRahm Mar 18, 2024
3cbf074
Commit code missing from previous commit and fix some comments
ThomasRahm Mar 18, 2024
2a7aefa
Merge remote-tracking branch 'upstream/5.7' into tree_support_2
ThomasRahm Mar 18, 2024
6966fa0
Merge part 2: Fixing variable names/usage.
ThomasRahm Mar 18, 2024
aa00d60
Fix wrong type name.
ThomasRahm Mar 18, 2024
27dd92c
Removed performance optimisation causing cradle line tips of removed …
ThomasRahm Mar 18, 2024
f08100f
Removed some unused variables
ThomasRahm Mar 19, 2024
d7cb1aa
Fix cradle calculation for 1 line not terminating
ThomasRahm Mar 21, 2024
9a95d4b
Improving fractional support for tree supports
ThomasRahm Mar 25, 2024
25acb8c
Fix bug causing roof to not properly generate when using tree supports
ThomasRahm Mar 25, 2024
01b10c0
Merge branch 'improved-fractional-tree-support' into tree_support_2
ThomasRahm Mar 31, 2024
74c8bd4
Fix issues with cradle lines including issues occurring when the crad…
ThomasRahm Apr 4, 2024
75d2dff
Merge remote-tracking branch 'upstream/5.7' into tree_support_2
ThomasRahm Apr 4, 2024
5f57b8e
Fix cradle line distance being wrong sometimes for angled parts of th…
ThomasRahm Apr 6, 2024
9ef6698
Fix fractional support bug related to tree support caused by merging …
ThomasRahm Apr 6, 2024
96d023a
Fix fractional support skin for cradle base areas.
ThomasRahm Apr 6, 2024
50c57ce
First refactoring to add setting to ensure initial layer diameter can…
ThomasRahm Apr 9, 2024
f9e0bc7
Fix initial layer diameter not working
ThomasRahm Apr 9, 2024
6d44415
Fix using wrong fillInfillParts to add tree support areas.
ThomasRahm Apr 10, 2024
057ed36
Enable different amount of roof wall counts for tree support.
ThomasRahm Apr 20, 2024
8f2ccdd
Improve interaction between cradle base and lines if both are roofs a…
ThomasRahm Apr 20, 2024
1309df4
Fix possible crash caused by cradle code.
ThomasRahm Apr 20, 2024
6a2f662
Fix large cradle tip calculations
ThomasRahm Apr 21, 2024
2214365
Fix rounding errors with anti-preferred avoidance.
ThomasRahm Apr 21, 2024
2e5d928
Remove support areas around lines missing because of cradle z distanc…
ThomasRahm Apr 21, 2024
872e8e7
Fix "Removing already placed tip" when a cradle roof base is only val…
ThomasRahm Apr 21, 2024
879ecb1
Prevent roof from generating close to the cradle as any overhang ther…
ThomasRahm Apr 21, 2024
f5186eb
Fix regressions with fractional tree support. Also ensure fractional …
ThomasRahm Apr 22, 2024
14f8f3d
Improve anti-preferred handling in increaseSingleArea.
ThomasRahm Apr 22, 2024
73313c6
Fixes and refactoring related to cradle line generation.
ThomasRahm Apr 23, 2024
d17b2d5
Fix cradle roof type "Cradle and Base"
ThomasRahm Apr 23, 2024
5153fe0
Improved formatting
ThomasRahm Apr 24, 2024
e329928
Fix roof cradle lines missing if roof wall line count is larger than 0
ThomasRahm Apr 24, 2024
abcf5ce
Improve branches avoiding cradle lines.
ThomasRahm Apr 24, 2024
aed739c
Added performance logging to generateInitialAreas
ThomasRahm Apr 25, 2024
1a7db83
Improved performance and fixed regression that could cause branches b…
ThomasRahm Apr 25, 2024
93f53f1
Fix issue causing force initial layer diameter to be always applied f…
ThomasRahm Apr 25, 2024
9637267
Merge remote-tracking branch 'upstream/5.7' into tree_support_2
ThomasRahm Apr 25, 2024
ba8208d
Refactoring to enable adding cradle to regular support later
ThomasRahm May 1, 2024
2cec577
Fix roof cradle base calculation creating non-supportable bases
ThomasRahm May 2, 2024
a79c0de
Fix rounding errors in handleCradleLineValidity.
ThomasRahm May 2, 2024
b07e7fd
Fix support of cradle lines by fixing the reduction
ThomasRahm May 2, 2024
9aa2fad
Fix cradle roof base z distance if no fractional roof is present and …
ThomasRahm May 2, 2024
5efba20
Fix tip density for cradle lines if cradle tips size is small.
ThomasRahm May 2, 2024
fbbf9fa
Fix roof generating for areas that are handled by cradle bases or lin…
ThomasRahm Jun 3, 2024
9d1ebf2
Ensure that cradle lines can not intersect with already added roof. P…
ThomasRahm May 3, 2024
60d8b95
Fix guaranteed line below large cradle base.
ThomasRahm May 3, 2024
d77e87b
Fix missing cradle lines if cradle line count is odd
ThomasRahm May 24, 2024
ae25532
Fix issue causing support lines to overlap with the model
ThomasRahm Jun 3, 2024
fba4d7b
Fix issue causing support skin lines to overlap with the model
ThomasRahm Jun 3, 2024
798ad56
Ensure support skin is generated below holes that can not be removed
ThomasRahm Jun 3, 2024
cc8147b
Merge remote-tracking branch 'upstream/5.7' into tree_support_2
ThomasRahm Jun 3, 2024
11b4a76
Fix regression causing hole removal to not work correctly.
ThomasRahm Jun 4, 2024
6664a4f
Change non-removable hole detection, to prevent potential issues with…
ThomasRahm Jun 4, 2024
5e03048
Fix crash occurring when cradle z distance is smaller than z distance.
ThomasRahm Jul 5, 2024
f26a916
Merge remote-tracking branch 'refs/remotes/upstream/5.8' into tree_su…
ThomasRahm Jul 24, 2024
c0e46cb
Adapt to new Shape and LinesSets after merge. Also add back all funct…
ThomasRahm Jul 25, 2024
ae63e19
Fix cradle lines stopping because of too long jumps caused by xy dist…
ThomasRahm Jul 26, 2024
4b9a595
Merge remote-tracking branch 'refs/remotes/upstream/5.8' into tree_su…
ThomasRahm Aug 16, 2024
ad51551
Fix for issue https://github.com/Ultimaker/Cura/issues/19586 in the c…
ThomasRahm Aug 28, 2024
6e73eb8
Add ability to manually place cradles, refactor the way support modif…
ThomasRahm Sep 6, 2024
5a7a068
Add initial support for cradles if normal support is used.
ThomasRahm Sep 11, 2024
85bca65
Fix cradle generation wrongly being called twice if tree support is used
ThomasRahm Sep 13, 2024
06c6488
Improve resiliency if TreeModelVolumes is used without precalculating…
ThomasRahm Sep 17, 2024
340e70f
Fix support for cradle being placed to far up if the cradle is roof.
ThomasRahm Sep 18, 2024
d7d1f71
Implement functionality to select whether cradle lines should be prin…
ThomasRahm Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ set(engine_SRCS # Except main.cpp.
src/geometry/Polyline.cpp
src/geometry/ClosedPolyline.cpp
src/geometry/MixedLinesSet.cpp
src/TreeSupportCradle.cpp
)

add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS})
Expand Down
6 changes: 3 additions & 3 deletions include/FffGcodeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "FanSpeedLayerTime.h"
#include "GCodePathConfig.h"
#include "LayerPlanBuffer.h"
#include "SupportInfillPart.h"
#include "gcodeExport.h"
#include "utils/LayerVector.h"
#include "utils/NoCopy.h"
Expand Down Expand Up @@ -635,12 +636,11 @@ class FffGcodeWriter : public NoCopy
* layer.
*
* \param[in] storage Where the slice data is stored.
* \param[in] support_roof_outlines which polygons to generate roofs for.
* \param[in] current_roof_config config to be used.
* \param[in] support_roof_outlines Collection of polygons to generate roofs for.
* \param gcodeLayer The initial planning of the g-code of the layer.
* \return Whether any support skin was added to the layer plan.
*/
bool addSupportRoofsToGCode(const SliceDataStorage& storage, const Shape& support_roof_outlines, const GCodePathConfig& current_roof_config, LayerPlan& gcode_layer) const;
bool addSupportRoofsToGCode(const SliceDataStorage& storage, const std::vector<SupportInfillPart>& support_roof_outlines, LayerPlan& gcode_layer) const;

/*!
* Add the support bottoms to the layer plan \p gcodeLayer of the current
Expand Down
12 changes: 10 additions & 2 deletions include/PathOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class PathOrderOptimizer

// For some Z seam types the start position can be pre-computed.
// This is faster since we don't need to re-compute the start position at each step then.
precompute_start &= seam_config_.type_ == EZSeamType::RANDOM || seam_config_.type_ == EZSeamType::USER_SPECIFIED || seam_config_.type_ == EZSeamType::SHARPEST_CORNER;
precompute_start &= seam_config_.type_ == EZSeamType::RANDOM || seam_config_.type_ == EZSeamType::USER_SPECIFIED || seam_config_.type_ == EZSeamType::INTERNAL_SPECIFIED || seam_config_.type_ == EZSeamType::SHARPEST_CORNER;
if (precompute_start)
{
for (auto& path : paths_)
Expand Down Expand Up @@ -584,7 +584,7 @@ class PathOrderOptimizer
}

const bool precompute_start
= seam_config_.type_ == EZSeamType::RANDOM || seam_config_.type_ == EZSeamType::USER_SPECIFIED || seam_config_.type_ == EZSeamType::SHARPEST_CORNER;
= seam_config_.type_ == EZSeamType::RANDOM || seam_config_.type_ == EZSeamType::USER_SPECIFIED || seam_config_.type_ == EZSeamType::INTERNAL_SPECIFIED ||seam_config_.type_ == EZSeamType::SHARPEST_CORNER;
if (! path->is_closed_ || ! precompute_start) // Find the start location unless we've already precomputed it.
{
path->start_vertex_ = findStartLocation(*path, start_position);
Expand Down Expand Up @@ -676,6 +676,14 @@ class PathOrderOptimizer
{
if (! path.is_closed_)
{
if (seam_config_.type_ == EZSeamType::INTERNAL_SPECIFIED)
{
if(getDirectDistance(path.converted_->back(), seam_config_.pos_) < getDirectDistance(path.converted_->front(), seam_config_.pos_))
{
return path.converted_->size() - 1; // Back end is closer.
}
return 0;
}
// For polylines, the seam settings are not applicable. Simply choose the position closest to target_pos then.
const coord_t back_distance
= (combing_boundary_ == nullptr) ? getDirectDistance(path.converted_->back(), target_pos) : getCombingDistance(path.converted_->back(), target_pos);
Expand Down
13 changes: 12 additions & 1 deletion include/SupportInfillPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#ifndef SUPPORT_INFILL_PART_H
#define SUPPORT_INFILL_PART_H

#include <optional>
#include <vector>

#include "geometry/Polygon.h"
#include "geometry/SingleShape.h"
#include "settings/EnumSettings.h"
#include "utils/AABB.h"
#include "utils/ExtrusionLine.h"

Expand Down Expand Up @@ -36,8 +38,17 @@ class SupportInfillPart

coord_t custom_line_distance_; //!< The distance between support infill lines. 0 means use the default line distance instead.
bool use_fractional_config_; //!< Request to use the configuration used to fill a partial layer height here, instead of the normal full layer height configuration.
EFillMethod custom_line_pattern_;
std::optional<Point2LL> start_near_location;

SupportInfillPart(const SingleShape& outline, coord_t support_line_width, bool use_fractional_config, int inset_count_to_generate = 0, coord_t custom_line_distance = 0);
SupportInfillPart(const SingleShape& outline,
coord_t support_line_width,
bool use_fractional_config,
int inset_count_to_generate = 0,
coord_t custom_line_distance = 0,
EFillMethod custom_line_pattern = EFillMethod::NONE,
std::optional<Point2LL> start_near_location = std::optional<Point2LL>()
);

const Shape& getInfillArea() const;
};
Expand Down
101 changes: 99 additions & 2 deletions include/TreeModelVolumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <unordered_map>
#include <unordered_set>

#include "TreeSupportEnums.h"
#include "TreeSupportEnums.h"
#include "geometry/Shape.h"
#include "settings/EnumSettings.h" //To store whether X/Y or Z distance gets priority.
Expand Down Expand Up @@ -40,6 +41,7 @@ class TreeModelVolumes
coord_t max_move,
coord_t max_move_slow,
coord_t min_offset_per_step,
const coord_t min_radius,
size_t current_mesh_idx,
double progress_multiplier,
double progress_offset,
Expand All @@ -50,14 +52,15 @@ class TreeModelVolumes
TreeModelVolumes(const TreeModelVolumes&) = delete;
TreeModelVolumes& operator=(const TreeModelVolumes&) = delete;


/*!
* \brief Precalculate avoidances and collisions up to this layer.
*
* This uses knowledge about branch angle to only calculate avoidances and collisions that could actually be needed.
* Not calling this will cause the class to lazily calculate avoidances and collisions as needed, which will be a lot slower on systems with more then one or two cores!
*
*/
void precalculate(coord_t max_layer);
void precalculate(LayerIndex max_layer);

/*!
* \brief Provides the areas that have to be avoided by the tree's branches to prevent collision with the model on this layer.
Expand Down Expand Up @@ -129,6 +132,7 @@ class TreeModelVolumes
*/
const Shape& getWallRestriction(coord_t radius, LayerIndex layer_idx, bool min_xy_dist);


/*!
* \brief Round \p radius upwards to either a multiple of radius_sample_resolution_ or a exponentially increasing value
*
Expand All @@ -143,12 +147,46 @@ class TreeModelVolumes
/*!
* \brief Round \p radius upwards to the maximum that would still round up to the same value as the provided one.
*
* \param radius The radius of the node of interest
* \param radius The radius of the element of interest
* \param min_xy_dist is the minimum xy distance used.
* \return The maximum radius, resulting in the same rounding.
*/
coord_t getRadiusNextCeil(coord_t radius, bool min_xy_dist) const;

LayerIndex getFirstAntiPreferredLayerIdx();

/*!
* \brief Provide hints which areas should be avoided in the future.
* \param area The area that should be avoided in the future.
* \param layer_idx The layer said area is on.
*/
void addAreaToAntiPreferred(const Shape area, LayerIndex layer_idx);

void precalculateAntiPreferred();

/*!
* \brief Get areas that were additionally set to be avoided
* \param layer_idx The layer said area is on.
* \param radius The radius of the node of interest.
* \returns The area that should be avoided
*/
const Shape& getAntiPreferredAreas(LayerIndex layer_idx, coord_t radius);

/*!
* \brief Get avoidance areas for areas that were additionally set to be avoided
* \param layer_idx The layer said area is on.
* \param radius The radius of the node of interest.
* \returns The area that should be avoided
*/
const Shape& getAntiPreferredAvoidance(coord_t radius, LayerIndex layer_idx, AvoidanceType type, bool to_model, bool min_xy_dist);

/*!
* \brief Get areas that were are classified as support blocker
* \param layer_idx The layer said area is on.
* \returns The area should not contain support
*/
const Shape& getSupportBlocker(LayerIndex layer_idx);


private:
/*!
Expand Down Expand Up @@ -309,6 +347,17 @@ class TreeModelVolumes
calculateAvoidanceToModel(std::deque<RadiusLayerPair>{ RadiusLayerPair(key) });
}

/*!
* \brief Creates the areas that have to be avoided by the tree's branches to prevent collision with the model with radius 0 from the smallest actual avoidance.
* This is done as a real 0 radius avoidance would not be able to be printed. These 0 radius avoidances are used for calculating roof and cradle.
*
* The result is a 2D area that would cause nodes of radius 0 to
* collide with the model in a not wanted way. Result is saved in the cache.
* \param max_layer The result will be calculated up to the this layer.
*/
void calculateFake0Avoidances(const LayerIndex max_layer);


/*!
* \brief Creates the areas that can not be passed when expanding an area downwards. As such these areas are an somewhat abstract representation of a wall (as in a printed
* object).
Expand Down Expand Up @@ -463,6 +512,18 @@ class TreeModelVolumes
*/
RestPreference support_rest_preference_;

/*!
* \brief Largest DTT a cradle supporting tip may have.
*/
size_t max_cradle_dtt = 0;

LayerIndex first_anti_preferred_layer_idx_ = 0;

/*!
* \brief radii for which avoidance was already precalculated. Used to calculate anti preferred avoidance.
*/
std::deque<RadiusLayerPair> precalculated_avoidance_radii;

/*!
* \brief Caches for the collision, avoidance and areas on the model where support can be placed safely
* at given radius and layer indices.
Expand Down Expand Up @@ -520,9 +581,45 @@ class TreeModelVolumes
mutable std::unordered_map<RadiusLayerPair, Shape> wall_restrictions_cache_min_;
std::unique_ptr<std::mutex> critical_wall_restrictions_cache_min_ = std::make_unique<std::mutex>();

mutable std::unordered_map<RadiusLayerPair, Shape> anti_preferred_;
std::unique_ptr<std::mutex> critical_anti_preferred_ = std::make_unique<std::mutex>();

mutable std::unordered_map<RadiusLayerPair, Shape> anti_preferred_cache_;
mutable std::unordered_map<RadiusLayerPair, Shape> anti_preferred_cache_to_model_;
mutable std::unordered_map<RadiusLayerPair, Shape> anti_preferred_cache_collision;
std::unique_ptr<std::mutex> critical_anti_preferred_caches = std::make_unique<std::mutex>();

enum class CalculationType
{
AVOIDANCE,
AVOIDANCE_0,
AVOIDANCE_TO_MODEL,
AVOIDANCE_COLLISION,
COLLISION,
COLLISION_HOLEFREE,
PLACEABLE,
PLACEABLE_ACCUMULATED,
WALL_RESTRICTION
};
std::unique_ptr<std::mutex> critical_calculation_request_ = std::make_unique<std::mutex>();
std::unordered_map<std::pair<coord_t, CalculationType>, std::shared_ptr<std::mutex>> critical_calculation_map_;

std::shared_ptr<std::mutex> getLockForCalculation(coord_t radius, CalculationType type)
{
std::lock_guard<std::mutex> critical_section(*critical_calculation_request_);
std::pair<coord_t, CalculationType> key(radius, type);
if (! critical_calculation_map_.contains(key))
{
critical_calculation_map_[key] = std::make_shared<std::mutex>();
}
return critical_calculation_map_[key];
}

std::unique_ptr<std::mutex> critical_progress_ = std::make_unique<std::mutex>();

Simplify simplifier_ = Simplify(0, 0, 0); // a simplifier to simplify polygons. Will be properly initialised in the constructor.

Shape empty_polygon = Shape();
};

} // namespace cura
Expand Down
Loading
Loading