Skip to content

Commit

Permalink
Merge branch '5.5' into CURA-10993_simple_prime_tower_raft
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Oct 11, 2023
2 parents 6de64a2 + 0503a4c commit 586e338
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 251 deletions.
4 changes: 2 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CuraEngineConan(ConanFile):

def set_version(self):
if not self.version:
self.version = "5.5.0-alpha"
self.version = "5.5.0-beta.2"

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand Down Expand Up @@ -85,7 +85,7 @@ def requirements(self):
self.requires("arcus/5.3.0")
self.requires("asio-grpc/2.6.0")
self.requires("grpc/1.50.1")
self.requires("curaengine_grpc_definitions/(latest)@ultimaker/testing")
self.requires("curaengine_grpc_definitions/0.1.0-beta.1")
self.requires("clipper/6.4.2")
self.requires("boost/1.82.0")
self.requires("rapidjson/1.1.0")
Expand Down
3 changes: 1 addition & 2 deletions include/FffGcodeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ class FffGcodeWriter : public NoCopy
const Ratio skin_density,
const bool monotonic,
bool& added_something,
double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT,
const bool is_bridge_skin = false) const;
double fan_speed = GCodePathConfig::FAN_SPEED_DEFAULT) const;

/*!
* see if we can avoid printing a lines or zig zag style skin part in multiple segments by moving to
Expand Down
437 changes: 231 additions & 206 deletions include/PathOrderOptimizer.h

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions include/infill.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ class Infill
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_provider = nullptr,
const std::shared_ptr<LightningLayer>& lightning_layer = nullptr,
const SliceMeshStorage* mesh = nullptr,
const Polygons& prevent_small_exposed_to_air = Polygons(),
const bool is_bridge_skin = false);
const Polygons& prevent_small_exposed_to_air = Polygons());

/*!
* Generate the wall toolpaths of an infill area. It will return the inner contour and set the inner-contour.
Expand All @@ -219,7 +218,6 @@ class Infill
* \param line_width [in] The optimum wall line width of the walls
* \param infill_overlap [in] The overlap of the infill
* \param settings [in] A settings storage to use for generating variable-width walls.
* \param is_bridge_skin [in] Setting to filter out the extra skin walls while bridging
* \return The inner contour of the wall toolpaths
*/
static Polygons generateWallToolPaths(
Expand All @@ -230,8 +228,7 @@ class Infill
const coord_t infill_overlap,
const Settings& settings,
int layer_idx,
SectionType section_type,
const bool is_bridge_skin = false);
SectionType section_type);

private:
/*!
Expand Down
2 changes: 2 additions & 0 deletions include/settings/MeshPathConfigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct MeshPathConfigs
{
GCodePathConfig inset0_config{};
GCodePathConfig insetX_config{};
GCodePathConfig inset0_roofing_config{};
GCodePathConfig insetX_roofing_config{};
GCodePathConfig bridge_inset0_config{};
GCodePathConfig bridge_insetX_config{};
GCodePathConfig skin_config{};
Expand Down
124 changes: 109 additions & 15 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "utils/math.h"
#include "utils/orderOptimizer.h"

#include <range/v3/view/sliding.hpp>
#include <range/v3/view/transform.hpp>
#include <range/v3/view/zip.hpp>
#include <spdlog/spdlog.h>

Expand Down Expand Up @@ -1240,9 +1242,10 @@ void FffGcodeWriter::processSkirtBrim(const SliceDataStorage& storage, LayerPlan


// Add the support brim after the skirt_brim to gcode_layer
// Support brim is only added in layer 0
// For support brim we don't care about the order, because support doesn't need to be accurate.
const Settings& mesh_group_settings = Application::getInstance().current_slice->scene.current_mesh_group->settings;
if (extruder_nr == mesh_group_settings.get<ExtruderTrain&>("support_extruder_nr_layer_0").extruder_nr)
if ((layer_nr == 0) && (extruder_nr == mesh_group_settings.get<ExtruderTrain&>("support_extruder_nr_layer_0").extruder_nr))
{
total_line_count += storage.support_brim.size();
Polygons support_brim_lines = storage.support_brim;
Expand Down Expand Up @@ -1500,7 +1503,7 @@ void FffGcodeWriter::addMeshLayerToGCode(
{
part_order_optimizer.addPolygon(&part);
}
part_order_optimizer.optimize();
part_order_optimizer.optimize(false);
for (const PathOrdering<const SliceLayerPart*>& path : part_order_optimizer.paths)
{
addMeshPartToGCode(storage, mesh, extruder_nr, mesh_config, *path.vertices, gcode_layer);
Expand Down Expand Up @@ -2399,6 +2402,101 @@ bool FffGcodeWriter::processInsets(
}
else
{
// for layers that (partially) do not have any layers above we apply the roofing configuration
auto use_roofing_config = [&part, &mesh, &gcode_layer]()
{
const auto getOutlineOnLayer = [mesh](const SliceLayerPart& part_here, const LayerIndex layer2_nr) -> Polygons
{
Polygons result;
if (layer2_nr >= static_cast<int>(mesh.layers.size()))
{
return result;
}
const SliceLayer& layer2 = mesh.layers[layer2_nr];
for (const SliceLayerPart& part2 : layer2.parts)
{
if (part_here.boundaryBox.hit(part2.boundaryBox))
{
result.add(part2.outline);
}
}
return result;
};

const auto filled_area_above = [&getOutlineOnLayer, &part, &mesh, &gcode_layer]() -> Polygons
{
const size_t roofing_layer_count = std::min(mesh.settings.get<size_t>("roofing_layer_count"), mesh.settings.get<size_t>("top_layers"));
const bool no_small_gaps_heuristic = mesh.settings.get<bool>("skin_no_small_gaps_heuristic");
const int layer_nr = gcode_layer.getLayerNr();
auto filled_area_above = getOutlineOnLayer(part, layer_nr + roofing_layer_count);
if (! no_small_gaps_heuristic)
{
for (int layer_nr_above = layer_nr + 1; layer_nr_above < layer_nr + roofing_layer_count; layer_nr_above++)
{
Polygons outlines_above = getOutlineOnLayer(part, layer_nr_above);
filled_area_above = filled_area_above.intersection(outlines_above);
}
}
if (layer_nr > 0)
{
// if the skin has air below it then cutting it into regions could cause a region
// to be wholely or partly above air and it may not be printable so restrict
// the regions that have air above (the visible regions) to not include any area that
// has air below (fixes https://github.com/Ultimaker/Cura/issues/2656)

// set air_below to the skin area for the current layer that has air below it
Polygons air_below = getOutlineOnLayer(part, layer_nr).difference(getOutlineOnLayer(part, layer_nr - 1));

if (! air_below.empty())
{
// add the polygons that have air below to the no air above polygons
filled_area_above = filled_area_above.unionPolygons(air_below);
}
}

return filled_area_above;
}();

if (filled_area_above.empty())
{
return true;
}

const auto point_view = ranges::views::transform(
[](auto extrusion_junction)
{
return extrusion_junction.p;
});

for (const auto& path : part.wall_toolpaths)
{
for (const auto& wall : path)
{
for (const auto& p : wall | point_view)
{
if (! filled_area_above.inside(p))
{
return true;
}
}

for (const auto& window : wall | point_view | ranges::views::sliding(2))
{
auto p0 = window[0];
auto p1 = window[1];
if (PolygonUtils::polygonCollidesWithLineSegment(filled_area_above, p0, p1))
{
return true;
}
}
}
}
return false;
}();

const GCodePathConfig& inset0_config = use_roofing_config ? mesh_config.inset0_roofing_config : mesh_config.inset0_config;
const GCodePathConfig& insetX_config = use_roofing_config ? mesh_config.insetX_roofing_config : mesh_config.insetX_config;

// Main case: Optimize the insets with the InsetOrderOptimizer.
const coord_t wall_x_wipe_dist = 0;
const ZSeamConfig z_seam_config(
Expand All @@ -2412,8 +2510,8 @@ bool FffGcodeWriter::processInsets(
gcode_layer,
mesh.settings,
extruder_nr,
mesh_config.inset0_config,
mesh_config.insetX_config,
inset0_config,
insetX_config,
mesh_config.bridge_inset0_config,
mesh_config.bridge_insetX_config,
mesh.settings.get<bool>("travel_retract_before_outer_wall"),
Expand Down Expand Up @@ -2735,8 +2833,7 @@ void FffGcodeWriter::processTopBottom(
skin_density,
monotonic,
added_something,
fan_speed,
is_bridge_skin);
fan_speed);
}

void FffGcodeWriter::processSkinPrintFeature(
Expand All @@ -2753,8 +2850,7 @@ void FffGcodeWriter::processSkinPrintFeature(
const Ratio skin_density,
const bool monotonic,
bool& added_something,
double fan_speed,
const bool is_bridge_skin) const
double fan_speed) const
{
Polygons skin_polygons;
Polygons skin_lines;
Expand Down Expand Up @@ -2814,8 +2910,7 @@ void FffGcodeWriter::processSkinPrintFeature(
nullptr,
nullptr,
nullptr,
small_areas_on_surface ? Polygons() : exposed_to_air,
is_bridge_skin);
small_areas_on_surface ? Polygons() : exposed_to_air);

// add paths
if (! skin_polygons.empty() || ! skin_lines.empty() || ! skin_paths.empty())
Expand All @@ -2841,10 +2936,10 @@ void FffGcodeWriter::processSkinPrintFeature(
gcode_layer,
mesh.settings,
extruder_nr,
mesh_config.skin_config,
mesh_config.skin_config,
mesh_config.skin_config,
mesh_config.skin_config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -3060,7 +3155,6 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer
}
island_order_optimizer.optimize();

const auto support_brim_line_count = infill_extruder.settings.get<coord_t>("support_brim_line_count");
const auto support_connect_zigzags = infill_extruder.settings.get<bool>("support_connect_zigzags");
const auto support_structure = infill_extruder.settings.get<ESupportStructure>("support_structure");
const Point infill_origin;
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 = false;
const auto group_outer_walls = settings.get<bool>("group_outer_walls");
// 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
21 changes: 11 additions & 10 deletions src/SkeletalTrapezoidationGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

#include "SkeletalTrapezoidationGraph.h"

#include <unordered_map>
#include "utils/linearAlg2D.h"
#include "utils/macros.h"

#include <spdlog/spdlog.h>

#include "utils/linearAlg2D.h"
#include "utils/macros.h"
#include <unordered_map>

namespace cura
{

STHalfEdge::STHalfEdge(SkeletalTrapezoidationEdge data) : HalfEdge(data)
STHalfEdge::STHalfEdge(SkeletalTrapezoidationEdge data)
: HalfEdge(data)
{
}

Expand Down Expand Up @@ -131,7 +132,8 @@ STHalfEdge* STHalfEdge::getNextUnconnected()
return result->twin;
}

STHalfEdgeNode::STHalfEdgeNode(SkeletalTrapezoidationJoint data, Point p) : HalfEdgeNode(data, p)
STHalfEdgeNode::STHalfEdgeNode(SkeletalTrapezoidationJoint data, Point p)
: HalfEdgeNode(data, p)
{
}

Expand Down Expand Up @@ -223,7 +225,10 @@ void SkeletalTrapezoidationGraph::collapseSmallEdges(coord_t snap_dist)
}
};

auto should_collapse = [snap_dist](node_t* a, node_t* b) { return shorterThen(a->p - b->p, snap_dist); };
auto should_collapse = [snap_dist](node_t* a, node_t* b)
{
return shorterThen(a->p - b->p, snap_dist);
};

for (auto edge_it = edges.begin(); edge_it != edges.end();)
{
Expand Down Expand Up @@ -253,10 +258,6 @@ void SkeletalTrapezoidationGraph::collapseSmallEdges(coord_t snap_dist)
{
edge_from_3->from = quad_mid->from;
edge_from_3->twin->to = quad_mid->from;
if (count > 50)
{
std::cerr << edge_from_3->from->p << " - " << edge_from_3->to->p << '\n';
}
if (++count > 1000)
{
break;
Expand Down
4 changes: 2 additions & 2 deletions src/SkirtBrim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ void SkirtBrim::generateSupportBrim()
}

storage.support_brim.add(brim_line);

const coord_t length = skirt_brim_length + storage.support_brim.polygonLength();
// In case of adhesion::NONE length of support brim is only the length of the brims formed for the support
const coord_t length = (adhesion_type == EPlatformAdhesion::NONE) ? skirt_brim_length : skirt_brim_length + storage.support_brim.polygonLength();
if (skirt_brim_number + 1 >= line_count && length > 0 && length < minimal_length) // Make brim or skirt have more lines when total length is too small.
{
line_count++;
Expand Down
10 changes: 4 additions & 6 deletions src/infill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ Polygons Infill::generateWallToolPaths(
const coord_t infill_overlap,
const Settings& settings,
int layer_idx,
SectionType section_type,
const bool is_bridge_skin)
SectionType section_type)
{
outer_contour = outer_contour.offset(infill_overlap);
scripta::log("infill_outer_contour", outer_contour, section_type, layer_idx, scripta::CellVDI{ "infill_overlap", infill_overlap });

Polygons inner_contour;
if ((wall_line_count > 0) && (! is_bridge_skin))
if (wall_line_count > 0)
{
constexpr coord_t wall_0_inset = 0; // Don't apply any outer wall inset for these. That's just for the outer wall.
WallToolPaths wall_toolpaths(outer_contour, line_width, wall_line_count, wall_0_inset, settings, layer_idx, section_type);
Expand All @@ -91,15 +90,14 @@ void Infill::generate(
const std::shared_ptr<SierpinskiFillProvider>& cross_fill_provider,
const std::shared_ptr<LightningLayer>& lightning_trees,
const SliceMeshStorage* mesh,
const Polygons& prevent_small_exposed_to_air,
const bool is_bridge_skin)
const Polygons& prevent_small_exposed_to_air)
{
if (outer_contour.empty())
{
return;
}

inner_contour = generateWallToolPaths(toolpaths, outer_contour, wall_line_count, infill_line_width, infill_overlap, settings, layer_idx, section_type, is_bridge_skin);
inner_contour = generateWallToolPaths(toolpaths, outer_contour, wall_line_count, infill_line_width, infill_overlap, settings, layer_idx, section_type);
scripta::log("infill_inner_contour_0", inner_contour, section_type, layer_idx);

// It does not make sense to print a pattern in a small region. So the infill region
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ gcode_paths_modify_request::value_type
gcode_path->set_retract(path.retract);
gcode_path->set_unretract_before_last_travel_move(path.unretract_before_last_travel_move);
gcode_path->set_perform_z_hop(path.perform_z_hop);
gcode_path->set_perform_prime(path.perform_prime);
gcode_path->set_skip_agressive_merge_hint(path.skip_agressive_merge_hint);
gcode_path->set_done(path.done);
gcode_path->set_fan_speed(path.getFanSpeed());
Expand Down Expand Up @@ -458,6 +459,7 @@ gcode_paths_modify_response::native_value_type
.retract = gcode_path_msg.retract(),
.unretract_before_last_travel_move = gcode_path_msg.unretract_before_last_travel_move(),
.perform_z_hop = gcode_path_msg.perform_z_hop(),
.perform_prime = gcode_path_msg.perform_prime(),
.skip_agressive_merge_hint = gcode_path_msg.skip_agressive_merge_hint(),
.done = gcode_path_msg.done(),
.fan_speed = gcode_path_msg.fan_speed(),
Expand Down
Loading

0 comments on commit 586e338

Please sign in to comment.