Skip to content

Commit

Permalink
Fix aligned seam & add some others:
Browse files Browse the repository at this point in the history
 - contiguous: even more aligned
 - scattered: old random: random per island per layer
 - random : new random: every loop has its own random seam.
  • Loading branch information
supermerill committed Aug 9, 2022
1 parent 038a273 commit fbaf8d5
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 144 deletions.
27 changes: 19 additions & 8 deletions resources/ui_layout/default/print.as
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ void s_not_thick_bridge_set(bool set)
// spRandom [spNearest] spAligned spRear [spCustom] spCost
// ("Cost-based") ("Random") ("Aligned") ("Rear")
// -> Corners Nearest Random Aligned Rear Custom

// spRandom spAllRandom [spNearest] spAligned spExtrAligned spRear [spCustom] spCost
// ("Cost-based") ("Scattered") ("Random") ("Aligned") ("Contiguous") ("Rear")
// -> Corners Nearest Scattered Random Aligned Contiguous Rear Custom
float user_angle = 0;
float user_travel = 0;

Expand All @@ -164,8 +168,9 @@ int s_seam_position_get(string &out get_val)
int pos = get_int("seam_position");
string seam_pos;
get_string("seam_position", seam_pos);
if(pos < 5){
if (pos == 0) return 2;
if(pos < 7){
if (pos == 0) return 2;// Scattered
if (pos == 1) return 3;// Random
return pos + 1;
} else {
float angle = get_float("seam_angle_cost");
Expand All @@ -175,26 +180,32 @@ int s_seam_position_get(string &out get_val)
user_angle = angle;
user_travel = travel;
}
return 5;
return 7;
}

void s_seam_position_set(string &in set_val, int idx)
{
if (idx == 2 ) {
set_int("seam_position", 0);
set_int("seam_position", 0); // Scattered
} else if (idx == 3) {
set_int("seam_position", 1); // Random
} else if (idx == 4) {
set_int("seam_position", 3); // Aligned
} else if (idx == 5) {
set_int("seam_position", 4); // Contiguous
} else if (idx == 6) {
set_int("seam_position", 5); // Rear
} else if (idx <= 1) {
set_int("seam_position", 5);
set_int("seam_position", 7);
if (idx == 0) {
set_percent("seam_angle_cost", 80);
set_percent("seam_travel_cost", 20);
} else {
set_percent("seam_angle_cost", 30);
set_percent("seam_travel_cost", 60);
}
} else if (idx < 5) {
set_int("seam_position", idx - 1);
} else {
set_int("seam_position", 5);
set_int("seam_position", 7);
if(user_angle > 0 || user_travel > 0){
set_percent("seam_angle_cost", user_angle);
set_percent("seam_travel_cost", user_travel);
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/default/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ group:sidetext_width$5:Advanced
setting:width$5:gap_fill_min_length
end_line
line:Seam
setting:tags$Simple$Advanced$Expert$Prusa$SuSi:script:enum$corners$Corners$nearest$Nearest$random$Random$aligned$Aligned$rear$Rear$custom$Custom:depends$seam_position$seam_angle_cost$seam_travel_cost:label$Seam position:label_width$12:sidetext_width$0:tooltip$Position of perimeters' starting points.\nCustom can be defined in Advanced or Expert mode. Cost-based settings let you choose the angle and travel cost. A high angle cost will place the seam where it can be hidden by a corner, the travel cost place the seam near the last position (often at the end of the previous infill).:s_seam_position
setting:tags$Simple$Advanced$Expert$Prusa$SuSi:script:enum$corners$Corners$nearest$Nearest$random$Scattered$allrandom$Random$aligned$Aligned$contiguous$Contiguous$rear$Rear$custom$Custom:depends$seam_position$seam_angle_cost$seam_travel_cost:label$Seam position:label_width$12:sidetext_width$0:tooltip$Position of perimeters' starting points.\nCustom can be defined in Advanced or Expert mode. Cost-based settings let you choose the angle and travel cost. A high angle cost will place the seam where it can be hidden by a corner, the travel cost place the seam near the last position (often at the end of the previous infill).:s_seam_position
# setting:tags$Expert:label_width$12:sidetext_width$0:seam_position
setting:tags$Advanced$Expert$SuSi:width$3:sidetext_width$0:seam_angle_cost
setting:tags$Advanced$Expert$SuSi:width$3:sidetext_width$0:seam_travel_cost
Expand Down
5 changes: 3 additions & 2 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3685,12 +3685,13 @@ void GCode::split_at_seam_pos(ExtrusionLoop& loop, std::unique_ptr<EdgeGrid::Gri
if (!loop.split_at_vertex(seam))
// The point is not in the original loop. Insert it.
loop.split_at(seam, true);*/
} else
m_seam_placer.place_seam(loop,
} else {
m_seam_placer.place_seam(loop, *this->layer(),
this->last_pos(), m_config.external_perimeters_first,
EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0.4),
m_print_object_instance_id,
lower_layer_edge_grid ? lower_layer_edge_grid->get() : nullptr);
}
}

namespace check_wipe {
Expand Down
297 changes: 171 additions & 126 deletions src/libslic3r/GCode/SeamPlacer.cpp

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/libslic3r/GCode/SeamPlacer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace EdgeGrid { class Grid; }

class SeamHistory {
public:
SeamHistory() { clear(); }
std::optional<Point> get_last_seam(const PrintObject* po, coord_t layer_z, const BoundingBox& island_bb);
void add_seam(const PrintObject* po, const Point& pos, const BoundingBox& island_bb);
SeamHistory() {}
std::optional<Point> get_last_seam(const PrintObject* po, double layer_z, const BoundingBox& island_bb);
void add_seam(const PrintObject* po, const Point& pos, double layer_z, const BoundingBox& island_bb);
void clear();

private:
Expand All @@ -32,8 +32,7 @@ class SeamHistory {
BoundingBox m_island_bb;
};

std::map<const PrintObject*, std::vector<SeamPoint>> m_data_last_layer;
std::map<const PrintObject*, std::vector<SeamPoint>> m_data_this_layer;
std::vector<std::pair<double, std::map<const PrintObject*, std::vector<SeamPoint>>>> m_data;
coord_t m_layer_z;
};

Expand All @@ -54,7 +53,7 @@ class SeamPlacer {
const uint16_t print_object_instance_idx,
const EdgeGrid::Grid* lower_layer_edge_grid);

void place_seam(ExtrusionLoop& loop, const Point& last_pos, bool external_first, double nozzle_diameter,
void place_seam(ExtrusionLoop& loop, const Layer& layer, const Point& last_pos, bool external_first, double nozzle_diameter,
const uint16_t print_object_instance_idx, const EdgeGrid::Grid* lower_layer_edge_grid);


Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ PerimeterGenerator::_get_nearest_point(const PerimeterGeneratorLoops &children,
if (myPolylines.paths[idx_poly].length() < dist_cut + perimeter_flow.scaled_width()/20) continue;

if ((myPolylines.paths[idx_poly].role() == erExternalPerimeter || child.is_external() )
&& this->object_config->seam_position.value != SeamPosition::spRandom) {
&& (this->object_config->seam_position.value != SeamPosition::spRandom && this->object_config->seam_position.value != SeamPosition::spAllRandom)) {
//first, try to find 2 point near enough
for (size_t idx_point = 0; idx_point < myPolylines.paths[idx_poly].polyline.points.size(); idx_point++) {
const Point &p = myPolylines.paths[idx_poly].polyline.points[idx_point];
Expand Down
6 changes: 6 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SupportMaterialInterfacePattern)

static const t_config_enum_values s_keys_map_SeamPosition{
{"random", spRandom},
{"allrandom", spAllRandom},
{"nearest", spNearest}, // unused, replaced by cost
{"cost", spCost},
{"aligned", spAligned},
{"contiguous", spExtremlyAligned},
{"rear", spRear},
{"custom", spCustom}, // for seam object
};
Expand Down Expand Up @@ -4416,11 +4418,15 @@ void PrintConfigDef::init_fff_params()
def->enum_keys_map = &ConfigOptionEnum<SeamPosition>::get_enum_values();
def->enum_values.push_back("cost");
def->enum_values.push_back("random");
def->enum_values.push_back("allrandom");
def->enum_values.push_back("aligned");
def->enum_values.push_back("contiguous");
def->enum_values.push_back("rear");
def->enum_labels.push_back(L("Cost-based"));
def->enum_labels.push_back(L("Scattered"));
def->enum_labels.push_back(L("Random"));
def->enum_labels.push_back(L("Aligned"));
def->enum_labels.push_back(L("Contiguous"));
def->enum_labels.push_back(L("Rear"));
def->mode = comSimpleAE | comPrusa;
def->set_default_value(new ConfigOptionEnum<SeamPosition>(spCost));
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ enum SupportMaterialInterfacePattern {

enum SeamPosition {
spRandom,
spAllRandom,
spNearest, //not used anymore
spAligned,
spExtremlyAligned,
spRear,
spCustom, // or seam object
spCost,
Expand Down

0 comments on commit fbaf8d5

Please sign in to comment.