Skip to content

Commit

Permalink
Merge branch 'main' into CURA-10446_modify_gcode_path
Browse files Browse the repository at this point in the history
# Conflicts:
#	conanfile.py
#	include/TreeSupportTipGenerator.h
  • Loading branch information
jellespijker committed Aug 29, 2023
2 parents e537fa6 + 49461d4 commit dc7b53a
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 70 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def validate(self):

def build_requirements(self):
self.test_requires("standardprojectsettings/[>=0.1.0]@ultimaker/stable")
self.tool_requires("protobuf/3.21.9")
self.test_requires("protobuf/3.21.9")
if self.options.enable_testing:
self.test_requires("gtest/1.12.1")
if self.options.enable_benchmarks:
Expand Down
107 changes: 44 additions & 63 deletions include/TreeSupport.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2021 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef TREESUPPORT_H
#define TREESUPPORT_H
Expand Down Expand Up @@ -32,7 +32,7 @@ constexpr auto TREE_PROGRESS_GENERATE_BRANCH_AREAS = TREE_PROGRESS_DRAW_AREAS /
constexpr auto TREE_PROGRESS_SMOOTH_BRANCH_AREAS = TREE_PROGRESS_DRAW_AREAS / 3;
constexpr auto TREE_PROGRESS_FINALIZE_BRANCH_AREAS = TREE_PROGRESS_DRAW_AREAS / 3;

constexpr auto SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA = 100;
constexpr auto SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA = 100.0;
constexpr auto SUPPORT_TREE_MINIMUM_FAKE_ROOF_LAYERS = 1;
constexpr auto SUPPORT_TREE_MINIMUM_ROOF_AREA_HARD_LIMIT = false;
constexpr auto SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL = false;
Expand Down Expand Up @@ -69,8 +69,6 @@ class TreeSupport


private:


/*!
* \brief Precalculates all avoidances, that could be required.
*
Expand Down Expand Up @@ -101,17 +99,14 @@ class TreeSupport
* \param reduced_aabb[in,out] The already processed elements.
* \param input_aabb[in] Not yet processed elements
* \param to_bp_areas[in] The Elements of the current Layer that will reach the buildplate. Value is the influence area where the center of a circle of support may be placed.
* \param to_model_areas[in] The Elements of the current Layer that do not have to reach the buildplate. Also contains main as every element that can reach the buildplate is not forced to.
* Value is the influence area where the center of a circle of support may be placed.
* \param influence_areas[in] The influence areas without avoidance removed.
* \param to_model_areas[in] The Elements of the current Layer that do not have to reach the buildplate. Also contains main as every element that can reach the buildplate is
* not forced to. Value is the influence area where the center of a circle of support may be placed. \param influence_areas[in] The influence areas without avoidance removed.
* \param insert_bp_areas[out] Elements to be inserted into the main dictionary after the Helper terminates.
* \param insert_model_areas[out] Elements to be inserted into the secondary dictionary after the Helper terminates.
* \param insert_influence[out] Elements to be inserted into the dictionary containing the largest possibly valid influence area (ignoring if the area may not be there because of avoidance)
* \param erase[out] Elements that should be deleted from the above dictionaries.
* \param layer_idx[in] The Index of the current Layer.
* \param insert_influence[out] Elements to be inserted into the dictionary containing the largest possibly valid influence area (ignoring if the area may not be there because
* of avoidance) \param erase[out] Elements that should be deleted from the above dictionaries. \param layer_idx[in] The Index of the current Layer.
*/
void mergeHelper
(
void mergeHelper(
std::map<TreeSupportElement, AABB>& reduced_aabb,
std::map<TreeSupportElement, AABB>& input_aabb,
const PropertyAreasUnordered& to_bp_areas,
Expand All @@ -121,8 +116,7 @@ class TreeSupport
PropertyAreasUnordered& insert_model_areas,
PropertyAreasUnordered& insert_influence,
std::vector<TreeSupportElement>& erase,
const LayerIndex layer_idx
);
const LayerIndex layer_idx);

/*!
* \brief Merges Influence Areas if possible.
Expand All @@ -132,42 +126,36 @@ class TreeSupport
*
* \param to_bp_areas[in] The Elements of the current Layer that will reach the buildplate.
* Value is the influence area where the center of a circle of support may be placed.
* \param to_model_areas[in] The Elements of the current Layer that do not have to reach the buildplate. Also contains main as every element that can reach the buildplate is not forced to.
* Value is the influence area where the center of a circle of support may be placed.
* \param influence_areas[in] The Elements of the current Layer without avoidances removed. This is the largest possible influence area for this layer.
* Value is the influence area where the center of a circle of support may be placed.
* \param layer_idx[in] The current layer.
* \param to_model_areas[in] The Elements of the current Layer that do not have to reach the buildplate. Also contains main as every element that can reach the buildplate is
* not forced to. Value is the influence area where the center of a circle of support may be placed. \param influence_areas[in] The Elements of the current Layer without
* avoidances removed. This is the largest possible influence area for this layer. Value is the influence area where the center of a circle of support may be placed. \param
* layer_idx[in] The current layer.
*/
void mergeInfluenceAreas
(
PropertyAreasUnordered& to_bp_areas,
PropertyAreas& to_model_areas,
PropertyAreas& influence_areas,
LayerIndex layer_idx
);
void mergeInfluenceAreas(PropertyAreasUnordered& to_bp_areas, PropertyAreas& to_model_areas, PropertyAreas& influence_areas, LayerIndex layer_idx);

/*!
* \brief Checks if an influence area contains a valid subsection and returns the corresponding metadata and the new Influence area.
*
* Calculates an influence areas of the layer below, based on the influence area of one element on the current layer.
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in we would change our gracious or to_buildplate status the influence areas are instead increased by maximum_move_distance_slow.
* Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this were the case, the radius is not increased instead.
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in we would change our gracious or to_buildplate status the influence areas are
* instead increased by maximum_move_distance_slow. Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this
* were the case, the radius is not increased instead.
*
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was done to avoid not needed heap allocations.
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was
* done to avoid not needed heap allocations.
*
* \param settings[in] Which settings have to be used to check validity.
* \param layer_idx[in] Number of the current layer.
* \param parent[in] The metadata of the parents influence area.
* \param relevant_offset[in] The maximal possible influence area. No guarantee regarding validity with current layer collision required, as it is ensured in-function!
* \param to_bp_data[out] The part of the Influence area that can reach the buildplate.
* \param to_model_data[out] The part of the Influence area that do not have to reach the buildplate. This has overlap with new_layer_data.
* \param increased[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the user-supplied settings.
* \param overspeed[in] How much should the already offset area be offset again. Usually this is 0.
* \param mergelayer[in] Will the merge method be called on this layer. This information is required as some calculation can be avoided if they are not required for merging.
* \return A valid support element for the next layer regarding the calculated influence areas. Empty if no influence are can be created using the supplied influence area and settings.
* \param increased[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the
* user-supplied settings. \param overspeed[in] How much should the already offset area be offset again. Usually this is 0. \param mergelayer[in] Will the merge method be
* called on this layer. This information is required as some calculation can be avoided if they are not required for merging. \return A valid support element for the next
* layer regarding the calculated influence areas. Empty if no influence are can be created using the supplied influence area and settings.
*/
std::optional<TreeSupportElement> increaseSingleArea
(
std::optional<TreeSupportElement> increaseSingleArea(
AreaIncreaseSettings settings,
LayerIndex layer_idx,
TreeSupportElement* parent,
Expand All @@ -176,37 +164,35 @@ class TreeSupport
Polygons& to_model_data,
Polygons& increased,
const coord_t overspeed,
const bool mergelayer
);
const bool mergelayer);

/*!
* \brief Increases influence areas as far as required.
*
* Calculates influence areas of the layer below, based on the influence areas of the current layer.
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in it would change the gracious or to_buildplate status, the influence areas are instead increased by maximum_move_distance.
* Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this were the case, the radius is not increased instead.
* Increases every influence area by maximum_move_distance_slow. If this is not enough, as in it would change the gracious or to_buildplate status, the influence areas are
* instead increased by maximum_move_distance. Also ensures that increasing the radius of a branch, does not cause it to change its status (like to_buildplate ). If this were
* the case, the radius is not increased instead.
*
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was done to avoid not needed heap allocations.
* Warning: The used format inside this is different as the SupportElement does not have a valid area member. Instead this area is saved as value of the dictionary. This was
* done to avoid not needed heap allocations.
*
* \param to_bp_areas[out] Influence areas that can reach the buildplate
* \param to_model_areas[out] Influence areas that do not have to reach the buildplate. This has overlap with new_layer_data, as areas that can reach the buildplate are also considered valid areas to the model.
* This redundancy is required if a to_buildplate influence area is allowed to merge with a to model influence area.
* \param influence_areas[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the user-supplied settings.
* \param bypass_merge_areas[out] Influence areas ready to be added to the layer below that do not need merging.
* \param last_layer[in] Influence areas of the current layer.
* \param layer_idx[in] Number of the current layer.
* \param mergelayer[in] Will the merge method be called on this layer. This information is required as some calculation can be avoided if they are not required for merging.
* \param to_model_areas[out] Influence areas that do not have to reach the buildplate. This has overlap with new_layer_data, as areas that can reach the buildplate are also
* considered valid areas to the model. This redundancy is required if a to_buildplate influence area is allowed to merge with a to model influence area. \param
* influence_areas[out] Area than can reach all further up support points. No assurance is made that the buildplate or the model can be reached in accordance to the
* user-supplied settings. \param bypass_merge_areas[out] Influence areas ready to be added to the layer below that do not need merging. \param last_layer[in] Influence areas
* of the current layer. \param layer_idx[in] Number of the current layer. \param mergelayer[in] Will the merge method be called on this layer. This information is required as
* some calculation can be avoided if they are not required for merging.
*/
void increaseAreas
(
void increaseAreas(
PropertyAreasUnordered& to_bp_areas,
PropertyAreas& to_model_areas,
PropertyAreas& influence_areas,
std::vector<TreeSupportElement*>& bypass_merge_areas,
const std::vector<TreeSupportElement*>& last_layer,
const LayerIndex layer_idx,
const bool mergelayer
);
const bool mergelayer);

/*!
* \brief Propagates influence downwards, and merges overlapping ones.
Expand Down Expand Up @@ -245,15 +231,13 @@ class TreeSupport
*
* \param linear_data[in] All currently existing influence areas with the layer they are on
* \param layer_tree_polygons[out] Resulting branch areas with the layerindex they appear on.
* layer_tree_polygons.size() has to be at least linear_data.size() as each Influence area in linear_data will save have at least one (that's why it's a vector<vector>) corresponding branch area in layer_tree_polygons.
* \param inverse_tree_order[in] A mapping that returns the child of every influence area.
* layer_tree_polygons.size() has to be at least linear_data.size() as each Influence area in linear_data will save have at least one (that's why it's a vector<vector>)
* corresponding branch area in layer_tree_polygons. \param inverse_tree_order[in] A mapping that returns the child of every influence area.
*/
void generateBranchAreas
(
void generateBranchAreas(
std::vector<std::pair<LayerIndex, TreeSupportElement*>>& linear_data,
std::vector<std::unordered_map<TreeSupportElement*, Polygons>>& layer_tree_polygons,
const std::map<TreeSupportElement*, TreeSupportElement*>& inverse_tree_order
);
const std::map<TreeSupportElement*, TreeSupportElement*>& inverse_tree_order);

/*!
* \brief Applies some smoothing to the outer wall, intended to smooth out sudden jumps as they can happen when a branch moves though a hole.
Expand All @@ -270,13 +254,11 @@ class TreeSupport
* \param dropped_down_areas[out] Areas that have to be added to support all non-graceful areas.
* \param inverse_tree_order[in] A mapping that returns the child of every influence area.
*/
void dropNonGraciousAreas
(
void dropNonGraciousAreas(
std::vector<std::unordered_map<TreeSupportElement*, Polygons>>& layer_tree_polygons,
const std::vector<std::pair<LayerIndex, TreeSupportElement*>>& linear_data,
std::vector<std::vector<std::pair<LayerIndex, Polygons>>>& dropped_down_areas,
const std::map<TreeSupportElement*, TreeSupportElement*>& inverse_tree_order
);
const std::map<TreeSupportElement*, TreeSupportElement*>& inverse_tree_order);


void filterFloatingLines(std::vector<Polygons>& support_layer_storage);
Expand Down Expand Up @@ -335,7 +317,6 @@ class TreeSupport
* Required for the progress bar the behave as expected when areas have to be calculated multiple times
*/
double progress_offset = 0;

};


Expand Down
8 changes: 4 additions & 4 deletions include/TreeSupportTipGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ class TreeSupportTipGenerator


/*!
* \brief Minimum area an overhang has to have to become a roof.
* \brief Minimum area an overhang has to have to be supported.
*/
const double minimum_roof_area;
const double minimum_support_area;

/*!
* \brief Minimum area an overhang has to have to be supported.
* \brief Minimum area an overhang has to have to become a roof.
*/
const double minimum_support_area;
const double minimum_roof_area;

/*!
* \brief Amount of layers of roof. Zero if roof is disabled
Expand Down
2 changes: 1 addition & 1 deletion src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool InsetOrderOptimizer::addToLayer()

constexpr bool detect_loops = false;
constexpr Polygons* combing_boundary = nullptr;
constexpr bool group_outer_walls = true;
constexpr bool group_outer_walls = false;
// When we alternate walls, also alternate the direction at which the first wall starts in.
// On even layers we start with normal direction, on odd layers with inverted direction.
PathOrderOptimizer<const ExtrusionLine*>
Expand Down
7 changes: 6 additions & 1 deletion src/TreeSupportTipGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ namespace cura
TreeSupportTipGenerator::TreeSupportTipGenerator(const SliceDataStorage& storage, const SliceMeshStorage& mesh, TreeModelVolumes& volumes_s)
: config(mesh.settings)
, use_fake_roof(! mesh.settings.get<bool>("support_roof_enable"))
, minimum_roof_area(! use_fake_roof ? mesh.settings.get<double>("minimum_roof_area") : SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA)
, minimum_support_area(mesh.settings.get<double>("minimum_support_area"))
, minimum_roof_area(! use_fake_roof ? mesh.settings.get<double>("minimum_roof_area") : std::max(SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA, minimum_support_area))
, support_roof_layers(
mesh.settings.get<bool>("support_roof_enable") ? round_divide(mesh.settings.get<coord_t>("support_roof_height"), config.layer_height)
: use_fake_roof ? SUPPORT_TREE_MINIMUM_FAKE_ROOF_LAYERS
Expand Down Expand Up @@ -973,6 +973,11 @@ void TreeSupportTipGenerator::generateTips(
{
for (Polygons& remaining_overhang_part : remaining_overhang.splitIntoParts(false))
{
if (remaining_overhang_part.area() <= MM2_2INT(minimum_support_area))
{
continue;
}

std::vector<LineInformation> overhang_lines;
Polygons polylines = ensureMaximumDistancePolyline(generateLines(remaining_overhang_part, false, layer_idx), config.min_radius, 1, false);
// ^^^ Support_line_width to form a line here as otherwise most will be unsupported.
Expand Down

0 comments on commit dc7b53a

Please sign in to comment.