Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into CURA-11947_improve_mu…
Browse files Browse the repository at this point in the history
…ltimaterial_raft
  • Loading branch information
wawanbreton committed Jun 21, 2024
2 parents cfdf0b4 + 2f395b0 commit 8ca2838
Show file tree
Hide file tree
Showing 69 changed files with 209 additions and 18 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ target_compile_definitions(_CuraEngine
$<$<CONFIG:Debug>:ASSERT_INSANE_OUTPUT>
$<$<CONFIG:Debug>:USE_CPU_TIME>
$<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:RelWithDebInfo>:ASSERT_INSANE_OUTPUT>
$<$<CONFIG:RelWithDebInfo>:USE_CPU_TIME>
$<$<CONFIG:RelWithDebInfo>:DEBUG>
)

enable_sanitizers(_CuraEngine)
Expand Down
2 changes: 2 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def build(self):
self.run("objcopy --only-keep-debug --compress-debug-sections=zlib CuraEngine CuraEngine.debug")
self.run("objcopy --strip-debug --strip-unneeded CuraEngine")
self.run("objcopy --add-gnu-debuglink=CuraEngine.debug CuraEngine")
elif self.settings.os == "Macos":
self.run("dsymutil CuraEngine")

self.output.info("Uploading debug symbols to sentry")
build_source_dir = self.build_path.parent.parent.as_posix()
Expand Down
7 changes: 6 additions & 1 deletion include/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ class Application : NoCopy
#endif // ARCUS

/*!
* \brief Print the header and license to the stderr channel.
* \brief Print the header to the stderr channel.
*/
void printHeader() const;

/*!
* \brief Print the license to the stderr channel.
*/
void printLicense() const;

Expand Down
9 changes: 9 additions & 0 deletions include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ class InsetOrderOptimizer
Shape retraction_region_; // After printing an outer wall, move into this region so that retractions do not leave visible blobs. Calculated lazily if needed (see
// retraction_region_calculated).

/*!
* Given a closed polygon, insert a seam point at the point where the seam should be placed.
* This should result in the seam-finding algorithm finding that exact point, instead of the
* 'best' vertex on that polygon. Under certain circumstances, the seam-placing algorithm can
* however still deviate from this, for example when the seam-point placed here isn't suppored
* by the layer below.
*/
void insertSeamPoint(ExtrusionLine& closed_line);

/*!
* Determine if the paths should be reversed
* If there is one extruder used, and we're currently printing the inner walls then Reversing the insets now depends on the inverse of
Expand Down
12 changes: 10 additions & 2 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class LayerPlan : public NoCopy
coord_t comb_move_inside_distance_; //!< Whenever using the minimum boundary for combing it tries to move the coordinates inside by this distance after calculating the combing.
Shape bridge_wall_mask_; //!< The regions of a layer part that are not supported, used for bridging
Shape overhang_mask_; //!< The regions of a layer part where the walls overhang
Shape seam_overhang_mask_; //!< The regions of a layer part where the walls overhang, specifically as defined for the seam
Shape roofing_mask_; //!< The regions of a layer part where the walls are exposed to the air

bool min_layer_time_used = false; //!< Wether or not the minimum layer time (cool_min_layer_time) was actually used in this layerplan.
Expand Down Expand Up @@ -283,6 +284,13 @@ class LayerPlan : public NoCopy
*/
void setOverhangMask(const Shape& polys);

/*!
* Set seam_overhang_mask.
*
* \param polys The overhung areas of the part currently being processed that will require modified print settings w.r.t. seams
*/
void setSeamOverhangMask(const Shape& polys);

/*!
* Set roofing_mask.
*
Expand Down Expand Up @@ -671,12 +679,12 @@ class LayerPlan : public NoCopy
template<typename T>
unsigned locateFirstSupportedVertex(const T& wall, const unsigned start_idx) const
{
if (bridge_wall_mask_.empty() && overhang_mask_.empty())
if (bridge_wall_mask_.empty() && seam_overhang_mask_.empty())
{
return start_idx;
}

const auto air_below = bridge_wall_mask_.unionPolygons(overhang_mask_);
const auto air_below = bridge_wall_mask_.unionPolygons(seam_overhang_mask_);

unsigned curr_idx = start_idx;

Expand Down
42 changes: 41 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,49 @@ void Application::printHelp() const
fmt::print("\n");
}

void Application::printLicense() const
void Application::printHeader() const
{
fmt::print("\n");
fmt::print("Cura_SteamEngine version {}\n", CURA_ENGINE_VERSION);

#ifdef DEBUG
fmt::print("\n");
fmt::print(" _______ ________ _______ __ __ ______\n");
fmt::print("/ \\ / |/ \\ / | / | / \\\n");
fmt::print("███████ |████████/ ███████ |██ | ██ |/██████ |\n");
fmt::print("██ | ██ |██ |__ ██ |__██ |██ | ██ |██ | _██/\n");
fmt::print("██ | ██ |██ | ██ ██< ██ | ██ |██ |/ |\n");
fmt::print("██ | ██ |█████/ ███████ |██ | ██ |██ |████ |\n");
fmt::print("██ |__██ |██ |_____ ██ |__██ |██ \\__██ |██ \\__██ |\n");
fmt::print("██ ██/ ██ |██ ██/ ██ ██/ ██ ██/\n");
fmt::print("███████/ ████████/ ███████/ ██████/ ██████/\n");
fmt::print("\n");
fmt::print(" __ __ ______ _______ ________\n");
fmt::print("/ \\ / | / \\ / \\ / |\n");
fmt::print("██ \\ /██ |/██████ |███████ |████████/\n");
fmt::print("███ \\ /███ |██ | ██ |██ | ██ |██ |__\n");
fmt::print("████ /████ |██ | ██ |██ | ██ |██ |\n");
fmt::print("██ ██ ██/██ |██ | ██ |██ | ██ |█████/\n");
fmt::print("██ |███/ ██ |██ \\__██ |██ |__██ |██ |_____\n");
fmt::print("██ | █/ ██ |██ ██/ ██ ██/ ██ |\n");
fmt::print("██/ ██/ ██████/ ███████/ ████████/\n");
fmt::print("\n");

fmt::print("#########################################################\n");
fmt::print("#########################################################\n");
fmt::print("## WARNING: This version of CuraEngine has been built ##\n");
fmt::print("## in developper mode. This may impact performances, ##\n");
fmt::print("## provoke unexpected results or crashes. ##\n");
fmt::print("## If you downloaded an official version of CuraEngine ##\n");
fmt::print("## and see this message, please report the issue. ##\n");
fmt::print("#########################################################\n");
fmt::print("#########################################################\n");
#endif
}

void Application::printLicense() const
{
fmt::print("\n");
fmt::print("Copyright (C) 2024 Ultimaker\n");
fmt::print("\n");
fmt::print("This program is free software: you can redistribute it and/or modify\n");
Expand Down Expand Up @@ -184,6 +223,7 @@ void Application::run(const size_t argc, char** argv)
argc_ = argc;
argv_ = argv;

printHeader();
printLicense();
Progress::init();

Expand Down
21 changes: 11 additions & 10 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,22 +2706,21 @@ bool FffGcodeWriter::processInsets(
gcode_layer.setBridgeWallMask(Shape());
}

const AngleDegrees overhang_angle = mesh.settings.get<AngleDegrees>("wall_overhang_angle");
if (overhang_angle >= 90)
{
// clear to disable overhang detection
gcode_layer.setOverhangMask(Shape());
}
else
const auto get_overhang_region = [&](const AngleDegrees overhang_angle) -> Shape
{
if (overhang_angle >= 90)
{
return Shape(); // keep empty to disable overhang detection
}
// the overhang mask is set to the area of the current part's outline minus the region that is considered to be supported
// the supported region is made up of those areas that really are supported by either model or support on the layer below
// expanded to take into account the overhang angle, the greater the overhang angle, the larger the supported area is
// considered to be
const coord_t overhang_width = layer_height * std::tan(overhang_angle / (180 / std::numbers::pi));
Shape overhang_region = part.outline.offset(-half_outer_wall_width).difference(outlines_below.offset(10 + overhang_width - half_outer_wall_width)).offset(10);
gcode_layer.setOverhangMask(overhang_region);
}
return part.outline.offset(-half_outer_wall_width).difference(outlines_below.offset(10 + overhang_width - half_outer_wall_width)).offset(10);
};
gcode_layer.setOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("wall_overhang_angle")));
gcode_layer.setSeamOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("seam_overhang_angle")));

const auto roofing_mask_fn = [&]() -> Shape
{
Expand Down Expand Up @@ -2753,6 +2752,8 @@ bool FffGcodeWriter::processInsets(
gcode_layer.setBridgeWallMask(Shape());
// clear to disable overhang detection
gcode_layer.setOverhangMask(Shape());
// clear to disable overhang detection
gcode_layer.setSeamOverhangMask(Shape());
// clear to disable use of roofing settings
gcode_layer.setRoofingMask(Shape());
}
Expand Down
56 changes: 55 additions & 1 deletion src/InsetOrderOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ bool InsetOrderOptimizer::addToLayer()
group_outer_walls,
disallowed_areas_for_seams_);

for (const auto& line : walls_to_be_added)
for (auto& line : walls_to_be_added)
{
if (line.is_closed_)
{
if (! settings_.get<bool>("z_seam_on_vertex"))
{
insertSeamPoint(line);
}
order_optimizer.addPolygon(&line);
}
else
Expand Down Expand Up @@ -164,6 +168,56 @@ bool InsetOrderOptimizer::addToLayer()
return added_something;
}

void InsetOrderOptimizer::insertSeamPoint(ExtrusionLine& closed_line)
{
assert(closed_line.is_closed_);
assert(closed_line.size() >= 3);

Point2LL request_point;
switch (z_seam_config_.type_)
{
case EZSeamType::USER_SPECIFIED:
request_point = z_seam_config_.pos_;
break;
case EZSeamType::SHORTEST:
request_point = gcode_layer_.getLastPlannedPositionOrStartingPosition();
break;
default:
return;
}

// NOTE: Maybe rewrite this once we can use C++23 ranges::views::adjacent
size_t closest_junction_idx = 0;
coord_t closest_distance_sqd = std::numeric_limits<coord_t>::max();
for (const auto& [i, junction] : closed_line.junctions_ | ranges::views::enumerate)
{
const auto& next_junction = closed_line.junctions_[(i + 1) % closed_line.junctions_.size()];
const coord_t distance_sqd = LinearAlg2D::getDist2FromLineSegment(junction.p_, request_point, next_junction.p_);
if (distance_sqd < closest_distance_sqd)
{
closest_distance_sqd = distance_sqd;
closest_junction_idx = i;
}
}

const auto& start_pt = closed_line.junctions_[closest_junction_idx];
const auto& end_pt = closed_line.junctions_[(closest_junction_idx + 1) % closed_line.junctions_.size()];
const auto closest_point = LinearAlg2D::getClosestOnLineSegment(request_point, start_pt.p_, end_pt.p_);
constexpr coord_t smallest_dist_sqd = 25;
if (vSize2(closest_point - start_pt.p_) <= smallest_dist_sqd || vSize2(closest_point - end_pt.p_) <= smallest_dist_sqd)
{
return;
}

// NOTE: This could also be done on a single axis (skipping the implied sqrt), but figuring out which one and then using the right values became a bit messy/verbose.
const coord_t total_dist = vSize(end_pt.p_ - start_pt.p_);
const coord_t start_dist = vSize(closest_point - start_pt.p_);
const coord_t end_dist = vSize(closest_point - end_pt.p_);
const coord_t w = ((end_pt.w_ * end_dist) / total_dist) + ((start_pt.w_ * start_dist) / total_dist);

closed_line.junctions_.insert(closed_line.junctions_.begin() + closest_junction_idx + 1, ExtrusionJunction(closest_point, w, start_pt.perimeter_index_));
}

InsetOrderOptimizer::value_type InsetOrderOptimizer::getRegionOrder(const std::vector<ExtrusionLine>& extrusion_lines, const bool outer_to_inner)
{
if (extrusion_lines.empty())
Expand Down
5 changes: 5 additions & 0 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,11 @@ void LayerPlan::setOverhangMask(const Shape& polys)
overhang_mask_ = polys;
}

void LayerPlan::setSeamOverhangMask(const Shape& polys)
{
seam_overhang_mask_ = polys;
}

void LayerPlan::setRoofingMask(const Shape& polys)
{
roofing_mask_ = polys;
Expand Down
1 change: 1 addition & 0 deletions stress_benchmark/resources/001.settings
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ infill_support_angle=40
cool_fan_speed_max=100
cool_fan_enabled=False
wall_overhang_angle=90
seam_overhang_angle=30
cool_min_speed=9
wipe_retraction_speed=5
retraction_amount=0.75
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/002.settings
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ support_xy_distance_overhang=0.4
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=4.898587196589413e-17
Expand Down Expand Up @@ -881,6 +882,7 @@ roofing_material_flow=100
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=25.0
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/003.settings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ support_xy_distance_overhang=0.42
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=5.143516556418883e-17
Expand Down Expand Up @@ -882,6 +883,7 @@ roofing_material_flow=95.0
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=25.0
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/004.settings
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ support_xy_distance_overhang=0.4
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=4.898587196589413e-17
Expand Down Expand Up @@ -882,6 +883,7 @@ roofing_material_flow=100
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=20
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/005.settings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ support_xy_distance_overhang=0.4
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=4.898587196589413e-17
Expand Down Expand Up @@ -883,6 +884,7 @@ roofing_material_flow=100
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=25.0
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/006.settings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ support_xy_distance_overhang=0.4
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=4.898587196589413e-17
Expand Down Expand Up @@ -883,6 +884,7 @@ roofing_material_flow=100
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=25.0
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/007.settings
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ support_xy_distance_overhang=0.4
retract_at_layer_change=False
wall_transition_length=0.4
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_enabled=True
cool_fan_speed_max=100.0
min_skin_width_for_expansion=4.898587196589413e-17
Expand Down Expand Up @@ -883,6 +884,7 @@ roofing_material_flow=100
meshfix_maximum_deviation=0.025
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
cool_fan_speed_max=100
speed_prime_tower=40.0
infill=0
Expand Down
2 changes: 2 additions & 0 deletions stress_benchmark/resources/008.settings
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ retraction_retract_speed=45
cool_fan_speed_max=100
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
infill_wall_line_count=0
support_supported_skin_fan_speed=100
brim_width=3
Expand Down Expand Up @@ -920,6 +921,7 @@ acceleration_wall_0=1500
cool_fan_speed_max=100
cool_fan_enabled=True
wall_overhang_angle=90
seam_overhang_angle=30
acceleration_ironing=1000
prime_tower_flow=100
top_skin_expand_distance=0.8
Expand Down
Loading

0 comments on commit 8ca2838

Please sign in to comment.