Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/local/dev' into superslicer_var…
Browse files Browse the repository at this point in the history
…iant
  • Loading branch information
supermerill committed Jan 29, 2025
2 parents 28c9723 + d8e847d commit d4f908a
Show file tree
Hide file tree
Showing 26 changed files with 422 additions and 173 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ccpp_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: mkdir in deps
run: mkdir deps/build
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
run: |
curl -O -L http://ftpmirror.gnu.org/automake/automake-1.16.5.tar.gz
Expand All @@ -25,6 +29,8 @@ jobs:
make
sudo make install
automake --version
- name: mkdir in deps
run: mkdir deps/build
- name: dep cache
id: cache-action
uses: actions/cache@v3
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ccpp_mac_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: install autoconf
run: brew install autoconf
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ccpp_mac_arm_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: install autoconf
run: brew install autoconf
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ccpp_mac_arm_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: mkdir in deps
run: mkdir deps/build
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
run: |
curl -O -L http://ftpmirror.gnu.org/automake/automake-1.16.5.tar.gz
Expand All @@ -22,6 +26,8 @@ jobs:
make
sudo make install
automake --version
- name: mkdir in deps
run: mkdir deps/build
- name: dep cache
id: cache-action
uses: actions/cache@v3
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ccpp_mac_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: mkdir in deps
run: mkdir deps/build
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
run: |
curl -O -L http://ftpmirror.gnu.org/automake/automake-1.16.5.tar.gz
Expand All @@ -22,6 +26,8 @@ jobs:
make
sudo make install
automake --version
- name: mkdir in deps
run: mkdir deps/build
- name: dep cache
id: cache-action
uses: actions/cache@v3
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ccpp_mac_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: mkdir in deps
run: mkdir deps/build
- name: Install Autoconf
run: |
brew update
brew install autoconf
- name: check autoconf version
run: autoconf --version
- name: update automake for mpfr
run: |
curl -O -L http://ftpmirror.gnu.org/automake/automake-1.16.5.tar.gz
Expand All @@ -22,6 +26,8 @@ jobs:
make
sudo make install
automake --version
- name: mkdir in deps
run: mkdir deps/build
- name: dep cache
id: cache-action
uses: actions/cache@v3
Expand Down
35 changes: 21 additions & 14 deletions src/libslic3r/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,24 +362,31 @@ bool decode_color(const std::string& color_in, ColorRGBA& color_out)
return true;
}

bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGB>& colors_out)
{
colors_out = std::vector<ColorRGB>(colors_in.size(), ColorRGB::BLACK());
for (size_t i = 0; i < colors_in.size(); ++i) {
if (!decode_color(colors_in[i], colors_out[i]))
return false;
}
return true;
bool decode_colors(const std::vector<std::string> &colors_in, std::vector<ColorRGB> &colors_out) {
bool all_success = true;
colors_out.resize(colors_in.size(), ColorRGB::BLACK());
for (size_t i = 0; i < colors_in.size(); ++i) {
if (!decode_color(colors_in[i], colors_out[i])) {
// continue, please.
// return false;
all_success = false;
}
}
return all_success;
}

bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGBA>& colors_out)
{
colors_out = std::vector<ColorRGBA>(colors_in.size(), ColorRGBA::BLACK());
for (size_t i = 0; i < colors_in.size(); ++i) {
if (!decode_color(colors_in[i], colors_out[i]))
return false;
}
return true;
bool all_success = true;
colors_out.resize(colors_in.size(), ColorRGBA::BLACK());
for (size_t i = 0; i < colors_in.size(); ++i) {
if (!decode_color(colors_in[i], colors_out[i])) {
// continue, please.
// return false;
all_success = false;
}
}
return all_success;
}

static const std::array<ColorRGBA, 12> COLOR_ROTATION = {{
Expand Down
14 changes: 9 additions & 5 deletions src/libslic3r/ExtrusionEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ class ExtrusionVisitorConst {
class ExtrusionEntity
{
protected:
static inline std::atomic_int64_t id_generator;
uint64_t m_id; // for travel map
// even if no_sort, allow to reverse() us (and our entities if they allow it, but they should)
bool m_can_reverse;
ExtrusionEntity(bool can_reverse) : m_can_reverse(can_reverse) {}
ExtrusionEntity(bool can_reverse) : m_can_reverse(can_reverse) , m_id(++id_generator) {}
ExtrusionEntity(uint64_t id, bool can_reverse) : m_can_reverse(can_reverse), m_id(id) {}
public:
uint64_t get_id() const { return m_id; }
virtual ExtrusionRole role() const = 0;
virtual bool is_collection() const { return false; }
virtual bool is_loop() const { return false; }
Expand Down Expand Up @@ -183,8 +187,8 @@ class ExtrusionPath : public ExtrusionEntity

//ExtrusionPath(ExtrusionRole role) : ExtrusionEntity(true), m_attributes{role} {}
ExtrusionPath(const ExtrusionAttributes &attributes, bool can_reverse = true) : ExtrusionEntity(can_reverse), m_attributes(attributes) {}
ExtrusionPath(const ExtrusionPath &rhs) : ExtrusionEntity(rhs.m_can_reverse), polyline(rhs.polyline), m_attributes(rhs.m_attributes) {}
ExtrusionPath(ExtrusionPath &&rhs) : ExtrusionEntity(rhs.m_can_reverse), polyline(std::move(rhs.polyline)), m_attributes(rhs.m_attributes) {}
ExtrusionPath(const ExtrusionPath &rhs) : ExtrusionEntity(rhs.m_id, rhs.m_can_reverse), polyline(rhs.polyline), m_attributes(rhs.m_attributes) {}
ExtrusionPath(ExtrusionPath &&rhs) : ExtrusionEntity(rhs.m_id, rhs.m_can_reverse), polyline(std::move(rhs.polyline)), m_attributes(rhs.m_attributes) {}
ExtrusionPath(const ArcPolyline &polyline, const ExtrusionAttributes &attribs, bool can_reverse = true) : ExtrusionEntity(can_reverse), polyline(polyline), m_attributes(attribs) {}
ExtrusionPath(ArcPolyline &&polyline, const ExtrusionAttributes &attribs, bool can_reverse = true) : ExtrusionEntity(can_reverse), polyline(std::move(polyline)), m_attributes(attribs) {}

Expand Down Expand Up @@ -333,8 +337,8 @@ class ExtrusionMultiEntity : public ExtrusionEntity {
std::vector<THING> paths;

ExtrusionMultiEntity(): ExtrusionEntity(false) {};
ExtrusionMultiEntity(const ExtrusionMultiEntity &rhs) : paths(rhs.paths), ExtrusionEntity(rhs.m_can_reverse) {}
ExtrusionMultiEntity(ExtrusionMultiEntity &&rhs) : paths(std::move(rhs.paths)), ExtrusionEntity(rhs.m_can_reverse) {}
ExtrusionMultiEntity(const ExtrusionMultiEntity &rhs) : paths(rhs.paths), ExtrusionEntity(rhs.m_id, rhs.m_can_reverse) {}
ExtrusionMultiEntity(ExtrusionMultiEntity &&rhs) : paths(std::move(rhs.paths)), ExtrusionEntity(rhs.m_id, rhs.m_can_reverse) {}
ExtrusionMultiEntity(const std::vector<THING> &paths) : paths(paths), ExtrusionEntity(false) {};
ExtrusionMultiEntity(const THING &path): ExtrusionEntity(false) { this->paths.push_back(path); }

Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/ExtrusionEntityCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ExtrusionEntityCollection& ExtrusionEntityCollection::operator= (const Extrusion
{
this->m_no_sort = other.m_no_sort;
this->m_can_reverse = other.m_can_reverse;
this->m_id = other.m_id;
clear();
this->append(other.m_entities);
return *this;
Expand All @@ -48,6 +49,7 @@ void ExtrusionEntityCollection::swap(ExtrusionEntityCollection &c)
std::swap(this->m_entities, c.m_entities);
std::swap(this->m_no_sort, c.m_no_sort);
std::swap(this->m_can_reverse, c.m_can_reverse);
std::swap(this->m_id, c.m_id);
}

void ExtrusionEntityCollection::clear()
Expand Down
5 changes: 3 additions & 2 deletions src/libslic3r/ExtrusionEntityCollection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ class ExtrusionEntityCollection : public ExtrusionEntity
ExtrusionEntitiesPtr& set_entities() { return m_entities; }
ExtrusionEntityCollection() : m_no_sort(false), ExtrusionEntity(true) {}
ExtrusionEntityCollection(bool can_sort, bool can_reverse) : m_no_sort(!can_sort), ExtrusionEntity(can_reverse) {}
ExtrusionEntityCollection(const ExtrusionEntityCollection &other) : m_no_sort(other.m_no_sort), ExtrusionEntity(other.m_can_reverse) { this->append(other.entities()); }
ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : m_entities(std::move(other.m_entities)), m_no_sort(other.m_no_sort), ExtrusionEntity(other.m_can_reverse) {}
ExtrusionEntityCollection(const ExtrusionEntityCollection &other) : m_no_sort(other.m_no_sort), ExtrusionEntity(other.m_id, other.m_can_reverse) { this->append(other.entities()); }
ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : m_entities(std::move(other.m_entities)), m_no_sort(other.m_no_sort), ExtrusionEntity(other.m_id, other.m_can_reverse) {}
explicit ExtrusionEntityCollection(const ExtrusionPaths &paths);
ExtrusionEntityCollection& operator=(const ExtrusionEntityCollection &other);
ExtrusionEntityCollection& operator=(ExtrusionEntityCollection &&other) {
this->clear();
this->m_entities = std::move(other.m_entities);
this->m_no_sort = other.m_no_sort;
this->m_can_reverse = other.m_can_reverse;
this->m_id = other.m_id;
return *this;
}
~ExtrusionEntityCollection() override { clear(); }
Expand Down
12 changes: 8 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ void GCodeGenerator::_do_export(Print& print_mod, GCodeOutputStream &file, Thumb
m_wipe_tower = std::make_unique<GCode::WipeTowerIntegration>(print.config(), *print.wipe_tower_data().priming.get(), print.wipe_tower_data().tool_changes, *print.wipe_tower_data().final_purge.get());

// Set position for wipe tower generation.
file.write(this->writer().travel_to_z(first_layer_height, "Move to first z, for wipe tower"));
preamble_to_put_start_layer.append(this->writer().travel_to_z(first_layer_height, "Move to first z, for wipe tower"));
m_last_layer_z = first_layer_height;
m_max_layer_z = std::max(m_max_layer_z, this->writer().get_unlifted_position().z());

Expand Down Expand Up @@ -2572,7 +2572,8 @@ std::string GCodeGenerator::placeholder_parser_process(
} else {
//update our current position
Point pt_updated = this->gcode_to_point({pos[0], pos[1]});
if (!is_approx(pt_updated.x(), last_pos().x(), SCALED_EPSILON) ||
if (!last_pos_defined() ||
!is_approx(pt_updated.x(), last_pos().x(), SCALED_EPSILON) ||
!is_approx(pt_updated.y(), last_pos().y(), SCALED_EPSILON)) {
set_last_pos(pt_updated);
}
Expand Down Expand Up @@ -7105,7 +7106,7 @@ Polyline GCodeGenerator::travel_to(std::string &gcode, const Point &point, Extru

Point last_post_before_retract = this->last_pos_defined() ? this->last_pos() : Point{0, 0};

bool no_lift_on_retract = travel.length() <= scale_(EXTRUDER_CONFIG_WITH_DEFAULT(retract_lift_before_travel, 0)) && travel.size() > 1;
bool no_lift_on_retract = m_writer.get_extra_lift() == 0 && travel.length() <= scale_(EXTRUDER_CONFIG_WITH_DEFAULT(retract_lift_before_travel, 0)) && travel.size() > 1;
gcode += this->retract_and_wipe(false, no_lift_on_retract /*, comment*/);

// When "Wipe while retracting" is enabled, then extruder moves to another position, and travel from this position can cross perimeters.
Expand Down Expand Up @@ -7544,6 +7545,9 @@ std::string GCodeGenerator::travel_to(

bool GCodeGenerator::needs_retraction(const Polyline& travel, ExtrusionRole role /*=ExtrusionRole::None*/, coordf_t max_min_dist /*=0*/)
{
// If extra lift set, please lift (and retract, as one is dependent on the other)
if (m_writer.get_extra_lift() > 0)
return true;
coordf_t min_dist = scale_d(EXTRUDER_CONFIG_WITH_DEFAULT(retract_before_travel, 0));
if (max_min_dist > 0)
min_dist = std::min(max_min_dist, min_dist);
Expand Down Expand Up @@ -7928,7 +7932,7 @@ std::string GCodeGenerator::set_extruder(uint16_t extruder_id, double print_z, b
ensure_end_object_change_labels(gcode);

//just for testing
assert(is_approx(this->writer().get_position().z(), print_z, EPSILON));
assert(m_layer == nullptr || is_approx(this->writer().get_position().z(), print_z, EPSILON));

// if we are running a single-extruder setup, just set the extruder and return nothing
if (!m_writer.multiple_extruders) {
Expand Down
42 changes: 31 additions & 11 deletions src/libslic3r/GCode/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,20 @@ std::string GCodeWriter::set_temperature(const int16_t temperature, bool wait, i
FLAVOR_IS_NOT(gcfRepRap)) {
gcode << " T" << tool;
}
gcode << " ; " << comment << "\n";
if (this->config.gcode_comments) {
gcode << " ; " << comment;
}
gcode << "\n";
}
// emit wait (for gcfTeacup, gcfRepRap, gcfNematX)
if (wait && !can_M109) {
if ((FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepRap)))
gcode << "M116 ; wait for temperature to be reached\n";
if ((FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepRap))) {
gcode << "M116";
if (this->config.gcode_comments) {
gcode << " ; wait for temperature to be reached";
}
gcode << "\n";
}
}
// update internal var to prevent repeat
m_last_temperature = temperature;
Expand Down Expand Up @@ -329,19 +337,28 @@ std::string GCodeWriter::set_bed_temperature(uint32_t temperature, bool wait)
code = "M140"sv;
comment = "set bed temperature"sv;
}

std::ostringstream gcode;
gcode << code << " ";
if (FLAVOR_IS(gcfMach3) || FLAVOR_IS(gcfMachinekit)) {
gcode << "P";
} else {
gcode << "S";
}
gcode << temperature << " ; " << comment << "\n";

if (FLAVOR_IS(gcfTeacup) && wait)
gcode << "M116 ; wait for bed temperature to be reached\n";

gcode << temperature;
if (this->config.gcode_comments) {
gcode << " ; " << comment;
}
gcode << "\n";

if (FLAVOR_IS(gcfTeacup) && wait) {
gcode << "M116";
if (this->config.gcode_comments) {
gcode << " ; wait for temperature to be reached";
}
gcode << "\n";
}

return gcode.str();
}

Expand All @@ -368,8 +385,11 @@ std::string GCodeWriter::set_chamber_temperature(uint32_t temperature, bool wait
}

std::ostringstream gcode;
gcode << code << " " << "S";
gcode << temperature << " ; " << comment << "\n";
gcode << code << " " << "S" << temperature;
if (this->config.gcode_comments) {
gcode << " ; " << comment;
}
gcode << "\n";

return gcode.str();
}
Expand Down
Loading

0 comments on commit d4f908a

Please sign in to comment.