mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-22 00:12:34 +00:00
Merge branch 'main' into feat/ota-opc-ci
This commit is contained in:
@@ -73,6 +73,7 @@ using namespace nlohmann;
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "libslic3r/BlacklistedLibraryCheck.hpp"
|
||||
#include "libslic3r/FlushVolCalc.hpp"
|
||||
#include "libslic3r/LayOnFace.hpp"
|
||||
|
||||
#include "libslic3r/Orient.hpp"
|
||||
#include "libslic3r/PNGReadWrite.hpp"
|
||||
@@ -85,6 +86,8 @@ using namespace nlohmann;
|
||||
#ifdef WIN32
|
||||
#include "dev-utils/BaseException.h"
|
||||
#endif
|
||||
#include "slic3r/Utils/MeshInspect.hpp"
|
||||
#include "slic3r/Utils/PaintCLI.hpp"
|
||||
#include "slic3r/GUI/PartPlate.hpp"
|
||||
#include "slic3r/GUI/BitmapCache.hpp"
|
||||
#include "slic3r/GUI/OpenGLManager.hpp"
|
||||
@@ -189,6 +192,9 @@ typedef struct _sliced_info {
|
||||
int wall_loops{0};
|
||||
std::vector<std::string> upward_machines;
|
||||
std::vector<std::string> downward_machines;
|
||||
// Structured slicing warnings for result.json, and whether --strict was on.
|
||||
nlohmann::json warnings = nlohmann::json::array();
|
||||
bool strict_mode {false};
|
||||
}sliced_info_t;
|
||||
std::vector<PrintBase::SlicingStatus> g_slicing_warnings;
|
||||
|
||||
@@ -424,6 +430,21 @@ static PrinterTechnology get_printer_technology(const DynamicConfig &config)
|
||||
return(ret);}
|
||||
#endif
|
||||
|
||||
// Records a structured slicing warning so a CI or scripted consumer can branch on
|
||||
// a stable `class` string instead of matching stderr. Warnings are kept on the
|
||||
// run's sliced_info and emitted as the top-level "warnings" array of result.json;
|
||||
// a non-empty array does not by itself mean the run failed. Under --strict a
|
||||
// NON_CRITICAL warning additionally ends the run non-zero.
|
||||
//
|
||||
// result.json is written on Linux only (see the guard in record_exit_reson), so
|
||||
// neither "warnings" nor "strict_mode" reaches Windows or macOS.
|
||||
static void cli_record_warning(sliced_info_t &sliced_info, const std::string &cls,
|
||||
nlohmann::json details = nlohmann::json::object())
|
||||
{
|
||||
details["class"] = cls;
|
||||
sliced_info.warnings.push_back(std::move(details));
|
||||
}
|
||||
|
||||
void record_exit_reson(std::string outputdir, int code, int plate_id, std::string error_message, sliced_info_t& sliced_info, std::map<std::string, std::string> key_values = std::map<std::string, std::string>())
|
||||
{
|
||||
#if defined(__linux__) || defined(__LINUX__)
|
||||
@@ -462,6 +483,9 @@ void record_exit_reson(std::string outputdir, int code, int plate_id, std::strin
|
||||
for (auto& iter: key_values)
|
||||
j[iter.first] = iter.second;
|
||||
|
||||
j["warnings"] = sliced_info.warnings;
|
||||
j["strict_mode"] = sliced_info.strict_mode;
|
||||
|
||||
boost::nowide::ofstream c;
|
||||
c.open(result_file, std::ios::out | std::ios::trunc);
|
||||
c << j.dump(1, '\t') << std::endl;
|
||||
@@ -1381,12 +1405,68 @@ int CLI::run(int argc, char **argv)
|
||||
bool need_skip = (skip_objects.size() > 0)?true:false;
|
||||
long long global_begin_time = 0, global_current_time;
|
||||
sliced_info_t sliced_info;
|
||||
// Read up front so result.json reports it for early failures too.
|
||||
sliced_info.strict_mode = m_config.opt_bool("strict");
|
||||
// --no-check skips the check behind the only NON_CRITICAL warning --strict acts on
|
||||
// (support needed but disabled), from the point it appears among the actions. The pair
|
||||
// would make --strict a no-op or depend on argument order, so refuse it.
|
||||
if (sliced_info.strict_mode && m_config.opt_bool("no_check")) {
|
||||
boost::nowide::cerr << "--strict cannot be combined with --no-check" << std::endl;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
std::map<std::string, std::string> record_key_values;
|
||||
|
||||
ConfigOptionBool* downward_check_option = m_config.option<ConfigOptionBool>("downward_check");
|
||||
if (downward_check_option)
|
||||
downward_check = downward_check_option->value;
|
||||
|
||||
// --inspect-mesh prints its JSON and exits, so any action that does work of its
|
||||
// own (slicing, exporting) would be skipped without notice. Reject those up front;
|
||||
// only options that merely tune how the input is loaded may come along.
|
||||
if (std::find(m_actions.begin(), m_actions.end(), "inspect_mesh") != m_actions.end()) {
|
||||
static const std::set<std::string> inspect_compatible = { "inspect_mesh", "uptodate", "load_defaultfila", "min_save",
|
||||
"mtcpp", "mstpp", "no_check", "normative_check", "pipe" };
|
||||
for (const std::string &action : m_actions) {
|
||||
if (inspect_compatible.count(action) == 0) {
|
||||
std::string flag = action;
|
||||
std::replace(flag.begin(), flag.end(), '_', '-');
|
||||
boost::nowide::cerr << "--inspect-mesh cannot be combined with --" << flag << std::endl;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
}
|
||||
// Without input there is nothing to inspect; fail rather than print nothing and exit 0.
|
||||
if (m_input_files.empty() && m_config.opt_string("load_assemble_list").empty()) {
|
||||
boost::nowide::cerr << "--inspect-mesh needs an input file or --load-assemble-list" << std::endl;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
// --inspect-paint prints its JSON and exits, so any action that does work of its
|
||||
// own (slicing, exporting) would be skipped without notice. Reject those up front;
|
||||
// only options that merely tune how the input is loaded may come along.
|
||||
if (std::find(m_actions.begin(), m_actions.end(), "inspect_paint") != m_actions.end()) {
|
||||
static const std::set<std::string> inspect_compatible = { "inspect_paint", "uptodate", "load_defaultfila", "min_save",
|
||||
"mtcpp", "mstpp", "no_check", "normative_check", "pipe" };
|
||||
for (const std::string &action : m_actions) {
|
||||
if (inspect_compatible.count(action) == 0) {
|
||||
std::string flag = action;
|
||||
std::replace(flag.begin(), flag.end(), '_', '-');
|
||||
boost::nowide::cerr << "--inspect-paint cannot be combined with --" << flag << std::endl;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
}
|
||||
// Without input there is nothing to inspect; fail rather than print nothing and exit 0.
|
||||
if (m_input_files.empty() && m_config.opt_string("load_assemble_list").empty()) {
|
||||
boost::nowide::cerr << "--inspect-paint needs an input file or --load-assemble-list" << std::endl;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
// --export-settings - writes its JSON to stdout, so reject every action or transform that may write there
|
||||
// too (--info, --help, --orient, slicing and exporting). The allowed ones do nothing when nothing is
|
||||
// sliced or exported.
|
||||
@@ -4810,6 +4890,64 @@ int CLI::run(int argc, char **argv)
|
||||
for (auto &o : model.objects)
|
||||
// this affects volumes:
|
||||
o->rotate(Geometry::deg2rad(m_config.opt_float(opt_key)), Y);
|
||||
} else if (opt_key == "ground_largest_face" || opt_key == "ground_face_normal" || opt_key == "ground_face_point") {
|
||||
// Each instance is laid on one of its lay-on-face planes, which are computed from the current part
|
||||
// transformations, so the rotations given before this option are respected. A direction or point is in
|
||||
// object coordinates, so it names the same face for every instance of an object.
|
||||
std::function<int(const std::vector<LayOnFacePlane>&, const Transform3d&)> pick;
|
||||
if (opt_key == "ground_largest_face") {
|
||||
if (m_config.opt_bool(opt_key))
|
||||
pick = [](const std::vector<LayOnFacePlane>& planes, const Transform3d&) { return find_largest_plane(planes); };
|
||||
} else {
|
||||
// Only options given on the command line reach this loop, so an empty value is malformed input too.
|
||||
const std::string& value = m_config.opt_string(opt_key);
|
||||
Vec3d v;
|
||||
int consumed = 0;
|
||||
if (sscanf(value.c_str(), "%lf,%lf,%lf%n", &v.x(), &v.y(), &v.z(), &consumed) != 3 || consumed != int(value.size()) ||
|
||||
!v.allFinite() || (opt_key == "ground_face_normal" && v.norm() < EPSILON)) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Invalid params: %1% expects three comma-separated numbers, got \"%2%\"") % opt_key % value;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
if (opt_key == "ground_face_normal")
|
||||
pick = [v](const std::vector<LayOnFacePlane>& planes, const Transform3d&) { return find_plane_by_normal(planes, v); };
|
||||
else
|
||||
pick = [v](const std::vector<LayOnFacePlane>& planes, const Transform3d& inst_matrix) {
|
||||
return find_plane_at_point(planes, inst_matrix, v, 0.01);
|
||||
};
|
||||
}
|
||||
if (pick) {
|
||||
size_t laid = 0, missed = 0;
|
||||
for (auto& model : m_models) {
|
||||
model.add_default_instances();
|
||||
for (ModelObject* o : model.objects)
|
||||
for (size_t i = 0; i < o->instances.size(); ++i) {
|
||||
const Transform3d inst_matrix = o->instances[i]->get_matrix_no_offset();
|
||||
const std::vector<LayOnFacePlane> planes = lay_on_face_planes(*o, inst_matrix);
|
||||
if (planes.empty()) {
|
||||
// Small or smooth parts (e.g. a sphere) have no face to rest on; the gizmo offers none either.
|
||||
BOOST_LOG_TRIVIAL(warning) << boost::format("%1%: object %2% has no face large enough to lay on, left as it is") % opt_key % o->name;
|
||||
continue;
|
||||
}
|
||||
const int idx = pick(planes, inst_matrix);
|
||||
if (idx < 0) {
|
||||
// Only a point can miss: with several objects it usually belongs to one of them.
|
||||
BOOST_LOG_TRIVIAL(warning) << boost::format("%1%: no face of object %2% contains the point, left as it is") % opt_key % o->name;
|
||||
++missed;
|
||||
continue;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: object %2% instance %3% laid on the %4% mm2 face with normal %5%")
|
||||
% opt_key % o->name % i % planes[idx].area % planes[idx].normal.transpose();
|
||||
lay_on_face(*o, i, planes[idx].normal);
|
||||
++laid;
|
||||
}
|
||||
}
|
||||
if (laid == 0 && missed > 0) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Invalid params: %1%: no face of any object contains the point") % opt_key;
|
||||
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
|
||||
flush_and_exit(CLI_INVALID_PARAMS);
|
||||
}
|
||||
}
|
||||
} else if (opt_key == "scale") {
|
||||
float ratio = m_config.opt_float(opt_key);
|
||||
if (ratio <= 0.f) {
|
||||
@@ -5969,6 +6107,53 @@ int CLI::run(int argc, char **argv)
|
||||
model.add_default_instances();
|
||||
model.print_info();
|
||||
}
|
||||
} else if (opt_key == "inspect_mesh") {
|
||||
// Machine-readable alternative to --info. Registered as an action so it satisfies the
|
||||
// "needs an action" check and bypasses the GUI fallback, then exits once the JSON is out.
|
||||
for (Model &model : m_models) {
|
||||
model.add_default_instances();
|
||||
Slic3r::MeshInspect::inspect_to_json(model, m_input_files, boost::nowide::cout);
|
||||
}
|
||||
boost::nowide::cout.flush();
|
||||
// Conflicting actions were rejected before loading. Finish like the end of run().
|
||||
// flush_and_exit() is not usable here: it prints "found error ..." to stdout,
|
||||
// which would corrupt the JSON.
|
||||
#if defined(__linux__) || defined(__LINUX__)
|
||||
if (g_cli_callback_mgr.is_started()) {
|
||||
PrintBase::SlicingStatus slicing_status{100, "All done, Success"};
|
||||
cli_status_callback(slicing_status);
|
||||
}
|
||||
g_cli_callback_mgr.stop();
|
||||
#endif
|
||||
for (Model &m : m_models)
|
||||
m.remove_backup_path_if_exist();
|
||||
record_exit_reson(outfile_dir, CLI_SUCCESS, plate_to_slice, cli_errors[CLI_SUCCESS], sliced_info);
|
||||
boost::nowide::cerr.flush();
|
||||
return CLI_SUCCESS;
|
||||
} else if (opt_key == "inspect_paint") {
|
||||
// --inspect-paint — read the per-facet enforcer/blocker/extruder/
|
||||
// fuzzy state from the loaded model and emit a JSON summary.
|
||||
// Machine-readable alternative to opening the paint gizmos.
|
||||
for (Model &model : m_models) {
|
||||
model.add_default_instances();
|
||||
Slic3r::PaintCLI::inspect_to_json(model, m_input_files, boost::nowide::cout);
|
||||
}
|
||||
boost::nowide::cout.flush();
|
||||
// The tooltip promises "then exit"; conflicting actions were rejected before
|
||||
// loading. Finish like the end of run(). flush_and_exit() is not usable here:
|
||||
// it prints "found error ..." to stdout, which would corrupt the JSON.
|
||||
#if defined(__linux__) || defined(__LINUX__)
|
||||
if (g_cli_callback_mgr.is_started()) {
|
||||
PrintBase::SlicingStatus slicing_status{100, "All done, Success"};
|
||||
cli_status_callback(slicing_status);
|
||||
}
|
||||
g_cli_callback_mgr.stop();
|
||||
#endif
|
||||
for (Model &m : m_models)
|
||||
m.remove_backup_path_if_exist();
|
||||
record_exit_reson(outfile_dir, CLI_SUCCESS, plate_to_slice, cli_errors[CLI_SUCCESS], sliced_info);
|
||||
boost::nowide::cerr.flush();
|
||||
return CLI_SUCCESS;
|
||||
} else if (opt_key == "uptodate") {
|
||||
//already processed before
|
||||
} else if (opt_key == "min_save") {
|
||||
@@ -6009,6 +6194,8 @@ int CLI::run(int argc, char **argv)
|
||||
export_3mf_file = m_config.opt_string(opt_key);
|
||||
}else if(opt_key=="no_check"){
|
||||
no_check = m_config.opt_bool(opt_key);
|
||||
}else if(opt_key=="strict"){
|
||||
//already read into sliced_info at the start of run()
|
||||
//} else if (opt_key == "export_gcode" || opt_key == "export_sla" || opt_key == "slice") {
|
||||
} else if (opt_key == "normative_check") {
|
||||
//already processed before
|
||||
@@ -6717,6 +6904,15 @@ int CLI::run(int argc, char **argv)
|
||||
|
||||
if (status.warning_level == PrintStateBase::WarningLevel::NON_CRITICAL) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "plate "<< index+1<< ": found NON_CRITICAL slicing warnings: "<<status.text <<std::endl;
|
||||
// Always record for AI/CI consumers; under --strict, elevate to a
|
||||
// non-zero exit so scripted pipelines don't ship a "warning OK" slice.
|
||||
cli_record_warning(sliced_info, "slicing_warning_non_critical",
|
||||
nlohmann::json{{"plate_id", index+1}, {"text", status.text}});
|
||||
if (sliced_info.strict_mode) {
|
||||
sliced_info.sliced_plates.push_back(sliced_plate_info);
|
||||
record_exit_reson(outfile_dir, CLI_SLICING_ERROR, index+1, cli_errors[CLI_SLICING_ERROR], sliced_info);
|
||||
flush_and_exit(CLI_SLICING_ERROR);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(warning) << boost::format("plate %1%: found slicing warnings: %2%, no_check=%3%")%(index+1) %status.text %no_check;
|
||||
|
||||
@@ -260,6 +260,8 @@ set(lisbslic3r_sources
|
||||
GCode/SmallAreaInfillFlowCompensator.hpp
|
||||
GCode/SpiralVase.cpp
|
||||
GCode/SpiralVase.hpp
|
||||
GCode/WipePathHelpers.cpp
|
||||
GCode/WipePathHelpers.hpp
|
||||
GCode/ThumbnailData.cpp
|
||||
GCode/ThumbnailData.hpp
|
||||
GCode/Thumbnails.cpp
|
||||
@@ -302,6 +304,8 @@ set(lisbslic3r_sources
|
||||
Layer.cpp
|
||||
Layer.hpp
|
||||
LayerRegion.cpp
|
||||
LayOnFace.cpp
|
||||
LayOnFace.hpp
|
||||
libslic3r.cpp
|
||||
libslic3r.h
|
||||
Line.cpp
|
||||
|
||||
@@ -454,6 +454,10 @@ class ExtrusionLoop : public ExtrusionEntity
|
||||
{
|
||||
public:
|
||||
ExtrusionPaths paths;
|
||||
// ORCA: Set on a loop extruded entirely in mid air and out of reach of the layer below: it has
|
||||
// nothing to lean on until this layer is bridged, so the G-code writer holds it back until the
|
||||
// infill is down. See defer_unsupported_loops() in PerimeterGenerator.cpp.
|
||||
bool print_after_infill = false;
|
||||
|
||||
ExtrusionLoop(ExtrusionLoopRole role = elrDefault) : m_loop_role(role) {}
|
||||
ExtrusionLoop(const ExtrusionPaths &paths, ExtrusionLoopRole role = elrDefault) : paths(paths), m_loop_role(role) {}
|
||||
|
||||
+187
-102
@@ -1,5 +1,6 @@
|
||||
#include "BoundingBox.hpp"
|
||||
#include "Config.hpp"
|
||||
#include "GCode/WipePathHelpers.hpp"
|
||||
#include "GCodeWriter.hpp"
|
||||
#include "Polygon.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
@@ -438,7 +439,6 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
auto& writer = gcodegen.writer();
|
||||
auto& config = gcodegen.config();
|
||||
auto extruder = writer.filament();
|
||||
auto extruder_id = extruder->extruder_id();
|
||||
auto last_pos = gcodegen.last_pos();
|
||||
|
||||
// Declare & initialize retraction lengths
|
||||
@@ -475,13 +475,13 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
wipe_speed = std::max(wipe_speed, 10.0);
|
||||
|
||||
// Process wipe path & calculate wipe path length
|
||||
double wipe_dist = scale_(config.wipe_distance.get_at(extruder_id));
|
||||
double wipe_dist = scale_(config.wipe_distance.get_at(extruder->config_index()));
|
||||
Polyline wipe_path = {last_pos};
|
||||
wipe_path.append(this->path.points.begin() + 1, this->path.points.end());
|
||||
double wipe_path_length = std::min(wipe_path.length(), wipe_dist);
|
||||
|
||||
// Calculate the maximum retraction amount during wipe
|
||||
retraction_length_during_wipe = config.retraction_speed.get_at(extruder_id) *
|
||||
retraction_length_during_wipe = config.retraction_speed.get_at(extruder->config_index()) *
|
||||
unscale_(wipe_path_length) / wipe_speed;
|
||||
|
||||
// If the maximum retraction amount during wipe is too small,
|
||||
@@ -564,6 +564,16 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
return default_value;
|
||||
}
|
||||
|
||||
// Orca: rebuild the stored wipe path while preserving Polyline's boundary deduplication.
|
||||
void Wipe::update_path(const ExtrusionPaths &paths, bool reverse)
|
||||
{
|
||||
reset_path();
|
||||
for (const ExtrusionPath& extrusion_path : paths)
|
||||
path.append(extrusion_path.polyline.to_polyline());
|
||||
if (reverse)
|
||||
path.reverse();
|
||||
}
|
||||
|
||||
std::string Wipe::wipe(GCode& gcodegen,double length, bool toolchange, bool is_last)
|
||||
{
|
||||
std::string gcode;
|
||||
@@ -616,14 +626,11 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
if (gcodegen.enable_cooling_markers() && !is_last)
|
||||
cooling_mark = /*gcodegen.config().role_based_wipe_speed ? ";_EXTERNAL_PERIMETER" : */";_WIPE";
|
||||
|
||||
// Orca: set speed once because wipe_speed is constant for all segments.
|
||||
gcode += gcodegen.writer().set_speed(_wipe_speed * 60, "", cooling_mark);
|
||||
for (const Line& line : wipe_path.lines()) {
|
||||
double segment_length = line.length();
|
||||
double dE = length * (segment_length / wipe_dist);
|
||||
//BBS: fix this FIXME
|
||||
//FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
|
||||
// Is it here for the cooling markers? Or should it be outside of the cycle?
|
||||
//gcode += gcodegen.writer().set_speed(wipe_speed * 60, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
|
||||
gcode += gcodegen.writer().extrude_to_xy(
|
||||
gcodegen.point_to_gcode(line.b),
|
||||
-dE,
|
||||
@@ -1021,11 +1028,21 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
double current_z = gcodegen.writer().get_position().z();
|
||||
if (z == -1.) // in case no specific z was provided, print at current_z pos
|
||||
z = current_z;
|
||||
if (!is_approx(z, current_z)) {
|
||||
// Orca: wipe_tower_no_sparse_layers crash guard. With sparse layers skipped the tower is
|
||||
// compacted far below the object, so descending to it is only safe once the nozzle is parked
|
||||
// over the tower - which is what the is_finish_first travel above does. Otherwise the nozzle
|
||||
// is still over the model and this descent would drive it into the print, so defer it to the
|
||||
// re-descents below, which run after the travel to the tower.
|
||||
const bool defer_compacted_descend = m_sparse_layers_skipped
|
||||
&& !tcr.priming && !tcr.is_finish_first && (current_z - z) > EPSILON;
|
||||
if (!is_approx(z, current_z) && !defer_compacted_descend) {
|
||||
gcode += gcodegen.writer().retract();
|
||||
gcode += gcodegen.writer().travel_to_z(z, "Travel down to the last wipe tower layer.");
|
||||
gcode += gcodegen.writer().unretract();
|
||||
}
|
||||
// Tower compacted below the object, so any extrusion emitted without an explicit z has to be
|
||||
// pulled back down to it first.
|
||||
const bool compacted_below_object = m_sparse_layers_skipped && z >= 0. && (tcr.print_z - z) > EPSILON;
|
||||
|
||||
// Process the end filament gcode.
|
||||
bool add_change_filament_624 = false;
|
||||
@@ -1078,11 +1095,23 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
std::string nozzle_change_gcode_trans;
|
||||
if (is_nozzle_change) {
|
||||
// move to start_pos before nozzle change
|
||||
// Orca: travel_to() lifts to the object layer height to clear the print. That lift is
|
||||
// needed when arriving from the model, but is a wasted full-height Z bounce when the
|
||||
// nozzle already sits on the compacted tower, so travel at the compacted z instead.
|
||||
const bool compact_intower_nc_travel = compacted_below_object
|
||||
&& (tcr.print_z - gcodegen.writer().get_position().z()) > EPSILON;
|
||||
std::string start_pos_str;
|
||||
start_pos_str = gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(tcr.nozzle_change_result.start_pos) + plate_origin_2d), erMixed,
|
||||
"Move to nozzle change start pos");
|
||||
"Move to nozzle change start pos", compact_intower_nc_travel ? z : DBL_MAX);
|
||||
check_add_eol(start_pos_str);
|
||||
nozzle_change_gcode_trans += start_pos_str;
|
||||
// The nozzle-change wipe below carries no explicit z, so it would extrude at the object
|
||||
// layer height and float above the compacted tower. Descend unless the travel stayed down.
|
||||
if (!compact_intower_nc_travel && compacted_below_object) {
|
||||
std::string nc_z_descend = gcodegen.writer().travel_to_z(z, "Descend to compacted wipe tower z (no sparse layers)");
|
||||
check_add_eol(nc_z_descend);
|
||||
nozzle_change_gcode_trans += nc_z_descend;
|
||||
}
|
||||
nozzle_change_gcode_trans += gcodegen.unretract();
|
||||
nozzle_change_gcode_trans += transform_gcode(tcr.nozzle_change_result.gcode, tcr.nozzle_change_result.start_pos, wipe_tower_offset, wipe_tower_rotation);
|
||||
gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, transform_wt_pt(tcr.nozzle_change_result.end_pos) + plate_origin_2d));
|
||||
@@ -1421,6 +1450,15 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
|
||||
start_filament_gcode_str = start_filament_gcode_str + wipe_next_start_point_str + toolchange_unretract_str;
|
||||
|
||||
// Orca: the custom change_filament_gcode lifts to the object layer height and the unretract
|
||||
// de-hops back to it, so every tower extrusion emitted after it (purge moves, and the wall
|
||||
// when it prints after the toolchange) would float above the compacted tower. Descend first.
|
||||
if (compacted_below_object) {
|
||||
std::string z_descend = gcodegen.writer().travel_to_z(z, "Descend to compacted wipe tower z (no sparse layers)");
|
||||
check_add_eol(z_descend);
|
||||
start_filament_gcode_str += z_descend;
|
||||
}
|
||||
|
||||
// Insert the end filament, toolchange, and start filament gcode into the generated gcode.
|
||||
DynamicConfig config;
|
||||
config.set_key_value("filament_end_gcode", new ConfigOptionString(end_filament_gcode_str));
|
||||
@@ -1908,11 +1946,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
// resulting in a wipe tower with sparse layers.
|
||||
double wipe_tower_z = -1;
|
||||
bool ignore_sparse = false;
|
||||
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
||||
if (m_sparse_layers_skipped) {
|
||||
wipe_tower_z = m_last_wipe_tower_print_z;
|
||||
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 &&
|
||||
m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool &&
|
||||
m_layer_idx != 0);
|
||||
ignore_sparse = wipe_tower_layer_is_sparse(m_tool_changes[m_layer_idx]) && m_layer_idx != 0;
|
||||
if (m_tool_change_idx == 0 && !ignore_sparse)
|
||||
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
||||
}
|
||||
@@ -1928,12 +1964,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
// resulting in a wipe tower with sparse layers.
|
||||
double wipe_tower_z = -1;
|
||||
bool ignore_sparse = false;
|
||||
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
||||
wipe_tower_z = m_last_wipe_tower_print_z;
|
||||
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 &&
|
||||
m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
||||
if (m_tool_change_idx == 0 && !ignore_sparse)
|
||||
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
||||
if (m_sparse_layers_skipped) {
|
||||
ignore_sparse = wipe_tower_layer_is_sparse(m_tool_changes[m_layer_idx]);
|
||||
wipe_tower_z = m_compacted_tower_z[m_layer_idx];
|
||||
}
|
||||
|
||||
if ((m_enable_timelapse_print || m_enable_wrapping_detection) && m_is_first_print) {
|
||||
@@ -1946,10 +1979,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
|
||||
throw Slic3r::RuntimeError("Wipe tower generation failed, possibly due to empty first layer.");
|
||||
|
||||
if (!ignore_sparse) {
|
||||
if (!ignore_sparse)
|
||||
gcode += append_tcr(gcodegen, m_tool_changes[m_layer_idx][m_tool_change_idx++], extruder_id, wipe_tower_z);
|
||||
m_last_wipe_tower_print_z = wipe_tower_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1963,9 +1994,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
return true;
|
||||
|
||||
bool ignore_sparse = false;
|
||||
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
||||
ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
||||
}
|
||||
if (m_sparse_layers_skipped)
|
||||
ignore_sparse = wipe_tower_layer_is_sparse(m_tool_changes[m_layer_idx]);
|
||||
|
||||
if ((m_enable_timelapse_print || m_enable_wrapping_detection) && m_is_first_print) {
|
||||
return false;
|
||||
@@ -2901,6 +2931,19 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
const bool skip_config_block = print.config().gcode_skip_config_block;
|
||||
const WipeTowerType wipe_tower_type = print.wipe_tower_type();
|
||||
m_calib_config.clear();
|
||||
// Orca: Calibration overrides are reapplied after object/region settings in _extrude().
|
||||
// Keep inward wiping from masking retraction and pressure advance artifacts.
|
||||
switch (print.calib_mode()) {
|
||||
case CalibMode::Calib_PA_Line:
|
||||
case CalibMode::Calib_PA_Pattern:
|
||||
case CalibMode::Calib_PA_Tower:
|
||||
case CalibMode::Calib_Auto_PA_Line:
|
||||
case CalibMode::Calib_Retraction_tower:
|
||||
m_calib_config.set_key_value("wipe_inward", new ConfigOptionBool(false));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// resets analyzer's tracking data
|
||||
m_last_height = 0.f;
|
||||
m_last_layer_z = 0.f;
|
||||
@@ -3555,7 +3598,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
|
||||
auto used_filaments = print.get_slice_used_filaments(false);
|
||||
this->placeholder_parser().set("is_all_bbl_filament", std::all_of(used_filaments.begin(), used_filaments.end(), [&](auto idx) {
|
||||
return m_config.filament_vendor.values[idx] == "Bambu Lab";
|
||||
return m_config.filament_vendor.get_at(idx) == "Bambu Lab";
|
||||
}));
|
||||
|
||||
//add during_print_exhaust_fan_speed
|
||||
@@ -3572,7 +3615,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
this->placeholder_parser().set("outer_wall_volumetric_speed", new ConfigOptionFloat(outer_wall_volumetric_speed));
|
||||
|
||||
auto first_layer_filaments = print.get_slice_used_filaments(true);
|
||||
bool has_tpu_in_first_layer = std::any_of(first_layer_filaments.begin(), first_layer_filaments.end(), [&](unsigned int idx) { return m_config.filament_type.values[idx] == "TPU"; });
|
||||
bool has_tpu_in_first_layer = std::any_of(first_layer_filaments.begin(), first_layer_filaments.end(), [&](unsigned int idx) { return m_config.filament_type.get_at(idx) == "TPU"; });
|
||||
this->placeholder_parser().set("has_tpu_in_first_layer", new ConfigOptionBool(has_tpu_in_first_layer));
|
||||
|
||||
if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
||||
@@ -6560,6 +6603,8 @@ LayerResult GCode::process_layer(
|
||||
}
|
||||
// Then print infill
|
||||
gcode += this->extrude_infill(print, by_region_specific, false);
|
||||
// Then the walls left hanging in mid air, now that the infill can anchor them
|
||||
gcode += this->extrude_perimeters(print, by_region_specific, first_layer, false, true);
|
||||
// Then print perimeters of regions that has is_infill_first == true
|
||||
gcode += this->extrude_perimeters(print, by_region_specific, first_layer, true);
|
||||
}
|
||||
@@ -6855,6 +6900,7 @@ LayerResult GCode::process_layer(
|
||||
has_insert_timelapse_gcode = true;
|
||||
}
|
||||
gcode += this->extrude_infill(print, by_region_specific, false);
|
||||
gcode += this->extrude_perimeters(print, by_region_specific, first_layer, false, true);
|
||||
gcode += this->extrude_perimeters(print, by_region_specific, first_layer, true);
|
||||
// ironing
|
||||
gcode += this->extrude_infill(print, by_region_specific, true);
|
||||
@@ -7204,7 +7250,8 @@ std::string GCode::extrude_loop(const ExtrusionLoop& loop_ref,
|
||||
const std::string& description,
|
||||
double speed,
|
||||
const ExtrusionEntitiesPtr& region_perimeters,
|
||||
const Point* start_point)
|
||||
const Point* start_point,
|
||||
const WipeInwardSupport* wipe_support)
|
||||
{
|
||||
// get a copy; don't modify the orientation of the original loop object otherwise
|
||||
// next copies (if any) would not detect the correct orientation
|
||||
@@ -7434,63 +7481,80 @@ std::string GCode::extrude_loop(const ExtrusionLoop& loop_ref,
|
||||
m_processor.result().print_statistics.total_seam_scarf_distance += static_cast<float>(seam_scarf_distance_mm);
|
||||
}
|
||||
|
||||
// BBS
|
||||
// Orca: share the post-extrusion nozzle position between wipe_inward and wipe_on_loops.
|
||||
const bool is_ccw = loop.is_counter_clockwise();
|
||||
|
||||
std::optional<Point> wipe_on_loops_dest;
|
||||
if (m_config.wipe_on_loops.value && paths.back().role() == erExternalPerimeter &&
|
||||
m_layer != nullptr && m_config.wall_loops.value > 1 && paths.front().size() >= 2 &&
|
||||
paths.back().polyline.points.size() >= 2)
|
||||
wipe_on_loops_dest = wipe_on_loops_destination(paths, scale_(nozzle_diameter), is_ccw, is_hole);
|
||||
|
||||
bool wipe_inward_applied = false;
|
||||
// Orca: store loop paths in print order because inward offsets use this orientation.
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.path = Polyline();
|
||||
for (ExtrusionPath &path : paths) {
|
||||
//BBS: Don't need to save duplicated point into wipe path
|
||||
if (!m_wipe.path.empty() && !path.empty() &&
|
||||
m_wipe.path.last_point() == Point(path.first_point().x(), path.first_point().y())) {
|
||||
// Convert Points3 to Points
|
||||
for (auto it = path.polyline.points.begin() + 1; it != path.polyline.points.end(); ++it)
|
||||
m_wipe.path.append(Point(it->x(), it->y()));
|
||||
} else
|
||||
m_wipe.path.append(path.polyline.to_polyline()); // TODO: don't limit wipe to last path
|
||||
m_wipe.update_path(paths);
|
||||
|
||||
// Orca: loop wipe paths retain print direction. Their material side is
|
||||
// therefore left for CCW contours and right for CW contours, with the
|
||||
// result inverted for holes. Only external perimeters are eligible.
|
||||
// Calibration overrides are applied during extrusion, after the region
|
||||
// context was created. Check the effective setting again at execution.
|
||||
if (m_config.wipe_inward && m_config.wipe_inward_distance.value > 0. &&
|
||||
wipe_support != nullptr && !wipe_support->inner_lines.empty() &&
|
||||
// A loop's role is its first path's role. An overhanging start must
|
||||
// not hide ordinary external-wall segments elsewhere in the loop.
|
||||
std::any_of(paths.begin(), paths.end(),
|
||||
[](const ExtrusionPath &path) { return is_external_perimeter(path.role()); }) &&
|
||||
m_wipe.path.points.size() >= 2) {
|
||||
// Orca: use the actual extrusion width from the path, not the config
|
||||
// value — outer_wall_line_width=0 (Auto) would make get_abs_value
|
||||
// return 0 and silently disable the feature, and Arachne may produce
|
||||
// a different width than the config default.
|
||||
const double outer_wall_line_width = paths.front().width;
|
||||
const double requested_offset = m_config.wipe_inward_distance.get_abs_value(outer_wall_line_width);
|
||||
const double offset_dist = scale_(std::min(requested_offset, outer_wall_line_width));
|
||||
if (offset_dist > SCALED_EPSILON) {
|
||||
const Point seam_start = paths.front().first_point();
|
||||
const Point seam_end = paths.back().last_point();
|
||||
const Point wipe_start = wipe_on_loops_dest.value_or(seam_end);
|
||||
const double max_wipe_length = scale_(FILAMENT_CONFIG(wipe_distance));
|
||||
// Orca: Wipe::wipe() replaces points[0] with last_pos and executes
|
||||
// from points[1]. The helper preserves that sentinel and atomically
|
||||
// replaces the remaining points, or leaves the path untouched.
|
||||
// Orca: a configured wall count does not guarantee that Arachne
|
||||
// generated an adjacent wall for this particular loop. Only
|
||||
// earlier entities are considered because later walls have
|
||||
// not been printed yet (for example with Outer/Inner order).
|
||||
// Inner walls determine the material side; every earlier wall
|
||||
// remains available to validate the executable wipe path.
|
||||
const double support_distance = scale_(std::max(nozzle_diameter, outer_wall_line_width));
|
||||
Polyline inward_path = m_wipe.path;
|
||||
if (offset_wipe_path_toward_support(
|
||||
inward_path, seam_start, seam_end, wipe_start,
|
||||
wipe_offset_direction(is_ccw, is_hole), offset_dist, max_wipe_length,
|
||||
wipe_support->inner_lines, wipe_support->printed_lines,
|
||||
m_wipe.path.lines(), support_distance)) {
|
||||
m_wipe.path = std::move(inward_path);
|
||||
wipe_inward_applied = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make a little move inwards before leaving loop
|
||||
if (m_config.wipe_on_loops.value && paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.wall_loops.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 3) {
|
||||
// detect angle between last and first segment
|
||||
// the side depends on the original winding order of the polygon (inwards for contours, outwards for holes)
|
||||
//FIXME improve the algorithm in case the loop is tiny.
|
||||
//FIXME improve the algorithm in case the loop is split into segments with a low number of points (see the Point b query).
|
||||
const Point3 &a3 = paths.front().polyline.points[1]; // second point
|
||||
Point a = Point(a3.x(), a3.y());
|
||||
const Point3 &b3 = *(paths.back().polyline.points.end()-3); // second to last point
|
||||
Point b = Point(b3.x(), b3.y());
|
||||
if (is_hole == loop.is_counter_clockwise()) {
|
||||
// swap points
|
||||
Point c = a; a = b; b = c;
|
||||
}
|
||||
|
||||
double angle = paths.front().first_point().ccw_angle(a, b) / 3;
|
||||
|
||||
// turn inwards if contour, turn outwards if hole
|
||||
if (is_hole == loop.is_counter_clockwise()) angle *= -1;
|
||||
|
||||
// create the destination point along the first segment and rotate it
|
||||
// we make sure we don't exceed the segment length because we don't know
|
||||
// the rotation of the second segment so we might cross the object boundary
|
||||
Vec2d p1 = paths.front().polyline.points.front().cast<double>().head<2>();
|
||||
Vec2d p2 = paths.front().polyline.points[1].cast<double>().head<2>();
|
||||
Vec2d v = p2 - p1;
|
||||
double nd = scale_(EXTRUDER_CONFIG(nozzle_diameter));
|
||||
double l2 = v.squaredNorm();
|
||||
// Shift by no more than a nozzle diameter.
|
||||
//FIXME Hiding the seams will not work nicely for very densely discretized contours!
|
||||
//BBS. shorten the travel distant before the wipe path
|
||||
double threshold = 0.2;
|
||||
Point pt = (p1 + v * threshold).cast<coord_t>();
|
||||
if (nd * nd < l2)
|
||||
pt = (p1 + threshold * v * (nd / sqrt(l2))).cast<coord_t>();
|
||||
//Point pt = ((nd * nd >= l2) ? (p1+v*0.4): (p1 + 0.2 * v * (nd / sqrt(l2)))).cast<coord_t>();
|
||||
const Point3 ¢er3 = paths.front().polyline.points.front();
|
||||
pt.rotate(angle, Point(center3.x(), center3.y()));
|
||||
// generate the travel move
|
||||
gcode += m_writer.extrude_to_xy(this->point_to_gcode(pt), 0, "move inwards before travel", true);
|
||||
// Orca: make the configured inward move before leaving the loop.
|
||||
if (wipe_on_loops_dest) {
|
||||
gcode += m_writer.extrude_to_xy(
|
||||
this->point_to_gcode(*wipe_on_loops_dest), 0, "move inwards before travel", true);
|
||||
this->set_last_pos(*wipe_on_loops_dest);
|
||||
}
|
||||
|
||||
// Execute the accepted path before another extrusion replaces it. Wiping
|
||||
// must not force retraction or Z-hop across a short travel to the next wall.
|
||||
// Ordinary travel planning decides whether to retract from the new position.
|
||||
if (wipe_inward_applied)
|
||||
gcode += m_wipe.wipe(*this, 0.);
|
||||
|
||||
return gcode;
|
||||
}
|
||||
|
||||
@@ -7524,21 +7588,9 @@ std::string GCode::extrude_multi_path(const ExtrusionMultiPath& multipath, const
|
||||
m_multi_flow_segment_path_pa_set = true;
|
||||
}
|
||||
|
||||
// BBS
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.path = Polyline();
|
||||
for (const ExtrusionPath &path : multipath.paths) {
|
||||
//BBS: Don't need to save duplicated point into wipe path
|
||||
if (!m_wipe.path.empty() && !path.empty() &&
|
||||
m_wipe.path.last_point() == Point(path.first_point().x(), path.first_point().y())) {
|
||||
// Convert Points3 to Points
|
||||
for (auto it = path.polyline.points.begin() + 1; it != path.polyline.points.end(); ++it)
|
||||
m_wipe.path.append(Point(it->x(), it->y()));
|
||||
} else
|
||||
m_wipe.path.append(path.polyline.to_polyline()); // TODO: don't limit wipe to last path
|
||||
}
|
||||
m_wipe.path.reverse();
|
||||
}
|
||||
// Orca: multipath wipes retrace the extrusion in reverse order.
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe))
|
||||
m_wipe.update_path(multipath.paths, true);
|
||||
|
||||
return gcode;
|
||||
}
|
||||
@@ -7546,14 +7598,15 @@ std::string GCode::extrude_multi_path(const ExtrusionMultiPath& multipath, const
|
||||
std::string GCode::extrude_entity(const ExtrusionEntity& entity,
|
||||
const std::string& description,
|
||||
double speed,
|
||||
const ExtrusionEntitiesPtr& region_perimeters)
|
||||
const ExtrusionEntitiesPtr& region_perimeters,
|
||||
const WipeInwardSupport* wipe_support)
|
||||
{
|
||||
if (const ExtrusionPath* path = dynamic_cast<const ExtrusionPath*>(&entity))
|
||||
return this->extrude_path(*path, description, speed);
|
||||
else if (const ExtrusionMultiPath* multipath = dynamic_cast<const ExtrusionMultiPath*>(&entity))
|
||||
return this->extrude_multi_path(*multipath, description, speed);
|
||||
else if (const ExtrusionLoop* loop = dynamic_cast<const ExtrusionLoop*>(&entity))
|
||||
return this->extrude_loop(*loop, description, speed, region_perimeters);
|
||||
return this->extrude_loop(*loop, description, speed, region_perimeters, nullptr, wipe_support);
|
||||
else
|
||||
throw Slic3r::InvalidArgument("Invalid argument supplied to extrude()");
|
||||
return "";
|
||||
@@ -7567,6 +7620,7 @@ std::string GCode::extrude_path(const ExtrusionPath& path, const std::string& de
|
||||
// description += ExtrusionEntity::role_to_string(path.role());
|
||||
std::string gcode = this->_extrude(path, description, speed);
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe)) {
|
||||
m_wipe.reset_path();
|
||||
m_wipe.path = path.polyline.to_polyline();
|
||||
if (is_tree(this->config().support_type) && is_support(path.role())) {
|
||||
if ((m_wipe.path.first_point() - m_wipe.path.last_point()).cast<double>().norm() > scale_(0.2)) {
|
||||
@@ -7587,7 +7641,7 @@ std::string GCode::extrude_path(const ExtrusionPath& path, const std::string& de
|
||||
}
|
||||
|
||||
// Extrude perimeters: Decide where to put seams (hide or align seams).
|
||||
std::string GCode::extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool is_first_layer, bool is_infill_first)
|
||||
std::string GCode::extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool is_first_layer, bool is_infill_first, bool unsupported_loops_only)
|
||||
{
|
||||
std::string gcode;
|
||||
for (const ObjectByExtruder::Island::Region ®ion : by_region)
|
||||
@@ -7599,8 +7653,36 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
|
||||
: (m_config.is_infill_first == is_infill_first);
|
||||
if (!should_print) continue;
|
||||
|
||||
for (const ExtrusionEntity* ee : region.perimeters)
|
||||
gcode += this->extrude_entity(*ee, "perimeter", -1., region.perimeters);
|
||||
// Build the printed prefix once in emission order, scoped to this
|
||||
// region. Disabled or zero-length wipes need no support geometry.
|
||||
std::optional<WipeInwardSupport> wipe_support;
|
||||
if (m_wipe.enable && FILAMENT_CONFIG(wipe) && m_config.wipe_inward &&
|
||||
m_config.wipe_inward_distance.value > 0. &&
|
||||
scale_(FILAMENT_CONFIG(wipe_distance)) > SCALED_EPSILON)
|
||||
wipe_support.emplace();
|
||||
|
||||
// ORCA: loops flagged as extruded in mid air, out of reach of the layer below, are held back
|
||||
// for a second pass after the infill that anchors them. Infill already precedes infill first walls.
|
||||
const bool defer_unsupported = !is_infill_first;
|
||||
auto waits_for_infill = [](const ExtrusionEntity *ee) {
|
||||
return ee->is_loop() && static_cast<const ExtrusionLoop *>(ee)->print_after_infill;
|
||||
};
|
||||
|
||||
// The deferred pass runs after the infill, so the loops the first pass emitted are
|
||||
// already down and belong in the prefix an inward wipe may land on.
|
||||
if (wipe_support && defer_unsupported && unsupported_loops_only)
|
||||
for (const ExtrusionEntity* ee : region.perimeters)
|
||||
if (!waits_for_infill(ee))
|
||||
wipe_support->append(*ee);
|
||||
|
||||
for (const ExtrusionEntity* ee : region.perimeters) {
|
||||
if (defer_unsupported && waits_for_infill(ee) != unsupported_loops_only)
|
||||
continue;
|
||||
gcode += this->extrude_entity(*ee, "perimeter", -1., region.perimeters,
|
||||
wipe_support ? &*wipe_support : nullptr);
|
||||
if (wipe_support)
|
||||
wipe_support->append(*ee);
|
||||
}
|
||||
}
|
||||
return gcode;
|
||||
}
|
||||
@@ -7841,7 +7923,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
// path is 2D. But in slope lift case, lift z is done in travel_to function.
|
||||
// Add m_need_change_layer_lift_z when change_layer in case of no lift if m_last_pos is equal to path.first_point() by chance
|
||||
Point first_point = path.first_point();
|
||||
if (!m_last_pos_defined || m_last_pos.to_point() != first_point || m_need_change_layer_lift_z || slope_need_z_travel) {
|
||||
if (!m_last_pos_defined || m_last_pos.to_point() != first_point || m_need_change_layer_lift_z ||
|
||||
slope_need_z_travel) {
|
||||
const bool _last_pos_undefined = !m_last_pos_defined;
|
||||
|
||||
double z = DBL_MAX;
|
||||
@@ -9474,12 +9557,14 @@ std::string GCode::set_extruder(unsigned int new_filament_id, double print_z, bo
|
||||
if (old_filament_id_in_new_extruder == -1)
|
||||
wipe_volume = 0;
|
||||
else {
|
||||
wipe_volume = flush_matrix[old_filament_id_in_new_extruder * number_of_extruders + new_filament_id];
|
||||
size_t flush_idx = size_t(old_filament_id_in_new_extruder) * number_of_extruders + new_filament_id;
|
||||
wipe_volume = flush_idx < flush_matrix.size() ? flush_matrix[flush_idx] : 0.f;
|
||||
wipe_volume *= m_config.flush_multiplier.get_at(new_extruder_id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
wipe_volume = flush_matrix[old_filament_id * number_of_extruders + new_filament_id];
|
||||
size_t flush_idx = size_t(old_filament_id) * number_of_extruders + new_filament_id;
|
||||
wipe_volume = flush_idx < flush_matrix.size() ? flush_matrix[flush_idx] : 0.f;
|
||||
wipe_volume *= m_config.flush_multiplier.get_at(new_extruder_id); // if is multi_extruder only use the fist extruder matrix
|
||||
}
|
||||
wipe_volume = std::max(0.f, wipe_volume-grab_purge_volume);
|
||||
|
||||
+21
-6
@@ -39,6 +39,7 @@ namespace Slic3r {
|
||||
|
||||
// Forward declarations.
|
||||
class GCode;
|
||||
struct WipeInwardSupport;
|
||||
|
||||
namespace CustomGCode{ struct Item; }
|
||||
struct PrintInstance;
|
||||
@@ -61,7 +62,7 @@ public:
|
||||
bool enable;
|
||||
Polyline path;
|
||||
|
||||
// Orca:
|
||||
// Orca: retraction portions emitted before, during, and after the wipe move.
|
||||
struct RetractionValues{
|
||||
double retraction_length_before_wipe = 0.;
|
||||
double retraction_length_during_wipe = 0.;
|
||||
@@ -73,8 +74,10 @@ public:
|
||||
void reset_path() { this->path = Polyline(); }
|
||||
std::string wipe(GCode &gcodegen, double length, bool toolchange = false, bool is_last = false);
|
||||
|
||||
// Orca:
|
||||
// Orca: calculate the retraction portions that can be emitted at wipe speed.
|
||||
RetractionValues calculateWipeRetractionLengths(GCode& gcodegen, bool toolchange);
|
||||
// Orca: rebuild the stored path while deduplicating shared path boundaries.
|
||||
void update_path(const ExtrusionPaths &paths, bool reverse = false);
|
||||
};
|
||||
|
||||
class WipeTowerIntegration {
|
||||
@@ -103,8 +106,13 @@ public:
|
||||
m_enable_wrapping_detection(print_config.enable_wrapping_detection && (print_config.wrapping_exclude_area.values.size() > 2) && (slice_used_filaments.size() <= 1)),
|
||||
m_is_first_print(true),
|
||||
m_print_config(&print_config),
|
||||
m_last_wipe_tower_print_z(print_config.z_offset.value)
|
||||
m_last_wipe_tower_print_z(print_config.z_offset.value),
|
||||
m_sparse_layers_skipped(wipe_tower_sparse_layers_skipped(print_config))
|
||||
{
|
||||
// Precomputed rather than accumulated while emitting, so that the clearance validator and
|
||||
// the emitter cannot disagree about where the compacted tower sits on any given layer.
|
||||
if (m_sparse_layers_skipped)
|
||||
m_compacted_tower_z = compute_compacted_wipe_tower_z(tool_changes, float(print_config.z_offset.value));
|
||||
// initialize with the extruder offset of master extruder id
|
||||
m_extruder_offsets.resize(print_config.filament_map.size(), print_config.extruder_offset.get_at(print_config.master_extruder_id.value - 1));
|
||||
const auto& filament_map = print_config.filament_map.values; // 1 based idx
|
||||
@@ -164,6 +172,11 @@ private:
|
||||
float m_wipe_tower_depth;
|
||||
BoundingBoxf m_wipe_tower_bbx;
|
||||
Vec2f m_rib_offset{Vec2f(0, 0)};
|
||||
// wipe_tower_no_sparse_layers, as answered by the shared compaction rule rather than by the raw
|
||||
// option: smooth timelapse and wrapping detection keep a tower on every layer regardless.
|
||||
const bool m_sparse_layers_skipped;
|
||||
// Print z of the compacted tower per planned layer. Empty when the tower is not compacted.
|
||||
std::vector<float> m_compacted_tower_z;
|
||||
};
|
||||
|
||||
class ColorPrintColors
|
||||
@@ -430,14 +443,16 @@ private:
|
||||
std::string extrude_entity(const ExtrusionEntity& entity,
|
||||
const std::string& description = "",
|
||||
double speed = -1.,
|
||||
const ExtrusionEntitiesPtr& region_perimeters = ExtrusionEntitiesPtr());
|
||||
const ExtrusionEntitiesPtr& region_perimeters = ExtrusionEntitiesPtr(),
|
||||
const WipeInwardSupport* wipe_support = nullptr);
|
||||
// Orca: pass the complete collection of region perimeters to the extrude loop to check whether the wipe before external loop
|
||||
// should be executed
|
||||
std::string extrude_loop(const ExtrusionLoop& loop,
|
||||
const std::string& description,
|
||||
double speed = -1.,
|
||||
const ExtrusionEntitiesPtr& region_perimeters = ExtrusionEntitiesPtr(),
|
||||
const Point* start_point = nullptr);
|
||||
const Point* start_point = nullptr,
|
||||
const WipeInwardSupport* wipe_support = nullptr);
|
||||
std::string extrude_multi_path(const ExtrusionMultiPath& multipath, const std::string& description = "", double speed = -1.);
|
||||
std::string extrude_path(const ExtrusionPath& path, const std::string& description = "", double speed = -1.);
|
||||
|
||||
@@ -519,7 +534,7 @@ private:
|
||||
// For sequential print, the instance of the object to be printing has to be defined.
|
||||
const size_t single_object_instance_idx);
|
||||
|
||||
std::string extrude_perimeters(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool is_first_layer, bool is_infill_first);
|
||||
std::string extrude_perimeters(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool is_first_layer, bool is_infill_first, bool unsupported_loops_only = false);
|
||||
std::string extrude_infill(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool ironing);
|
||||
std::string extrude_support(const ExtrusionEntityCollection& support_fills, const ExtrusionRole support_extrusion_role);
|
||||
|
||||
|
||||
@@ -7596,8 +7596,8 @@ void GCodeProcessor::update_slice_warnings()
|
||||
if (used_filaments[idx] < m_result.required_nozzle_HRC.size())
|
||||
filament_hrc = m_result.required_nozzle_HRC[used_filaments[idx]];
|
||||
|
||||
int filament_extruder_id = m_filament_maps[used_filaments[idx]];
|
||||
int extruder_hrc = nozzle_hrc_lists[filament_extruder_id];
|
||||
int filament_extruder_id = used_filaments[idx] < m_filament_maps.size() ? m_filament_maps[used_filaments[idx]] : -1;
|
||||
int extruder_hrc = (filament_extruder_id >= 0 && (size_t) filament_extruder_id < nozzle_hrc_lists.size()) ? nozzle_hrc_lists[filament_extruder_id] : 0;
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": Check HRC: filament:%1%, hrc=%2%, extruder:%3%, hrc:%4%") % used_filaments[idx] % filament_hrc % filament_extruder_id % extruder_hrc;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "FilamentMixer.hpp"
|
||||
#include "LocalesUtils.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "format.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
@@ -82,8 +83,9 @@ bool check_filament_printable_after_group(const std::vector<unsigned int> &used_
|
||||
int printable_status = print_config->filament_printable.get_at(filament_id);
|
||||
int extruder_idx = filament_maps[filament_id];
|
||||
if (!(printable_status >> extruder_idx & 1)) {
|
||||
std::string extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
|
||||
std::string error_msg = _L("Grouping error: ") + filament_type + _L(" can not be placed in the ") + extruder_name + _L(" nozzle");
|
||||
std::string error_msg = extruder_idx == 0 ?
|
||||
Slic3r::format(_L("Grouping error: %1% cannot be placed in the left nozzle"), filament_type) :
|
||||
Slic3r::format(_L("Grouping error: %1% cannot be placed in the right nozzle"), filament_type);
|
||||
throw Slic3r::RuntimeError(error_msg);
|
||||
}
|
||||
}
|
||||
@@ -1488,10 +1490,10 @@ static FilamentGroupContext build_filament_group_context(
|
||||
|
||||
auto machine_filament_info = build_machine_filaments(print->get_extruder_filament_info(), extruder_ams_counts, ignore_ext_filament);
|
||||
|
||||
std::vector<std::string> filament_types = print_config.filament_type.values;
|
||||
std::vector<std::string> filament_colours = print_config.filament_colour.values;
|
||||
std::vector<unsigned char> filament_is_support = print_config.filament_is_support.values;
|
||||
std::vector<std::string> filament_ids = print_config.filament_ids.values;
|
||||
// The grouping code walks filament_ids and indexes filament_info by the same position.
|
||||
std::vector<std::string> filament_ids = print_config.filament_ids.values;
|
||||
if (filament_ids.size() > filament_nums)
|
||||
filament_ids.resize(filament_nums);
|
||||
|
||||
FGMode fg_mode = mode == FilamentMapMode::fmmAutoForMatch ? FGMode::MatchMode : FGMode::FlushMode;
|
||||
context.model_info.flush_matrix = std::move(nozzle_flush_mtx);
|
||||
@@ -1500,11 +1502,14 @@ static FilamentGroupContext build_filament_group_context(
|
||||
context.model_info.filament_ids = filament_ids;
|
||||
context.model_info.unprintable_volumes = unprintable_volumes;
|
||||
|
||||
for (size_t idx = 0; idx < filament_types.size(); ++idx) {
|
||||
// Consumers index filament_info by filament id, so it must span the filament count: a partial
|
||||
// or legacy config can leave any of these arrays short, and get_at clamps.
|
||||
context.model_info.filament_info.reserve(filament_nums);
|
||||
for (size_t idx = 0; idx < filament_nums; ++idx) {
|
||||
FilamentGroupUtils::FilamentInfo info;
|
||||
info.color = filament_colours[idx];
|
||||
info.type = filament_types[idx];
|
||||
info.is_support = filament_is_support[idx];
|
||||
info.color = print_config.filament_colour.get_at(idx);
|
||||
info.type = print_config.filament_type.get_at(idx);
|
||||
info.is_support = print_config.filament_is_support.get_at(idx);
|
||||
context.model_info.filament_info.emplace_back(std::move(info));
|
||||
}
|
||||
|
||||
@@ -2732,6 +2737,28 @@ void ToolOrdering::enforce_mixed_component_order()
|
||||
}
|
||||
}
|
||||
|
||||
// Declared in ToolOrdering.hpp (exposed for unit testing).
|
||||
std::vector<unsigned int> parse_cyclic_order(const std::string& str, unsigned int number_of_extruders)
|
||||
{
|
||||
std::vector<unsigned int> order;
|
||||
for (const std::string& token : split_string(str, ',')) {
|
||||
try {
|
||||
size_t pos = 0;
|
||||
int filament = std::stoi(token, &pos); // stoi skips leading whitespace by itself
|
||||
// stoi stops at the first non-digit, so "2x" would parse as 2. Require the whole token to be
|
||||
// consumed (bar trailing whitespace) to drop it like any other garbage.
|
||||
if (token.find_first_not_of(" \t\r\n", pos) != std::string::npos)
|
||||
continue;
|
||||
if (filament >= 1 && (unsigned int)filament <= number_of_extruders
|
||||
&& std::find(order.begin(), order.end(), (unsigned int)(filament - 1)) == order.end())
|
||||
order.emplace_back((unsigned int)(filament - 1));
|
||||
} catch (const std::exception&) {
|
||||
// Not a number, ignore it.
|
||||
}
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first_layer)
|
||||
{
|
||||
const PrintConfig* print_config = m_print_config_ptr;
|
||||
@@ -2829,11 +2856,41 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
const bool use_cyclic_ordering =
|
||||
(print_config->toolchange_ordering == ToolChangeOrderingType::Cyclic);
|
||||
|
||||
// By default the first layer keeps its adhesion-optimized order (and any custom first layer
|
||||
// sequence); the cyclic sequence is only forced onto it when the user opts in.
|
||||
const bool cyclic_first_layer = use_cyclic_ordering && print_config->toolchange_cyclic_first_layer.value;
|
||||
|
||||
// Optional user defined cyclic sequence, given as 1-based filament numbers ("3,2,1,4"). Filaments
|
||||
// missing from it keep their ascending order after the listed ones, so a partial or bogus entry
|
||||
// still yields the default cyclic order.
|
||||
const std::vector<unsigned int> cyclic_order =
|
||||
use_cyclic_ordering ? parse_cyclic_order(print_config->toolchange_cyclic_order.value, number_of_extruders)
|
||||
: std::vector<unsigned int>();
|
||||
|
||||
// Reorder a layer's filaments (0-based) for cyclic ordering: ascending by default, or following the
|
||||
// user defined sequence when one was given. Filaments absent from the sequence keep ascending order
|
||||
// after the listed ones.
|
||||
auto apply_cyclic_order = [&cyclic_order](std::vector<unsigned int>& filaments) {
|
||||
std::sort(filaments.begin(), filaments.end());
|
||||
if (!cyclic_order.empty())
|
||||
std::stable_sort(filaments.begin(), filaments.end(), [&cyclic_order](unsigned int lhs, unsigned int rhs) {
|
||||
auto rank = [&cyclic_order](unsigned int filament) {
|
||||
return size_t(std::find(cyclic_order.begin(), cyclic_order.end(), filament) - cyclic_order.begin());
|
||||
};
|
||||
return rank(lhs) < rank(rhs);
|
||||
});
|
||||
};
|
||||
|
||||
// other_layers_seq: the layer_idx and extruder_idx are base on 1
|
||||
auto get_custom_seq = [&other_layers_seqs, &reorder_first_layer, &first_layer_filaments, &layer_filaments, use_cyclic_ordering](int layer_idx, std::vector<int>& out_seq) -> bool {
|
||||
auto get_custom_seq = [&other_layers_seqs, &reorder_first_layer, &first_layer_filaments, &layer_filaments, use_cyclic_ordering, cyclic_first_layer, &apply_cyclic_order](int layer_idx, std::vector<int>& out_seq) -> bool {
|
||||
if (!reorder_first_layer && layer_idx == 0) {
|
||||
out_seq.resize(first_layer_filaments.size());
|
||||
std::transform(first_layer_filaments.begin(), first_layer_filaments.end(), out_seq.begin(), [](auto item) {return item + 1; });
|
||||
// The first layer tool order is already decided (adhesion-optimized, plus any custom first
|
||||
// layer sequence). Only override it with the cyclic sequence when the user opted in.
|
||||
std::vector<unsigned int> ordered = first_layer_filaments;
|
||||
if (cyclic_first_layer)
|
||||
apply_cyclic_order(ordered);
|
||||
out_seq.resize(ordered.size());
|
||||
std::transform(ordered.begin(), ordered.end(), out_seq.begin(), [](auto item) {return int(item) + 1; });
|
||||
return true;
|
||||
}
|
||||
for (size_t idx = other_layers_seqs.size() - 1; idx != size_t(-1); --idx) {
|
||||
@@ -2844,9 +2901,12 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
}
|
||||
}
|
||||
|
||||
if (use_cyclic_ordering && layer_idx >= 0 && size_t(layer_idx) < layer_filaments.size()) {
|
||||
// Skip the first layer here (layer_idx == 0 only reaches this point on the reorder_first_layer
|
||||
// path) unless the user asked for cyclic order on it, so it keeps the default flush ordering.
|
||||
if (use_cyclic_ordering && layer_idx >= 0 && (layer_idx != 0 || cyclic_first_layer)
|
||||
&& size_t(layer_idx) < layer_filaments.size()) {
|
||||
std::vector<unsigned int> ordered = layer_filaments[size_t(layer_idx)];
|
||||
std::sort(ordered.begin(), ordered.end());
|
||||
apply_cyclic_order(ordered);
|
||||
out_seq.resize(ordered.size());
|
||||
std::transform(ordered.begin(), ordered.end(), out_seq.begin(), [](auto item) { return int(item) + 1; });
|
||||
return true;
|
||||
|
||||
@@ -417,6 +417,11 @@ private:
|
||||
int most_used_extruder;
|
||||
};
|
||||
|
||||
// Parse the user defined cyclic toolchange sequence ("3,2 , 1 , 4") into 0-based filament indices.
|
||||
// Out-of-range entries, duplicates and non-numeric tokens are dropped, so a partially valid string
|
||||
// still orders the filaments it does name. Exposed for unit testing.
|
||||
std::vector<unsigned int> parse_cyclic_order(const std::string& str, unsigned int number_of_extruders);
|
||||
|
||||
} // namespace SLic3r
|
||||
|
||||
#endif /* slic3r_ToolOrdering_hpp_ */
|
||||
|
||||
@@ -0,0 +1,920 @@
|
||||
#include "WipePathHelpers.hpp"
|
||||
|
||||
#include "../AABBTreeLines.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void WipeInwardSupport::append(const ExtrusionEntity &entity)
|
||||
{
|
||||
const ExtrusionPaths *paths = nullptr;
|
||||
if (const auto *loop = dynamic_cast<const ExtrusionLoop *>(&entity))
|
||||
paths = &loop->paths;
|
||||
else if (const auto *multipath = dynamic_cast<const ExtrusionMultiPath *>(&entity))
|
||||
paths = &multipath->paths;
|
||||
|
||||
// A loop's role is its first path's role. An overhanging start must not
|
||||
// hide the ordinary inner-wall segments elsewhere in the same loop.
|
||||
const bool is_inner = paths ? std::any_of(paths->begin(), paths->end(),
|
||||
[](const ExtrusionPath &path) { return is_internal_perimeter(path.role()); }) :
|
||||
is_internal_perimeter(entity.role());
|
||||
const Lines lines = entity.as_polyline().lines();
|
||||
printed_lines.insert(printed_lines.end(), lines.begin(), lines.end());
|
||||
if (is_inner)
|
||||
inner_lines.insert(inner_lines.end(), lines.begin(), lines.end());
|
||||
}
|
||||
|
||||
// Orca: miter limit ratio. Matches DefaultMiterLimit from ClipperUtils.hpp.
|
||||
// When the miter join extends more than miter_limit * offset_dist from the
|
||||
// original vertex, the miter is replaced by a bevel join.
|
||||
static constexpr double miter_limit = 3.0;
|
||||
|
||||
// Orca: threshold for detecting near-reversal (backtracking spike).
|
||||
// Normalized dot product below this means the segments point in nearly
|
||||
// opposite directions (angle > ~172°). Offsetting such a path is unsafe.
|
||||
static constexpr double reversal_dot_threshold = -0.99;
|
||||
|
||||
// Orca: candidates pointing more than 60 degrees away from the selected inner
|
||||
// wall are too tangent to distinguish the material side reliably at a cusp.
|
||||
static constexpr double min_support_alignment = 0.5;
|
||||
|
||||
// Keep a scaled-coordinate rounding floor while allowing the tolerance to
|
||||
// follow the relevant offset or path length. Clearance allows a larger fraction.
|
||||
static double wipe_tolerance(double distance, double relative_tolerance = 0.1)
|
||||
{
|
||||
return std::max(4. * SCALED_EPSILON, relative_tolerance * distance);
|
||||
}
|
||||
|
||||
Point sample_path_at_distance(const ExtrusionPaths &paths, bool forward, double target)
|
||||
{
|
||||
assert(!paths.empty());
|
||||
if (paths.empty())
|
||||
return Point(0, 0);
|
||||
|
||||
double remaining = target;
|
||||
Point result = forward ? paths.front().first_point() : paths.back().last_point();
|
||||
for (int pi = forward ? 0 : (int)paths.size() - 1;
|
||||
pi >= 0 && pi < (int)paths.size() && remaining > 0.;
|
||||
pi += forward ? 1 : -1) {
|
||||
const Points3 &pts = paths[pi].polyline.points;
|
||||
for (int i = forward ? 0 : (int)pts.size() - 1;
|
||||
remaining > 0. && (forward ? i + 1 < (int)pts.size() : i > 0);
|
||||
i += forward ? 1 : -1) {
|
||||
const int j = forward ? i + 1 : i - 1;
|
||||
const Point cur(pts[i].x(), pts[i].y());
|
||||
const Point next(pts[j].x(), pts[j].y());
|
||||
const double segment_length = (next - cur).cast<double>().norm();
|
||||
if (segment_length < SCALED_EPSILON)
|
||||
continue;
|
||||
if (remaining <= segment_length) {
|
||||
const double ratio = remaining / segment_length;
|
||||
return Point(coord_t(cur.x() + ratio * (next.x() - cur.x())),
|
||||
coord_t(cur.y() + ratio * (next.y() - cur.y())));
|
||||
}
|
||||
remaining -= segment_length;
|
||||
result = next;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Orca: consecutive duplicates carry no path length and can be removed safely.
|
||||
// A reversal, however, is real travelled distance: removing its vertex would
|
||||
// replace a long backtracking wipe with a short, unrelated shortcut.
|
||||
static bool prepare_source(Points &pts)
|
||||
{
|
||||
pts.erase(std::unique(pts.begin(), pts.end()), pts.end());
|
||||
|
||||
if (pts.size() < 2)
|
||||
return false;
|
||||
|
||||
for (size_t i = 1; i + 1 < pts.size(); ++i) {
|
||||
const Vec2d v_prev = (pts[i] - pts[i - 1]).cast<double>();
|
||||
const Vec2d v_next = (pts[i + 1] - pts[i]).cast<double>();
|
||||
const double dot = v_prev.dot(v_next) / (v_prev.norm() * v_next.norm());
|
||||
if (dot < reversal_dot_threshold)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool build_offset_polyline(const Points &original, int dir, double offset_dist,
|
||||
Points &result, size_t &first_join_index)
|
||||
{
|
||||
if (original.size() < 2)
|
||||
return false;
|
||||
|
||||
// Orca: collapse all consecutive duplicates first, then reject any
|
||||
// backtracking in the cleaned path instead of replacing travelled distance
|
||||
// with a shortcut.
|
||||
Points source = original;
|
||||
if (! prepare_source(source))
|
||||
return false;
|
||||
|
||||
const size_t n = source.size();
|
||||
|
||||
// Orca: compute the perpendicular offset for segment i->i+1 as an infinite Line.
|
||||
auto offset_segment = [dir, offset_dist](const Point &a, const Point &b) -> Line {
|
||||
Vec2d v = (b - a).cast<double>();
|
||||
double len = v.norm();
|
||||
Vec2d perp(0, 0);
|
||||
if (len > SCALED_EPSILON)
|
||||
perp = Vec2d(-v.y(), v.x()) * (dir * offset_dist / len);
|
||||
return Line(Point(coord_t(a.x() + perp.x()), coord_t(a.y() + perp.y())),
|
||||
Point(coord_t(b.x() + perp.x()), coord_t(b.y() + perp.y())));
|
||||
};
|
||||
|
||||
result.clear();
|
||||
result.reserve(n);
|
||||
first_join_index = 0;
|
||||
|
||||
// Orca: the first point is perpendicular to the first segment.
|
||||
Line l_prev = offset_segment(source[0], source[1]);
|
||||
result.push_back(l_prev.a);
|
||||
|
||||
// Orca: use the analytic intersection of adjacent offset segments for a
|
||||
// miter join. Intersecting the already rounded Line endpoints amplifies
|
||||
// coordinate quantization when the source segments are nearly parallel.
|
||||
for (size_t i = 1; i + 1 < n; ++i) {
|
||||
Line l_next = offset_segment(source[i], source[i + 1]);
|
||||
const Vec2d previous = (source[i] - source[i - 1]).cast<double>().normalized();
|
||||
const Vec2d next = (source[i + 1] - source[i]).cast<double>().normalized();
|
||||
const double denominator = 1. + previous.dot(next);
|
||||
|
||||
bool need_bevel = denominator <= EPSILON;
|
||||
Point pt;
|
||||
if (! need_bevel) {
|
||||
const Vec2d previous_normal(-previous.y(), previous.x());
|
||||
const Vec2d next_normal(-next.y(), next.x());
|
||||
const Vec2d miter = (previous_normal + next_normal) * (dir * offset_dist / denominator);
|
||||
if (miter.norm() > miter_limit * offset_dist) {
|
||||
need_bevel = true;
|
||||
} else {
|
||||
pt = Point(coord_t(source[i].x() + miter.x()),
|
||||
coord_t(source[i].y() + miter.y()));
|
||||
}
|
||||
}
|
||||
|
||||
if (need_bevel) {
|
||||
result.push_back(l_prev.b);
|
||||
if (l_next.a != result.back())
|
||||
result.push_back(l_next.a);
|
||||
} else {
|
||||
result.push_back(pt);
|
||||
}
|
||||
if (i == 1)
|
||||
first_join_index = result.size() - 1;
|
||||
l_prev = l_next;
|
||||
}
|
||||
|
||||
// Orca: the last point is perpendicular to the last segment.
|
||||
result.push_back(l_prev.b);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int wipe_offset_direction(bool is_ccw, bool is_hole)
|
||||
{
|
||||
const int loop_inside = is_ccw ? +1 : -1;
|
||||
return is_hole ? -loop_inside : loop_inside;
|
||||
}
|
||||
|
||||
static bool starts_by_backtracking(const Polyline &path, Point actual_start)
|
||||
{
|
||||
if (path.points.size() < 3)
|
||||
return false;
|
||||
// Orca: points[0] is only a storage sentinel; use the nozzle position for
|
||||
// the executable connector, particularly after a wipe_on_loops pre-move.
|
||||
const Vec2d connector = (path.points[1] - actual_start).cast<double>();
|
||||
const Vec2d outgoing = (path.points[2] - path.points[1]).cast<double>();
|
||||
// An inward connector may be perpendicular to the outgoing offset edge.
|
||||
// Rounded joins must not turn that right angle into a false backtrack.
|
||||
return connector.dot(outgoing) < -4. * SCALED_EPSILON * outgoing.norm();
|
||||
}
|
||||
|
||||
// Orca: sample the outgoing perimeter without copying or clipping its full loop.
|
||||
static Point sample_polyline_at_distance(const Polyline &polyline, double target)
|
||||
{
|
||||
assert(! polyline.points.empty());
|
||||
Point result = polyline.first_point();
|
||||
for (size_t i = 1; i < polyline.points.size() && target > 0.; ++i) {
|
||||
const Vec2d segment = (polyline.points[i] - result).cast<double>();
|
||||
const double length = segment.norm();
|
||||
if (length <= SCALED_EPSILON)
|
||||
continue;
|
||||
if (target <= length)
|
||||
return (result.cast<double>() + segment * (target / length)).cast<coord_t>();
|
||||
target -= length;
|
||||
result = polyline.points[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Orca: convert an executable path into Wipe::wipe()'s stored representation.
|
||||
// The first point is a dummy replaced by the actual nozzle position, while the
|
||||
// remaining points are clipped to the configured wipe distance.
|
||||
static bool store_wipe_path(Polyline &destination, Point seam_start,
|
||||
Polyline actual_path, double max_wipe_length)
|
||||
{
|
||||
if (actual_path.points.size() < 2 || max_wipe_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
const double actual_length = actual_path.length();
|
||||
if (actual_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
if (actual_length - max_wipe_length > SCALED_EPSILON)
|
||||
actual_path.clip_end(actual_length - max_wipe_length);
|
||||
if (actual_path.points.size() < 2)
|
||||
return false;
|
||||
for (size_t i = 1; i < actual_path.points.size(); ++i)
|
||||
if (actual_path.points[i - 1] == actual_path.points[i])
|
||||
return false;
|
||||
|
||||
Polyline stored_path;
|
||||
stored_path.points.reserve(actual_path.points.size());
|
||||
stored_path.points.push_back(seam_start);
|
||||
stored_path.points.insert(stored_path.points.end(), actual_path.points.begin() + 1, actual_path.points.end());
|
||||
stored_path.reset_to_linear_move();
|
||||
destination = std::move(stored_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool offset_wipe_path(Polyline &polyline, Point seam_start, Point seam_end, Point wipe_start,
|
||||
int dir, double offset_dist, double max_wipe_length)
|
||||
{
|
||||
assert(dir == +1 || dir == -1);
|
||||
assert(offset_dist > 0);
|
||||
if (polyline.points.empty() || polyline.first_point() != seam_start ||
|
||||
max_wipe_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
const Polyline original = polyline;
|
||||
const double original_length = original.length();
|
||||
if (original_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
double source_length = std::min(original_length, max_wipe_length);
|
||||
for (;;) {
|
||||
Polyline source = original;
|
||||
const double clip_distance = original_length - source_length;
|
||||
if (clip_distance > SCALED_EPSILON)
|
||||
source.clip_end(clip_distance);
|
||||
|
||||
Points wrapped_source;
|
||||
wrapped_source.reserve(source.points.size() + 1);
|
||||
if (seam_start == seam_end) {
|
||||
// Orca: the stored loop is open at seam_start even when the seam gap is
|
||||
// zero. Prepend the closing edge so build_offset_polyline() creates
|
||||
// the proper join between that edge and the first outgoing edge,
|
||||
// instead of leaving the first offset point on the closing wall.
|
||||
size_t closing_index = original.points.size();
|
||||
while (closing_index > 0 && original.points[closing_index - 1] == seam_start)
|
||||
--closing_index;
|
||||
if (closing_index == 0)
|
||||
return false; // Orca: the entire path is a single point.
|
||||
wrapped_source.push_back(original.points[closing_index - 1]);
|
||||
} else {
|
||||
// Orca: use the unextruded seam-gap edge to determine the incoming
|
||||
// direction at the seam. Its offset is construction geometry only;
|
||||
// wiping along it would create a Z-shaped detour before the outgoing
|
||||
// perimeter offset.
|
||||
wrapped_source.push_back(seam_end);
|
||||
}
|
||||
wrapped_source.insert(wrapped_source.end(), source.points.begin(), source.points.end());
|
||||
|
||||
Points offset_points;
|
||||
size_t first_join_index = 0;
|
||||
if (! build_offset_polyline(wrapped_source, dir, offset_dist, offset_points, first_join_index) ||
|
||||
first_join_index == 0 || first_join_index >= offset_points.size())
|
||||
return false;
|
||||
// Orca: discard the offset of the prepended edge and, for a bevel, its
|
||||
// incoming endpoint. The executable wipe starts at the seam join and
|
||||
// then follows only the already printed outgoing perimeter.
|
||||
offset_points.erase(offset_points.begin(), offset_points.begin() + first_join_index);
|
||||
|
||||
Polyline actual_path;
|
||||
actual_path.points.reserve(offset_points.size() + 1);
|
||||
actual_path.points.push_back(wipe_start);
|
||||
actual_path.points.insert(actual_path.points.end(), offset_points.begin(), offset_points.end());
|
||||
|
||||
// A loop pre-move may advance past an otherwise valid offset join.
|
||||
// Enter at the nozzle's projection instead of returning to the join.
|
||||
// Do not repair a join that already backtracks across the seam gap;
|
||||
// the caller must still validate wall crossings, material side and support.
|
||||
if (seam_start != seam_end && wipe_start != seam_start && wipe_start != seam_end &&
|
||||
starts_by_backtracking(actual_path, wipe_start) && ! starts_by_backtracking(actual_path, seam_end)) {
|
||||
size_t entry = 1;
|
||||
while (entry + 1 < actual_path.points.size()) {
|
||||
const Vec2d edge = (actual_path.points[entry + 1] - actual_path.points[entry]).cast<double>();
|
||||
const double projection = (wipe_start - actual_path.points[entry]).cast<double>().dot(edge);
|
||||
if (projection <= 0.)
|
||||
break;
|
||||
if (projection < edge.squaredNorm()) {
|
||||
actual_path.points[entry] = (actual_path.points[entry].cast<double>() +
|
||||
edge * (projection / edge.squaredNorm())).cast<coord_t>();
|
||||
break;
|
||||
}
|
||||
++entry;
|
||||
}
|
||||
actual_path.points.erase(actual_path.points.begin() + 1, actual_path.points.begin() + entry);
|
||||
}
|
||||
|
||||
if (seam_start != seam_end && wipe_start == seam_end &&
|
||||
starts_by_backtracking(actual_path, wipe_start)) {
|
||||
// Orca: a wide seam gap or a sharp cusp may put the first miter
|
||||
// behind its outgoing edge. Reject this offset candidate so the
|
||||
// caller can try the opposite side or the translated fallback.
|
||||
return false;
|
||||
}
|
||||
|
||||
const double actual_length = actual_path.length();
|
||||
const bool source_exhausted = original_length - source_length <= SCALED_EPSILON;
|
||||
if (actual_length + SCALED_EPSILON < max_wipe_length && ! source_exhausted) {
|
||||
// Orca: offset joins may shorten the path at every corner. Grow the
|
||||
// source until the executable offset path, not a heuristic source
|
||||
// margin, reaches the configured wipe distance.
|
||||
const double deficit = max_wipe_length - actual_length;
|
||||
const double next_length = std::min(original_length,
|
||||
source_length + std::max(deficit, 2. * SCALED_EPSILON));
|
||||
if (next_length - source_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
source_length = next_length;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Orca: unlike an extruded offset, a wipe may safely cross or retrace the
|
||||
// just-printed perimeter. The caller validates the complete executable
|
||||
// path against current and earlier printed perimeter geometry.
|
||||
return store_wipe_path(polyline, seam_start, std::move(actual_path), max_wipe_length);
|
||||
}
|
||||
}
|
||||
|
||||
static bool translated_wipe_path(Polyline &polyline, Point seam_start, Point seam_end, Point wipe_start,
|
||||
const Vec2d &translation, double max_wipe_length)
|
||||
{
|
||||
if (translation.norm() <= SCALED_EPSILON || max_wipe_length <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
const Polyline original = polyline;
|
||||
Polyline actual_path;
|
||||
actual_path.points.reserve(original.points.size() + 2);
|
||||
actual_path.points.push_back(wipe_start);
|
||||
|
||||
const auto append_translated = [&actual_path, &translation](const Point &point) {
|
||||
const Point translated = (point.cast<double>() + translation).cast<coord_t>();
|
||||
if (translated != actual_path.points.back())
|
||||
actual_path.points.push_back(translated);
|
||||
};
|
||||
|
||||
// Orca: translate the seam join directly. Translating seam_end and then
|
||||
// following the unextruded gap back to seam_start makes the wipe double
|
||||
// back whenever a gap ends near a sharp corner.
|
||||
append_translated(seam_start);
|
||||
for (const Point &point : original.points)
|
||||
append_translated(point);
|
||||
|
||||
if (seam_start != seam_end && wipe_start == seam_end &&
|
||||
starts_by_backtracking(actual_path, wipe_start)) {
|
||||
// Orca: at a wide gap next to a cusp, the translated seam join may
|
||||
// lie behind the outgoing edge. Prefer a shorter local inward move
|
||||
// at the actual extrusion end over a longer lightning-shaped wipe.
|
||||
actual_path.points.resize(1);
|
||||
append_translated(seam_end);
|
||||
}
|
||||
|
||||
return store_wipe_path(polyline, seam_start, std::move(actual_path), max_wipe_length);
|
||||
}
|
||||
|
||||
// A segment whose endpoints lie within one line's distance capsule is fully
|
||||
// supported, since that capsule is convex. Subdivide only when support changes
|
||||
// between lines; fixed-distance sampling can miss an unsupported gap.
|
||||
static bool segment_is_supported(Point start, Point end,
|
||||
const AABBTreeLines::LinesDistancer<Line> &distancer,
|
||||
double max_distance)
|
||||
{
|
||||
const Point midpoint = ((start.cast<double>() + end.cast<double>()) * 0.5).cast<coord_t>();
|
||||
const auto [distance, line_index, nearest] = distancer.distance_from_lines_extra<false>(midpoint);
|
||||
if (distance > max_distance)
|
||||
return false;
|
||||
|
||||
const Line &line = distancer.get_line(line_index);
|
||||
if (line.distance_to(start) <= max_distance && line.distance_to(end) <= max_distance)
|
||||
return true;
|
||||
if (distancer.distance_from_lines<false>(start) > max_distance ||
|
||||
distancer.distance_from_lines<false>(end) > max_distance)
|
||||
return false;
|
||||
|
||||
// Conservatively reject an unresolved transition at coordinate precision.
|
||||
if ((end - start).cast<double>().norm() <= SCALED_EPSILON)
|
||||
return false;
|
||||
return segment_is_supported(start, midpoint, distancer, max_distance) &&
|
||||
segment_is_supported(midpoint, end, distancer, max_distance);
|
||||
}
|
||||
|
||||
std::optional<double> wipe_path_support_score(
|
||||
const Polyline &polyline, Point wipe_start,
|
||||
const AABBTreeLines::LinesDistancer<Line> &target_distancer,
|
||||
const AABBTreeLines::LinesDistancer<Line> &all_support_distancer,
|
||||
double max_distance)
|
||||
{
|
||||
if (polyline.points.size() < 2 || target_distancer.get_lines().empty() || max_distance <= 0)
|
||||
return std::nullopt;
|
||||
|
||||
// Orca: require a local neighbour, not merely an earlier perimeter elsewhere in
|
||||
// the region. At a convex corner, an inner wall's miter is farther from the
|
||||
// external seam than its normal wall spacing, so allow the same bounded miter
|
||||
// reach as the offset construction without accepting a remote island.
|
||||
if (target_distancer.distance_from_lines<false>(wipe_start) >
|
||||
miter_limit * max_distance + 4. * SCALED_EPSILON)
|
||||
return std::nullopt;
|
||||
|
||||
Point previous = wipe_start;
|
||||
for (size_t i = 1; i < polyline.points.size(); ++i) {
|
||||
// Orca: a tightly curved inward path may cross back over the current wall.
|
||||
// This is safe for a non-extruding wipe as long as the complete path
|
||||
// remains over current or earlier printed perimeter geometry.
|
||||
// Allow the same coordinate-rounding tolerance at every point, including
|
||||
// the actual start substituted for the stored sentinel.
|
||||
if (! segment_is_supported(previous, polyline.points[i], all_support_distancer,
|
||||
max_distance + 4. * SCALED_EPSILON))
|
||||
return std::nullopt;
|
||||
previous = polyline.points[i];
|
||||
}
|
||||
|
||||
// Orca: decide direction at the seam. Scoring the complete path may select
|
||||
// the wrong initial side when two contours converge and the later prefix
|
||||
// happens to run closer to unrelated support.
|
||||
return target_distancer.distance_from_lines<false>(polyline.points[1]);
|
||||
}
|
||||
|
||||
static bool initial_connector_is_clear(
|
||||
const Polyline &polyline, Point wipe_start, Point seam_start,
|
||||
AABBTreeLines::LinesDistancer<Line> ¤t_perimeter_distancer,
|
||||
double contact_tolerance)
|
||||
{
|
||||
if (polyline.points.size() < 2 || polyline.points[1] == wipe_start)
|
||||
return false;
|
||||
|
||||
// Orca: without a seam gap, the connector necessarily starts at the wall
|
||||
// and a self-touching cusp may share that same endpoint on several edges.
|
||||
if (seam_start == wipe_start)
|
||||
return true;
|
||||
|
||||
const Line connector(wipe_start, polyline.points[1]);
|
||||
const auto intersections = current_perimeter_distancer.intersections_with_line<false>(connector);
|
||||
for (const auto &intersection : intersections) {
|
||||
if ((intersection.first - wipe_start).cast<double>().norm() > contact_tolerance)
|
||||
return false;
|
||||
}
|
||||
|
||||
Point closest;
|
||||
// Orca: integer offset joins may miss the exact seam-start coordinate by
|
||||
// a few microns. Treat a close pass through that point as retracing the
|
||||
// external wall, but keep the unavoidable contact at the actual start.
|
||||
if (connector.distance_to_squared(seam_start, &closest) <= contact_tolerance * contact_tolerance &&
|
||||
(closest - wipe_start).cast<double>().norm() > contact_tolerance)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::optional<Vec2d> support_offset_at_start(
|
||||
const Polyline &source, Point local_origin, bool disambiguate_branch,
|
||||
AABBTreeLines::LinesDistancer<Line> &support_distancer,
|
||||
double max_support_distance)
|
||||
{
|
||||
if (source.points.size() < 2)
|
||||
return std::nullopt;
|
||||
|
||||
// Orca: a nonzero gap may put the seam beside the wrong branch of a cusp.
|
||||
// Sample farther along the path to identify its actual neighbouring wall.
|
||||
const Point support_query = disambiguate_branch ?
|
||||
sample_polyline_at_distance(source, 2. * max_support_distance) : source.first_point();
|
||||
const auto nearest_result = support_distancer.distance_from_lines_extra<false>(support_query);
|
||||
const Line &nearest_line = support_distancer.get_line(std::get<1>(nearest_result));
|
||||
Vec2d sampled_offset = std::get<2>(nearest_result) - support_query.cast<double>();
|
||||
|
||||
if (disambiguate_branch) {
|
||||
// Orca: an endpoint projection also contains distance along the support
|
||||
// segment. Remove that tangent component before comparing wall sides.
|
||||
const Vec2d support_edge = (nearest_line.b - nearest_line.a).cast<double>();
|
||||
if (support_edge.norm() > SCALED_EPSILON) {
|
||||
const Vec2d support_tangent = support_edge.normalized();
|
||||
sampled_offset -= support_tangent * sampled_offset.dot(support_tangent);
|
||||
}
|
||||
}
|
||||
if (sampled_offset.norm() <= SCALED_EPSILON)
|
||||
return std::nullopt;
|
||||
|
||||
if (! disambiguate_branch)
|
||||
return sampled_offset;
|
||||
|
||||
// Orca: find the local point on the same material-side branch. Using the
|
||||
// sampled point itself would add the distance already travelled along the
|
||||
// perimeter and turn a normal transition into a long diagonal move.
|
||||
const Vec2d sampled_direction = sampled_offset.normalized();
|
||||
Vec2d local_offset = sampled_offset;
|
||||
double best_local_score = std::numeric_limits<double>::infinity();
|
||||
for (size_t line_index : support_distancer.all_lines_in_radius(
|
||||
local_origin, 2. * max_support_distance + 4. * SCALED_EPSILON)) {
|
||||
Point local_support;
|
||||
const Line &line = support_distancer.get_line(line_index);
|
||||
const double distance_squared = line.distance_to_squared(local_origin, &local_support);
|
||||
const Vec2d candidate_offset = local_support.cast<double>() - local_origin.cast<double>();
|
||||
const double candidate_distance = std::sqrt(distance_squared);
|
||||
if (candidate_distance <= SCALED_EPSILON)
|
||||
continue;
|
||||
const double alignment = candidate_offset.normalized().dot(sampled_direction);
|
||||
if (alignment < min_support_alignment)
|
||||
continue;
|
||||
const double score = candidate_distance / alignment;
|
||||
if (score < best_local_score) {
|
||||
best_local_score = score;
|
||||
local_offset = candidate_offset;
|
||||
}
|
||||
}
|
||||
return local_offset;
|
||||
}
|
||||
|
||||
static double executable_path_length(const Polyline &stored_path, Point wipe_start)
|
||||
{
|
||||
if (stored_path.points.size() < 2)
|
||||
return 0.;
|
||||
|
||||
// Orca: points[0] is the storage sentinel, so measure the first segment
|
||||
// from the actual nozzle position and the remaining stored segments normally.
|
||||
double length = (stored_path.points[1] - wipe_start).cast<double>().norm();
|
||||
for (size_t index = 2; index < stored_path.points.size(); ++index)
|
||||
length += (stored_path.points[index] - stored_path.points[index - 1]).cast<double>().norm();
|
||||
return length;
|
||||
}
|
||||
|
||||
static Lines material_side_support_lines(const Polyline &path, Point seam, int preferred_dir,
|
||||
const Lines &support_lines)
|
||||
{
|
||||
if (path.points.size() < 4 || path.first_point() != path.last_point())
|
||||
return {};
|
||||
|
||||
// Orca: the bisector of the incoming and outgoing material-side normals is
|
||||
// a local side test that remains valid for globally self-touching Arachne
|
||||
// contours. Ignore repeated seam points when obtaining both tangents.
|
||||
const auto outgoing_it = std::find_if(
|
||||
path.points.begin() + 1, path.points.end(), [seam](const Point &point) { return point != seam; });
|
||||
const auto incoming_it = std::find_if(
|
||||
path.points.rbegin() + 1, path.points.rend(), [seam](const Point &point) { return point != seam; });
|
||||
if (outgoing_it == path.points.end() || incoming_it == path.points.rend())
|
||||
return {};
|
||||
|
||||
const Vec2d outgoing = (*outgoing_it - seam).cast<double>().normalized();
|
||||
const Vec2d incoming = (seam - *incoming_it).cast<double>().normalized();
|
||||
const Vec2d material_direction =
|
||||
(Vec2d(-outgoing.y(), outgoing.x()) + Vec2d(-incoming.y(), incoming.x())) * preferred_dir;
|
||||
if (material_direction.norm() <= EPSILON)
|
||||
return {};
|
||||
|
||||
Lines result;
|
||||
result.reserve(support_lines.size());
|
||||
for (const Line &line : support_lines) {
|
||||
Point closest;
|
||||
line.distance_to_squared(seam, &closest);
|
||||
if ((closest - seam).cast<double>().dot(material_direction) > SCALED_EPSILON)
|
||||
result.push_back(line);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool wipe_path_stays_on_material_side(
|
||||
const Polyline &path, Point path_start, const Vec2d &support_direction,
|
||||
const AABBTreeLines::LinesDistancer<Line> &target_perimeter_distancer,
|
||||
const AABBTreeLines::LinesDistancer<Line> ¤t_perimeter_distancer,
|
||||
double effective_offset, bool require_clearance)
|
||||
{
|
||||
if (path.points.size() < 2 || support_direction.norm() <= EPSILON ||
|
||||
target_perimeter_distancer.get_lines().empty() || current_perimeter_distancer.get_lines().empty() ||
|
||||
effective_offset <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
const Vec2d initial_offset = (path.points[1] - path_start).cast<double>();
|
||||
if (initial_offset.norm() <= SCALED_EPSILON ||
|
||||
initial_offset.normalized().dot(support_direction.normalized()) < min_support_alignment)
|
||||
return false;
|
||||
// Orca: after the connector has left the extrusion endpoint, an inward
|
||||
// offset must retain most of its requested clearance from the current
|
||||
// external wall. Otherwise a tight turn may send an initially correct path
|
||||
// back onto that wall, or make the opposite-side candidate look supported.
|
||||
const double clearance_tolerance = wipe_tolerance(effective_offset, 0.25);
|
||||
const double minimum_clearance = effective_offset - clearance_tolerance;
|
||||
const Lines &lines = current_perimeter_distancer.get_lines();
|
||||
const auto left_normal = [](const Line &line) -> Vec2d {
|
||||
const Vec2d edge = (line.b - line.a).cast<double>();
|
||||
if (edge.norm() <= SCALED_EPSILON)
|
||||
return Vec2d::Zero();
|
||||
return Vec2d(-edge.y(), edge.x()).normalized();
|
||||
};
|
||||
const auto on_material_side = [&](const Point &point, bool check_clearance) {
|
||||
const auto [distance, line_index, nearest] =
|
||||
current_perimeter_distancer.distance_from_lines_extra<false>(point);
|
||||
if (line_index >= lines.size())
|
||||
return false;
|
||||
const Line &line = lines[line_index];
|
||||
Vec2d normal = left_normal(line);
|
||||
// At a shared vertex use both incident edges, so the result does not
|
||||
// depend on which equally close edge the AABB query happens to return.
|
||||
const Line &previous = lines[(line_index + lines.size() - 1) % lines.size()];
|
||||
const Line &next = lines[(line_index + 1) % lines.size()];
|
||||
if ((nearest - line.a.cast<double>()).norm() <= SCALED_EPSILON && previous.b == line.a)
|
||||
normal += left_normal(previous);
|
||||
if ((nearest - line.b.cast<double>()).norm() <= SCALED_EPSILON && next.a == line.b)
|
||||
normal += left_normal(next);
|
||||
if (normal.norm() <= EPSILON)
|
||||
return false;
|
||||
|
||||
// An open or self-touching wall has no reliable polygon-wide sign.
|
||||
// Orient its local normal toward the neighbouring printed inner wall,
|
||||
// then test the candidate on that side at every sample.
|
||||
normal.normalize();
|
||||
const Point wall_point = nearest.cast<coord_t>();
|
||||
const Vec2d support_point = std::get<2>(
|
||||
target_perimeter_distancer.distance_from_lines_extra<false>(wall_point));
|
||||
const double support_side = (support_point - nearest).dot(normal);
|
||||
if (std::abs(support_side) <= 4. * SCALED_EPSILON)
|
||||
return false;
|
||||
const double side = (point.cast<double>() - nearest).dot(normal) * (support_side > 0. ? 1. : -1.);
|
||||
return side >= -4. * SCALED_EPSILON &&
|
||||
(! check_clearance || distance + 4. * SCALED_EPSILON >= minimum_clearance);
|
||||
};
|
||||
|
||||
Point previous = path.points[1];
|
||||
if (! on_material_side(previous, require_clearance))
|
||||
return false;
|
||||
for (size_t index = 2; index < path.points.size(); ++index) {
|
||||
const Vec2d segment = (path.points[index] - previous).cast<double>();
|
||||
const size_t samples = std::max<size_t>(1, size_t(std::ceil(segment.norm() / effective_offset)));
|
||||
for (size_t sample = 1; sample <= samples; ++sample) {
|
||||
const Point point = (previous.cast<double>() +
|
||||
segment * (double(sample) / double(samples))).cast<coord_t>();
|
||||
if (! on_material_side(point, require_clearance))
|
||||
return false;
|
||||
}
|
||||
previous = path.points[index];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool offset_wipe_path_toward_support(Polyline &polyline, Point seam_start, Point seam_end, Point wipe_start,
|
||||
int preferred_dir, double offset_dist, double max_wipe_length,
|
||||
const Lines &target_perimeter_lines, const Lines &printed_perimeter_lines,
|
||||
const Lines ¤t_perimeter_lines,
|
||||
double max_support_distance)
|
||||
{
|
||||
assert(preferred_dir == +1 || preferred_dir == -1);
|
||||
if (polyline.points.size() < 2 || target_perimeter_lines.empty() || current_perimeter_lines.empty() ||
|
||||
offset_dist <= SCALED_EPSILON ||
|
||||
max_wipe_length <= SCALED_EPSILON || max_support_distance <= SCALED_EPSILON)
|
||||
return false;
|
||||
|
||||
Lines material_support_lines;
|
||||
const Lines *candidate_support_lines = &target_perimeter_lines;
|
||||
if (seam_start == seam_end) {
|
||||
// Orca: another contour may have a geometrically closer inner wall on
|
||||
// this loop's air side. Restrict zero-gap support using the local seam
|
||||
// normals before choosing the nearest wall.
|
||||
material_support_lines = material_side_support_lines(
|
||||
polyline, seam_start, preferred_dir, target_perimeter_lines);
|
||||
if (material_support_lines.empty())
|
||||
return false;
|
||||
candidate_support_lines = &material_support_lines;
|
||||
}
|
||||
|
||||
AABBTreeLines::LinesDistancer<Line> support_distancer(*candidate_support_lines);
|
||||
const std::optional<Vec2d> support_offset = support_offset_at_start(
|
||||
polyline, seam_end, seam_start != seam_end,
|
||||
support_distancer, max_support_distance);
|
||||
if (! support_offset)
|
||||
return false;
|
||||
const Vec2d toward_support = *support_offset;
|
||||
const double local_support_distance = toward_support.norm();
|
||||
const double effective_offset = std::min(offset_dist, local_support_distance);
|
||||
if (effective_offset <= SCALED_EPSILON)
|
||||
return false;
|
||||
const Vec2d support_direction = toward_support / local_support_distance;
|
||||
|
||||
// Orca: every candidate is validated against the same generated geometry.
|
||||
// Build these AABB trees once per loop instead of rebuilding them for each
|
||||
// preferred, alternate, translated, direct, or reversed candidate.
|
||||
Lines all_support_lines = printed_perimeter_lines;
|
||||
all_support_lines.insert(all_support_lines.end(), current_perimeter_lines.begin(), current_perimeter_lines.end());
|
||||
AABBTreeLines::LinesDistancer<Line> all_support_distancer(std::move(all_support_lines));
|
||||
AABBTreeLines::LinesDistancer<Line> current_perimeter_distancer(current_perimeter_lines);
|
||||
|
||||
// Orca: allow only the contact needed to leave the extrusion endpoint. A
|
||||
// connector that meets the current wall again is a seam-gap retrace, even
|
||||
// if the rest of the non-extruding wipe remains over printed material.
|
||||
const double contact_tolerance = wipe_tolerance(effective_offset);
|
||||
|
||||
struct Candidate {
|
||||
Polyline path;
|
||||
// Orca: support score chooses the material-side path; length is used
|
||||
// only to replace a corner-truncated path with the reverse fallback.
|
||||
double support_score;
|
||||
double path_length;
|
||||
};
|
||||
|
||||
// Direction and wall contact have different origins after a loop pre-move.
|
||||
// Keep the construction's wall endpoint for intersection checks even when
|
||||
// the candidate's direction must be checked from the current nozzle position.
|
||||
const auto validate_candidate = [&](Polyline path, Point path_start, Point direction_start,
|
||||
double path_contact_tolerance,
|
||||
const Vec2d &candidate_support_direction,
|
||||
double candidate_offset,
|
||||
bool require_clearance = true) -> std::optional<Candidate> {
|
||||
// Orca: backtracking indicates a wrong join only across a nonzero gap.
|
||||
// A closed zero-gap offset may initially turn back at its miter while
|
||||
// still remaining on the supported material side of the perimeter.
|
||||
const bool backtracks_across_gap = seam_start != seam_end && starts_by_backtracking(path, wipe_start);
|
||||
// At a clipped corner another branch of the current wall may be closer
|
||||
// than the requested offset. Preserve the zero-gap clearance rule, but
|
||||
// check direction and local material side independently for every gap.
|
||||
const bool material_side = wipe_path_stays_on_material_side(
|
||||
path, direction_start, candidate_support_direction,
|
||||
support_distancer, current_perimeter_distancer, candidate_offset,
|
||||
require_clearance && seam_start == seam_end);
|
||||
const bool connector_clear = initial_connector_is_clear(
|
||||
path, wipe_start, path_start, current_perimeter_distancer, path_contact_tolerance);
|
||||
if (backtracks_across_gap || ! material_side || ! connector_clear)
|
||||
return std::nullopt;
|
||||
const std::optional<double> score = wipe_path_support_score(
|
||||
path, wipe_start, support_distancer, all_support_distancer, max_support_distance);
|
||||
if (! score)
|
||||
return std::nullopt;
|
||||
const double path_length = executable_path_length(path, wipe_start);
|
||||
return Candidate{std::move(path), *score, path_length};
|
||||
};
|
||||
|
||||
const auto offset_candidate = [&](int dir) -> std::optional<Candidate> {
|
||||
Polyline path = polyline;
|
||||
if (! offset_wipe_path(path, seam_start, seam_end, wipe_start, dir,
|
||||
effective_offset, max_wipe_length))
|
||||
return std::nullopt;
|
||||
return validate_candidate(std::move(path), seam_start, seam_start,
|
||||
contact_tolerance, support_direction, effective_offset);
|
||||
};
|
||||
|
||||
std::optional<Candidate> preferred = offset_candidate(preferred_dir);
|
||||
std::optional<Candidate> alternate = offset_candidate(-preferred_dir);
|
||||
|
||||
// Orca: forward and reverse fallbacks share the same clamping, translation,
|
||||
// connector tolerance, and complete-path validation.
|
||||
const auto translated_candidate = [&](Polyline source, Point source_start, Point source_end,
|
||||
const Vec2d &candidate_support_offset) -> std::optional<Candidate> {
|
||||
const double support_distance = candidate_support_offset.norm();
|
||||
const double candidate_offset = std::min(offset_dist, support_distance);
|
||||
if (candidate_offset <= SCALED_EPSILON)
|
||||
return std::nullopt;
|
||||
|
||||
const Vec2d candidate_translation = candidate_support_offset * (candidate_offset / support_distance);
|
||||
if (! translated_wipe_path(source, source_start, source_end, wipe_start,
|
||||
candidate_translation, max_wipe_length))
|
||||
return std::nullopt;
|
||||
const double candidate_tolerance = wipe_tolerance(candidate_offset);
|
||||
return validate_candidate(std::move(source), source_start, source_start, candidate_tolerance,
|
||||
candidate_support_offset / support_distance, candidate_offset);
|
||||
};
|
||||
|
||||
std::optional<Candidate> translated = translated_candidate(polyline, seam_start, seam_end, toward_support);
|
||||
|
||||
// Orca: if every full-length construction folds back onto the external
|
||||
// wall, retain a short direct inward move instead of accepting an outward
|
||||
// candidate or falling back to the standard wipe along the outer wall.
|
||||
const auto direct_candidate = [&](Point origin, const Vec2d &candidate_support_offset) -> std::optional<Candidate> {
|
||||
const double support_distance = candidate_support_offset.norm();
|
||||
const double candidate_offset = std::min(offset_dist, support_distance);
|
||||
if (candidate_offset <= SCALED_EPSILON)
|
||||
return std::nullopt;
|
||||
const Vec2d direction = candidate_support_offset / support_distance;
|
||||
const Point destination = (origin.cast<double>() + direction * candidate_offset).cast<coord_t>();
|
||||
if (destination == wipe_start)
|
||||
return std::nullopt;
|
||||
|
||||
Polyline path;
|
||||
if (! store_wipe_path(path, seam_start, Polyline{wipe_start, destination}, max_wipe_length))
|
||||
return std::nullopt;
|
||||
const double candidate_tolerance = wipe_tolerance(candidate_offset);
|
||||
// Check the executed direction from the nozzle after any loop pre-move,
|
||||
// but retain the wall origin for the connector's intersection checks.
|
||||
return validate_candidate(std::move(path), origin, wipe_start,
|
||||
candidate_tolerance, direction, candidate_offset, false);
|
||||
};
|
||||
std::optional<Candidate> direct = direct_candidate(seam_end, toward_support);
|
||||
|
||||
const double length_margin = wipe_tolerance(max_wipe_length);
|
||||
std::optional<Candidate> reversed;
|
||||
if (seam_start != seam_end && polyline.last_point() == seam_end) {
|
||||
// Orca: when a large gap straddles a sharp corner, connecting the
|
||||
// extrusion end to the forward offset may either reverse or leave only
|
||||
// a short local move. The already printed incoming wall is equally safe:
|
||||
// follow it backwards and determine its own material-side support.
|
||||
Polyline reversed_source = polyline;
|
||||
reversed_source.reverse();
|
||||
const std::optional<Vec2d> reversed_support_offset = support_offset_at_start(
|
||||
reversed_source, seam_end, true, support_distancer, max_support_distance);
|
||||
if (reversed_support_offset) {
|
||||
reversed = translated_candidate(reversed_source, seam_end, seam_end, *reversed_support_offset);
|
||||
// A translated reverse path can backtrack or leave the material on
|
||||
// a curved wall. Offset the incoming wall itself when translation
|
||||
// cannot supply a complete wipe, retaining all candidate checks.
|
||||
if (! reversed || reversed->path_length + length_margin < max_wipe_length) {
|
||||
const double reverse_offset = std::min(offset_dist, reversed_support_offset->norm());
|
||||
if (reverse_offset > SCALED_EPSILON &&
|
||||
offset_wipe_path(reversed_source, seam_end, seam_start, wipe_start,
|
||||
-preferred_dir, reverse_offset, max_wipe_length)) {
|
||||
reversed_source.points.front() = seam_start;
|
||||
auto candidate = validate_candidate(std::move(reversed_source), seam_end, seam_end,
|
||||
wipe_tolerance(reverse_offset), reversed_support_offset->normalized(), reverse_offset);
|
||||
if (candidate && (! reversed ||
|
||||
(candidate->path_length > reversed->path_length + length_margin &&
|
||||
candidate->support_score <= reversed->support_score + wipe_tolerance(reverse_offset))))
|
||||
reversed = std::move(candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Orca: conventional offsets at a narrow cusp may form a bevel across the
|
||||
// cusp. Candidates pointing away from the actual inner wall are rejected
|
||||
// during validation; among the remaining paths, prefer the one whose first
|
||||
// point is materially closer to that wall.
|
||||
const double direction_change_margin = wipe_tolerance(effective_offset);
|
||||
std::optional<Candidate> selected = std::move(preferred);
|
||||
if (translated) {
|
||||
if (! selected || translated->support_score + direction_change_margin < selected->support_score)
|
||||
selected = std::move(translated);
|
||||
}
|
||||
if (! selected)
|
||||
selected = std::move(direct);
|
||||
// Prefer a direct inward move when the normal offset cannot be used.
|
||||
// An alternate offset is eligible only after the same material-side checks.
|
||||
if (! selected)
|
||||
selected = std::move(alternate);
|
||||
|
||||
// Orca: prefer a complete reverse wipe over a forward fallback that had to
|
||||
// stop at the corner. Equal-length paths keep the normal forward behavior.
|
||||
if (reversed && (! selected ||
|
||||
(reversed->path_length > selected->path_length + length_margin &&
|
||||
reversed->support_score <= selected->support_score + direction_change_margin)))
|
||||
selected = std::move(reversed);
|
||||
if (! selected)
|
||||
return false;
|
||||
|
||||
polyline = std::move(selected->path);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::optional<Point> wipe_on_loops_destination(const ExtrusionPaths &paths, double nozzle_diam_scaled,
|
||||
bool is_ccw, bool is_hole)
|
||||
{
|
||||
assert(!paths.empty());
|
||||
assert(nozzle_diam_scaled > 0);
|
||||
if (paths.empty() || nozzle_diam_scaled <= 0)
|
||||
return std::nullopt;
|
||||
|
||||
// Orca: clamp sample distance to L/4 so forward/backward samples cannot meet.
|
||||
double total_length = 0.;
|
||||
for (const ExtrusionPath &path : paths)
|
||||
total_length += path.length();
|
||||
const double sample_distance = std::min(nozzle_diam_scaled, total_length * 0.25);
|
||||
|
||||
Point a = sample_path_at_distance(paths, true, sample_distance);
|
||||
Point b = sample_path_at_distance(paths, false, sample_distance);
|
||||
|
||||
const Point seam_start = paths.front().first_point();
|
||||
|
||||
// Orca: skip the inward move for degenerate geometry.
|
||||
if (a == b || a == seam_start || b == seam_start)
|
||||
return std::nullopt;
|
||||
|
||||
const bool reverse_turn = is_hole == is_ccw;
|
||||
if (reverse_turn)
|
||||
std::swap(a, b);
|
||||
|
||||
double angle = seam_start.ccw_angle(a, b) / 3;
|
||||
|
||||
// Orca: reject degenerate angles near 0 or 2π.
|
||||
static constexpr double angle_epsilon = 0.01;
|
||||
if (angle < angle_epsilon || angle > 2 * PI / 3 - angle_epsilon)
|
||||
return std::nullopt;
|
||||
|
||||
if (reverse_turn)
|
||||
angle *= -1;
|
||||
|
||||
Point pt = sample_path_at_distance(paths, true, std::min(0.2 * nozzle_diam_scaled, sample_distance));
|
||||
pt.rotate(angle, seam_start);
|
||||
return pt;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "../ExtrusionEntity.hpp"
|
||||
#include "../Polyline.hpp"
|
||||
#include "../Line.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// Printed prefix of one region's perimeter sequence. Append each entity only
|
||||
// after extrusion; later walls and other regions cannot support an inward wipe.
|
||||
struct WipeInwardSupport {
|
||||
Lines printed_lines;
|
||||
Lines inner_lines;
|
||||
void append(const ExtrusionEntity &entity);
|
||||
};
|
||||
|
||||
namespace AABBTreeLines {
|
||||
template <typename LineType> class LinesDistancer;
|
||||
}
|
||||
|
||||
// Orca: sample a point at a given distance along ExtrusionPaths, walking
|
||||
// across segment boundaries. forward=true walks from paths.front, false from
|
||||
// paths.back. For tiny loops the walk stops early and returns the last
|
||||
// reachable point. Returns the start point if target is zero.
|
||||
// Precondition: paths must be non-empty.
|
||||
Point sample_path_at_distance(const ExtrusionPaths &paths, bool forward, double target);
|
||||
|
||||
// Orca: return the side of the printed path on which the material lies.
|
||||
// dir +1 is left and -1 is right, matching the offset-builder convention.
|
||||
int wipe_offset_direction(bool is_ccw, bool is_hole);
|
||||
|
||||
// Orca: atomically offset a stored wipe path. The seam-gap or closing edge
|
||||
// determines the join with the first outgoing perimeter edge, but its offset
|
||||
// is not part of the executable wipe. Only the prefix needed by Wipe::wipe()
|
||||
// is offset. Returns false and leaves polyline unchanged if that path cannot
|
||||
// be constructed without degenerate segments. This only constructs a candidate;
|
||||
// offset_wipe_path_toward_support() validates its support, material side and
|
||||
// connector before accepting it. The first stored point
|
||||
// remains a dummy preserving Wipe::wipe()'s convention of skipping points[0].
|
||||
// Precondition: polyline starts at seam_start, dir is +1 or -1, and
|
||||
// offset_dist > 0. A non-positive max_wipe_length returns false.
|
||||
bool offset_wipe_path(Polyline &polyline, Point seam_start, Point seam_end, Point wipe_start,
|
||||
int dir, double offset_dist, double max_wipe_length);
|
||||
|
||||
// Orca: score a candidate's first destination by distance to the target inner
|
||||
// walls. Return nullopt if no target wall is near wipe_start or any executable
|
||||
// segment lacks support. target_distancer contains eligible earlier walls;
|
||||
// all_support_distancer includes the current wall and all earlier walls.
|
||||
// The stored first point is a dummy: the first segment starts at wipe_start.
|
||||
// This checks support only; material-side and connector checks belong to
|
||||
// offset_wipe_path_toward_support(). Trees are reused across its candidates.
|
||||
std::optional<double> wipe_path_support_score(
|
||||
const Polyline &polyline, Point wipe_start,
|
||||
const AABBTreeLines::LinesDistancer<Line> &target_distancer,
|
||||
const AABBTreeLines::LinesDistancer<Line> &all_support_distancer,
|
||||
double max_distance);
|
||||
|
||||
// Validate the initial inward direction and the local material side along the
|
||||
// executable path, using the inner wall to orient the open current wall's
|
||||
// normals. Clearance is optional for clipped corners and short direct fallbacks;
|
||||
// the material-side check is mandatory. The straight connector is checked by
|
||||
// its initial direction and separately by support and intersection validation.
|
||||
// path_start is the construction origin; points[0] is only a storage sentinel.
|
||||
bool wipe_path_stays_on_material_side(
|
||||
const Polyline &path, Point path_start, const Vec2d &support_direction,
|
||||
const AABBTreeLines::LinesDistancer<Line> &target_perimeter_distancer,
|
||||
const AABBTreeLines::LinesDistancer<Line> ¤t_perimeter_distancer,
|
||||
double effective_offset, bool require_clearance);
|
||||
|
||||
// Orca: identify the adjacent inner perimeter from the outgoing wall, excluding
|
||||
// support on the air side of a closed zero-gap loop. Clamp the requested offset
|
||||
// to the distance from the seam end to that support, then select the safest
|
||||
// supported offset or translated path. If a wide seam gap at a corner truncates
|
||||
// every forward candidate, the incoming printed wall may be followed backwards
|
||||
// instead. All earlier printed perimeters still participate in the complete-path
|
||||
// safety check. This handles converging, locally ambiguous, or self-touching
|
||||
// contours whose global winding alone does not identify the material side.
|
||||
// Returns false and leaves polyline unchanged when no candidate is supported.
|
||||
// Precondition: preferred_dir is +1 or -1. Distances must be positive.
|
||||
bool offset_wipe_path_toward_support(Polyline &polyline, Point seam_start, Point seam_end, Point wipe_start,
|
||||
int preferred_dir, double offset_dist, double max_wipe_length,
|
||||
const Lines &target_perimeter_lines, const Lines &printed_perimeter_lines,
|
||||
const Lines ¤t_perimeter_lines,
|
||||
double max_support_distance);
|
||||
|
||||
// Orca: compute the inward destination point for wipe_on_loops, or
|
||||
// std::nullopt when the geometry is degenerate (tiny loop, coincident samples,
|
||||
// angle near 0 or 2π). Returns the rotated destination or nullopt to skip the
|
||||
// inward move entirely.
|
||||
// Precondition: paths non-empty, nozzle_diam_scaled > 0.
|
||||
std::optional<Point> wipe_on_loops_destination(const ExtrusionPaths &paths, double nozzle_diam_scaled,
|
||||
bool is_ccw, bool is_hole);
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -25,6 +25,30 @@ static constexpr int arc_fit_size = 20;
|
||||
enum class LimitFlow { None, LimitPrintFlow, LimitRammingFlow, LimitRammingFlowNC};//nc:nozzle change
|
||||
static const std::map<float, float> nozzle_diameter_to_nozzle_change_width{{0.2f, 0.5f}, {0.4f, 1.0f}, {0.6f, 1.2f}, {0.8f, 1.4f}};
|
||||
|
||||
bool wipe_tower_sparse_layers_skipped(const PrintConfig &config)
|
||||
{
|
||||
return config.wipe_tower_no_sparse_layers.value && config.timelapse_type.value != TimelapseType::tlSmooth &&
|
||||
! config.enable_wrapping_detection.value;
|
||||
}
|
||||
|
||||
bool wipe_tower_layer_is_sparse(const std::vector<WipeTower::ToolChangeResult> &layer_tool_changes)
|
||||
{
|
||||
return layer_tool_changes.size() == 1 && layer_tool_changes.front().initial_tool == layer_tool_changes.front().new_tool;
|
||||
}
|
||||
|
||||
std::vector<float> compute_compacted_wipe_tower_z(const std::vector<std::vector<WipeTower::ToolChangeResult>> &tool_changes,
|
||||
float base_z)
|
||||
{
|
||||
std::vector<float> tower_z(tool_changes.size(), base_z);
|
||||
float last = base_z;
|
||||
for (size_t i = 0; i < tool_changes.size(); ++i) {
|
||||
if (! tool_changes[i].empty() && ! wipe_tower_layer_is_sparse(tool_changes[i]))
|
||||
last += tool_changes[i].front().layer_height;
|
||||
tower_z[i] = last;
|
||||
}
|
||||
return tower_z;
|
||||
}
|
||||
|
||||
inline float align_round(float value, float base)
|
||||
{
|
||||
return std::round(value / base) * base;
|
||||
@@ -1349,7 +1373,7 @@ public:
|
||||
// flavor it reaches understands, not the zero dwell the other flavors flush with.
|
||||
buffer += "M400\n";
|
||||
buffer += "M104";
|
||||
if (target_extruder != -1)
|
||||
if (target_extruder != -1 && target_extruder < int(m_physical_extruder_map.size()))
|
||||
buffer += (" T" + std::to_string(m_physical_extruder_map[target_extruder]));
|
||||
buffer += " S" + std::to_string(target_temp) + " N0"; // N0 means the gcode is generated by slicer
|
||||
if (!comment.empty()) buffer += " ;" + comment;
|
||||
@@ -1361,7 +1385,7 @@ public:
|
||||
WipeTowerWriter &format_line_M109(int target_temp, int target_extruder, const std::string &comment = std::string())
|
||||
{
|
||||
std::string buffer = "M109";
|
||||
if (target_extruder != -1)
|
||||
if (target_extruder != -1 && target_extruder < int(m_physical_extruder_map.size()))
|
||||
buffer += (" T" + std::to_string(m_physical_extruder_map[target_extruder]));
|
||||
buffer += " S" + std::to_string(target_temp) + " N0"; // N0 means the gcode is generated by slicer
|
||||
if (!comment.empty()) buffer += " ;" + comment;
|
||||
@@ -1879,7 +1903,7 @@ WipeTower::WipeTower(const PrintConfig& config, int plate_idx, Vec3d plate_origi
|
||||
m_z_pos(0.f),
|
||||
//m_bridging(float(config.wipe_tower_bridging)),
|
||||
m_bridging(10.f),
|
||||
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
|
||||
m_sparse_layers_skipped(wipe_tower_sparse_layers_skipped(config)),
|
||||
m_gcode_flavor(config.gcode_flavor),
|
||||
m_travel_speed(config.travel_speed.get_at(get_extruder_index(config, (unsigned int)initial_tool))),
|
||||
m_current_tool(initial_tool),
|
||||
@@ -2977,7 +3001,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer(bool extrude_perimeter, bool
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (! m_no_sparse_layers || toolchanges_on_layer)
|
||||
if (! m_sparse_layers_skipped || toolchanges_on_layer)
|
||||
if (m_current_tool < m_used_filament_length.size())
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
@@ -3021,7 +3045,7 @@ void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned in
|
||||
if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
|
||||
m_plan.push_back(WipeTowerInfo(z_par, layer_height_par));
|
||||
|
||||
if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool))
|
||||
if (m_first_layer_idx == size_t(-1) && (! m_sparse_layers_skipped || old_tool != new_tool))
|
||||
m_first_layer_idx = m_plan.size() - 1;
|
||||
|
||||
if (old_tool == new_tool) // new layer without toolchanges - we are done
|
||||
@@ -3309,7 +3333,7 @@ void WipeTower::get_wall_skip_points(const WipeTowerInfo &layer, int layer_id)
|
||||
if (!cur_block_depth.count(m_filpar[new_filament].category)) cur_block_depth[m_filpar[new_filament].category] = block->start_depth;
|
||||
process_depth = cur_block_depth[m_filpar[new_filament].category];
|
||||
if (is_need_ramming(new_filament, old_filament, layer_id)) {
|
||||
if (m_filament_categories[new_filament] == m_filament_categories[old_filament])
|
||||
if (get_filament_category(new_filament) == get_filament_category(old_filament))
|
||||
process_depth += nozzle_change_depth;
|
||||
else {
|
||||
if (!cur_block_depth.count(m_filpar[old_filament].category)) {
|
||||
@@ -3874,7 +3898,7 @@ WipeTower::ToolChangeResult WipeTower::finish_layer_new(bool extrude_perimeter,
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (!m_no_sparse_layers || toolchanges_on_layer)
|
||||
if (!m_sparse_layers_skipped || toolchanges_on_layer)
|
||||
if (m_current_tool < m_used_filament_length.size())
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
@@ -3984,7 +4008,7 @@ WipeTower::ToolChangeResult WipeTower::finish_block(const WipeTowerBlock &block,
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (!m_no_sparse_layers || toolchanges_on_layer)
|
||||
if (!m_sparse_layers_skipped || toolchanges_on_layer)
|
||||
if (filament_id < m_used_filament_length.size())
|
||||
m_used_filament_length[filament_id] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
@@ -4101,7 +4125,7 @@ WipeTower::ToolChangeResult WipeTower::finish_block_solid(const WipeTowerBlock &
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (!m_no_sparse_layers || toolchanges_on_layer)
|
||||
if (!m_sparse_layers_skipped || toolchanges_on_layer)
|
||||
if (filament_id < m_used_filament_length.size())
|
||||
m_used_filament_length[filament_id] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
@@ -4783,7 +4807,7 @@ int WipeTower::get_wall_filament_for_all_layer()
|
||||
int filament_id = -1;
|
||||
int filament_count = 0;
|
||||
for (auto iter = filament_counts.begin(); iter != filament_counts.end(); ++iter) {
|
||||
if (m_filament_categories[iter->first] == selected_category && iter->second > filament_count) {
|
||||
if (get_filament_category(iter->first) == selected_category && iter->second > filament_count) {
|
||||
filament_id = iter->first;
|
||||
filament_count = iter->second;
|
||||
}
|
||||
@@ -5155,7 +5179,7 @@ WipeTower::ToolChangeResult WipeTower::only_generate_out_wall(bool is_new_mode)
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (!m_no_sparse_layers || toolchanges_on_layer)
|
||||
if (!m_sparse_layers_skipped || toolchanges_on_layer)
|
||||
if (m_current_tool < m_used_filament_length.size()) m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
|
||||
return construct_tcr(writer, false, old_tool, true, false, 0.f, false);
|
||||
|
||||
@@ -521,7 +521,7 @@ private:
|
||||
//float m_parking_pos_retraction = 0.f;
|
||||
//float m_extra_loading_move = 0.f;
|
||||
float m_bridging = 0.f;
|
||||
bool m_no_sparse_layers = false;
|
||||
bool m_sparse_layers_skipped = false;
|
||||
// BBS: remove useless config
|
||||
//bool m_set_extruder_trimpot = false;
|
||||
bool m_adhesion = true;
|
||||
@@ -680,6 +680,24 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// Compaction rule for wipe_tower_no_sparse_layers. Shared by the G-code emitter and by the
|
||||
// clearance validator so that both agree on where the compacted tower actually sits; a drift
|
||||
// between the two would either let a real nozzle collision through or reject a safe plate.
|
||||
|
||||
// Whether sparse layers are really skipped, i.e. whether the tower is compacted at all. Smooth
|
||||
// timelapse and wrapping detection put a tower on every layer, so no layer is ever dropped and the
|
||||
// tower keeps following the object even though the option is on. Tower planning, G-code emission and
|
||||
// the clearance validator all ask this single question, so none of them can compact on its own.
|
||||
bool wipe_tower_sparse_layers_skipped(const PrintConfig &config);
|
||||
|
||||
// A planned layer prints no tower at all when its only toolchange keeps the same filament.
|
||||
bool wipe_tower_layer_is_sparse(const std::vector<WipeTower::ToolChangeResult> &layer_tool_changes);
|
||||
|
||||
// Print z the compacted tower reaches on every planned layer. Sparse layers carry over the
|
||||
// previous value, so the tower falls one layer height behind the object for each of them. base_z is
|
||||
// the z the tower starts from, which Orca offsets by z_offset.
|
||||
std::vector<float> compute_compacted_wipe_tower_z(const std::vector<std::vector<WipeTower::ToolChangeResult>> &tool_changes,
|
||||
float base_z = 0.f);
|
||||
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -1032,7 +1032,7 @@ WipeTower2::WipeTower2(const PrintConfig& config, const PrintRegionConfig& defau
|
||||
m_y_shift(0.f),
|
||||
m_z_pos(0.f),
|
||||
m_bridging(float(config.wipe_tower_bridging)),
|
||||
m_no_sparse_layers(config.wipe_tower_no_sparse_layers),
|
||||
m_sparse_layers_skipped(wipe_tower_sparse_layers_skipped(config)),
|
||||
m_gcode_flavor(config.gcode_flavor),
|
||||
m_travel_speed(config.travel_speed.get_at(get_extruder_index(config, (unsigned int)initial_tool))),
|
||||
m_infill_speed(default_region_config.sparse_infill_speed.get_at(get_extruder_index(config, (unsigned int)initial_tool))),
|
||||
@@ -1730,7 +1730,7 @@ void WipeTower2::toolchange_Change(
|
||||
} else if (m_wall_type == (int)wtwCone) {
|
||||
const double support_scale = get_wipe_tower_cone_base(m_wipe_tower_width, m_wipe_tower_height, m_wipe_tower_depth,
|
||||
m_wipe_tower_cone_angle).second;
|
||||
const double z = m_no_sparse_layers ? (m_current_height + m_layer_info->height) : m_layer_info->z;
|
||||
const double z = m_sparse_layers_skipped ? (m_current_height + m_layer_info->height) : m_layer_info->z;
|
||||
const double r = std::tan(Geometry::deg2rad(m_wipe_tower_cone_angle / 2.f)) * (m_wipe_tower_height - z);
|
||||
const double w = m_layer_info->depth + m_perimeter_width;
|
||||
if (r > 0.5 * w + 0.01) { // same guard as generate_support_cone_wall
|
||||
@@ -1872,7 +1872,7 @@ void WipeTower2::toolchange_Wipe(
|
||||
// All the calculations in all other places take the spacing into account for all the layers.
|
||||
|
||||
// If spare layers are excluded->if 1 or less toolchange has been done, it must be sill the first layer, too.So slow down.
|
||||
const float target_speed = is_first_layer() || (m_num_tool_changes <= 1 && m_no_sparse_layers) ? m_first_layer_speed * 60.f : std::min(m_wipe_tower_max_purge_speed * 60.f, m_infill_speed * 60.f);
|
||||
const float target_speed = is_first_layer() || (m_num_tool_changes <= 1 && m_sparse_layers_skipped) ? m_first_layer_speed * 60.f : std::min(m_wipe_tower_max_purge_speed * 60.f, m_infill_speed * 60.f);
|
||||
float wipe_speed = 0.33f * target_speed;
|
||||
|
||||
// if there is less than 2.5*line_width to the edge, advance straightaway (there is likely a blob anyway)
|
||||
@@ -1970,7 +1970,7 @@ WipeTower::ToolChangeResult WipeTower2::finish_layer()
|
||||
|
||||
// Slow down on the 1st layer.
|
||||
// If spare layers are excluded -> if 1 or less toolchange has been done, it must be still the first layer, too. So slow down.
|
||||
bool first_layer = is_first_layer() || (m_num_tool_changes <= 1 && m_no_sparse_layers);
|
||||
bool first_layer = is_first_layer() || (m_num_tool_changes <= 1 && m_sparse_layers_skipped);
|
||||
float feedrate = first_layer ? m_first_layer_speed * 60.f : std::min(m_wipe_tower_max_purge_speed * 60.f, m_infill_speed * 60.f);
|
||||
if (m_enable_tower_interface_features && m_prev_layer_had_interface)
|
||||
feedrate = std::min(feedrate, 20.f * 60.f);
|
||||
@@ -2103,7 +2103,7 @@ WipeTower::ToolChangeResult WipeTower2::finish_layer()
|
||||
|
||||
// Ask our writer about how much material was consumed.
|
||||
// Skip this in case the layer is sparse and config option to not print sparse layers is enabled.
|
||||
if (! m_no_sparse_layers || toolchanges_on_layer || first_layer) {
|
||||
if (! m_sparse_layers_skipped || toolchanges_on_layer || first_layer) {
|
||||
if (m_current_tool < m_used_filament_length.size())
|
||||
m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length();
|
||||
m_current_height += m_layer_info->height;
|
||||
@@ -2226,7 +2226,7 @@ void WipeTower2::plan_toolchange(float z_par, float layer_height_par, unsigned i
|
||||
if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
|
||||
m_plan.push_back(WipeTowerInfo(z_par, layer_height_par));
|
||||
|
||||
if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool || m_plan.size() == 1))
|
||||
if (m_first_layer_idx == size_t(-1) && (! m_sparse_layers_skipped || old_tool != new_tool || m_plan.size() == 1))
|
||||
m_first_layer_idx = m_plan.size() - 1;
|
||||
|
||||
if (old_tool == new_tool) // new layer without toolchanges - we are done
|
||||
@@ -2652,7 +2652,7 @@ Polygon WipeTower2::generate_support_cone_wall(
|
||||
const auto [R, support_scale] = get_wipe_tower_cone_base(m_wipe_tower_width, m_wipe_tower_height, m_wipe_tower_depth,
|
||||
m_wipe_tower_cone_angle);
|
||||
|
||||
double z = m_no_sparse_layers ?
|
||||
double z = m_sparse_layers_skipped ?
|
||||
(m_current_height + m_layer_info->height) :
|
||||
m_layer_info->z; // the former should actually work in both cases, but let's stay on the safe side (the 2.6.0 is close)
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ private:
|
||||
float m_parking_pos_retraction = 0.f;
|
||||
float m_extra_loading_move = 0.f;
|
||||
float m_bridging = 0.f;
|
||||
bool m_no_sparse_layers = false;
|
||||
bool m_sparse_layers_skipped = false;
|
||||
bool m_set_extruder_trimpot = false;
|
||||
bool m_adhesion = true;
|
||||
GCodeFlavor m_gcode_flavor;
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
#include "LayOnFace.hpp"
|
||||
|
||||
#include "Geometry.hpp"
|
||||
#include "Geometry/ConvexHull.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "TriangleMesh.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
std::vector<LayOnFacePlane> lay_on_face_planes(const ModelObject &object, const Transform3d &inst_matrix)
|
||||
{
|
||||
// An object can only rest on its convex hull, so candidate faces are taken from the hull of all model parts.
|
||||
TriangleMesh ch;
|
||||
for (const ModelVolume* vol : object.volumes) {
|
||||
if (vol->type() != ModelVolumeType::MODEL_PART)
|
||||
continue;
|
||||
TriangleMesh vol_ch = vol->get_convex_hull();
|
||||
vol_ch.transform(vol->get_matrix());
|
||||
ch.merge(vol_ch);
|
||||
}
|
||||
ch = ch.convex_hull_3d();
|
||||
std::vector<LayOnFacePlane> planes;
|
||||
|
||||
// Following constants are used for discarding too small polygons.
|
||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||
const float minimal_side = 1.f; // mm
|
||||
const float minimal_angle = 1.f; // degree, initial value was 10, but cause bugs
|
||||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
const int num_of_facets = ch.facets_count();
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
|
||||
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(ch.its);
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
std::vector<bool> facet_visited(num_of_facets, false);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
int facet_idx = 0;
|
||||
while (1) {
|
||||
// Find next unvisited triangle:
|
||||
for (; facet_idx < num_of_facets; ++ facet_idx)
|
||||
if (!facet_visited[facet_idx]) {
|
||||
facet_queue[facet_queue_cnt ++] = facet_idx;
|
||||
facet_visited[facet_idx] = true;
|
||||
normal_ptr = &face_normals[facet_idx];
|
||||
planes.emplace_back();
|
||||
break;
|
||||
}
|
||||
if (facet_idx == num_of_facets)
|
||||
break; // Everything was visited already
|
||||
|
||||
while (facet_queue_cnt > 0) {
|
||||
int facet_idx = facet_queue[-- facet_queue_cnt];
|
||||
const stl_normal& this_normal = face_normals[facet_idx];
|
||||
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
|
||||
const Vec3i32 face = ch.its.indices[facet_idx];
|
||||
for (int j=0; j<3; ++j)
|
||||
planes.back().outline.emplace_back(ch.its.vertices[face[j]].cast<double>());
|
||||
|
||||
facet_visited[facet_idx] = true;
|
||||
for (int j = 0; j < 3; ++ j)
|
||||
if (int neighbor_idx = face_neighbors[facet_idx][j]; neighbor_idx >= 0 && ! facet_visited[neighbor_idx])
|
||||
facet_queue[facet_queue_cnt ++] = neighbor_idx;
|
||||
}
|
||||
}
|
||||
planes.back().normal = normal_ptr->cast<double>();
|
||||
|
||||
Pointf3s& verts = planes.back().outline;
|
||||
// Now we'll transform all the points into world coordinates, so that the areas, angles and distances
|
||||
// make real sense.
|
||||
verts = transform(verts, inst_matrix);
|
||||
|
||||
// if this is a just a very small triangle, remove it to speed up further calculations (it would be rejected later anyway):
|
||||
if (verts.size() == 3 &&
|
||||
((verts[0] - verts[1]).norm() < minimal_side
|
||||
|| (verts[0] - verts[2]).norm() < minimal_side
|
||||
|| (verts[1] - verts[2]).norm() < minimal_side))
|
||||
planes.pop_back();
|
||||
}
|
||||
|
||||
// Let's prepare transformation of the normal vector from mesh to instance coordinates.
|
||||
const Matrix3d normal_matrix = inst_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
|
||||
// Now we'll go through all the polygons, transform the points into xy plane to process them:
|
||||
for (unsigned int polygon_id=0; polygon_id < planes.size(); ++polygon_id) {
|
||||
Pointf3s& polygon = planes[polygon_id].outline;
|
||||
const Vec3d& normal = planes[polygon_id].normal;
|
||||
|
||||
// transform the normal according to the instance matrix:
|
||||
const Vec3d normal_transformed = normal_matrix * normal;
|
||||
|
||||
// We are going to rotate about z and y to flatten the plane
|
||||
Eigen::Quaterniond q;
|
||||
Transform3d& m = planes[polygon_id].to_plane_frame;
|
||||
m = Transform3d::Identity();
|
||||
m.matrix().block(0, 0, 3, 3) = q.setFromTwoVectors(normal_transformed, Vec3d::UnitZ()).toRotationMatrix();
|
||||
polygon = transform(polygon, m);
|
||||
|
||||
// Now to remove the inner points. We'll misuse Geometry::convex_hull for that, but since
|
||||
// it works in fixed point representation, we will rescale the polygon to avoid overflows.
|
||||
// And yes, it is a nasty thing to do. Whoever has time is free to refactor.
|
||||
Vec3d bb_size = BoundingBoxf3(polygon).size();
|
||||
float sf = std::min(1./bb_size(0), 1./bb_size(1));
|
||||
Transform3d tr = Geometry::scale_transform({ sf, sf, 1.f });
|
||||
polygon = transform(polygon, tr);
|
||||
polygon = Slic3r::Geometry::convex_hull(polygon);
|
||||
polygon = transform(polygon, tr.inverse());
|
||||
|
||||
// Calculate area of the polygons and discard ones that are too small
|
||||
float& area = planes[polygon_id].area;
|
||||
area = 0.f;
|
||||
for (unsigned int i = 0; i < polygon.size(); i++) // Shoelace formula
|
||||
area += polygon[i](0)*polygon[i + 1 < polygon.size() ? i + 1 : 0](1) - polygon[i + 1 < polygon.size() ? i + 1 : 0](0)*polygon[i](1);
|
||||
area = 0.5f * std::abs(area);
|
||||
|
||||
bool discard = false;
|
||||
if (area < minimal_area)
|
||||
discard = true;
|
||||
else {
|
||||
// We also check the inner angles and discard polygons with angles smaller than the following threshold
|
||||
const double angle_threshold = ::cos(minimal_angle * (double)PI / 180.0);
|
||||
|
||||
for (unsigned int i = 0; i < polygon.size(); ++i) {
|
||||
const Vec3d& prec = polygon[(i == 0) ? polygon.size() - 1 : i - 1];
|
||||
const Vec3d& curr = polygon[i];
|
||||
const Vec3d& next = polygon[(i == polygon.size() - 1) ? 0 : i + 1];
|
||||
|
||||
if ((prec - curr).normalized().dot((next - curr).normalized()) > angle_threshold) {
|
||||
discard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (discard) {
|
||||
planes[polygon_id--] = std::move(planes.back());
|
||||
planes.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
const Vec3d centroid = std::accumulate(polygon.begin(), polygon.end(), Vec3d(0.0, 0.0, 0.0)) / double(polygon.size());
|
||||
planes[polygon_id].center = inst_matrix.inverse() * (m.inverse() * centroid);
|
||||
}
|
||||
|
||||
std::sort(planes.rbegin(), planes.rend(), [](const LayOnFacePlane& a, const LayOnFacePlane& b) { return a.area < b.area; });
|
||||
return planes;
|
||||
}
|
||||
|
||||
int find_largest_plane(const std::vector<LayOnFacePlane> &planes)
|
||||
{
|
||||
// The plane frame maps the instance normal to +Z, so the normal's z in instance coordinates is element (2, 2).
|
||||
auto downward = [](const LayOnFacePlane &plane) { return -plane.to_plane_frame.linear()(2, 2); };
|
||||
// Areas are floats from rounded geometry, so faces within 0.1% count as equal.
|
||||
int best = -1;
|
||||
for (size_t i = 0; i < planes.size() && planes[i].area >= planes.front().area * (1. - 1e-3); ++i)
|
||||
if (best < 0 || downward(planes[i]) > downward(planes[best]))
|
||||
best = int(i);
|
||||
return best;
|
||||
}
|
||||
|
||||
int find_plane_by_normal(const std::vector<LayOnFacePlane> &planes, const Vec3d &direction)
|
||||
{
|
||||
const Vec3d dir = direction.normalized();
|
||||
int best = -1;
|
||||
double best_dot = -2.;
|
||||
for (size_t i = 0; i < planes.size(); ++i)
|
||||
if (const double dot = planes[i].normal.dot(dir); dot > best_dot) {
|
||||
best_dot = dot;
|
||||
best = int(i);
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
int find_plane_at_point(const std::vector<LayOnFacePlane> &planes, const Transform3d &instance_matrix_no_offset,
|
||||
const Vec3d &point, double tolerance)
|
||||
{
|
||||
const Vec3d instance_point = instance_matrix_no_offset * point;
|
||||
for (size_t i = 0; i < planes.size(); ++i) {
|
||||
const Pointf3s &outline = planes[i].outline;
|
||||
if (outline.empty())
|
||||
continue;
|
||||
const Vec3d p = planes[i].to_plane_frame * instance_point;
|
||||
// Facets with slightly different normals are merged into one face, so the outline is not exactly flat.
|
||||
const double z = std::accumulate(outline.begin(), outline.end(), 0., [](double sum, const Vec3d &v) { return sum + v.z(); }) / double(outline.size());
|
||||
if (std::abs(p.z() - z) > tolerance)
|
||||
continue;
|
||||
// The outline is convex: the point is inside when it is not on both sides of its edges.
|
||||
bool left = false, right = false;
|
||||
for (size_t j = 0; j < outline.size(); ++j) {
|
||||
const Vec2d a = outline[j].head<2>();
|
||||
const Vec2d edge = outline[(j + 1) % outline.size()].head<2>() - a;
|
||||
const double len = edge.norm();
|
||||
if (len < EPSILON)
|
||||
continue;
|
||||
const double side = cross2(edge, Vec2d(p.head<2>() - a)) / len;
|
||||
left |= side > tolerance;
|
||||
right |= side < -tolerance;
|
||||
}
|
||||
if (!(left && right))
|
||||
return int(i);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void lay_on_face(ModelObject &object, size_t instance_idx, const Vec3d &normal)
|
||||
{
|
||||
ModelInstance &instance = *object.instances[instance_idx];
|
||||
const Geometry::Transformation &trafo = instance.get_transformation();
|
||||
// Same rotation as Selection::flattening_rotate(): turn the transformed normal to point down.
|
||||
const Vec3d tnormal = trafo.get_matrix().matrix().block(0, 0, 3, 3).inverse().transpose() * normal;
|
||||
const Transform3d rotation = Transform3d(Eigen::Quaterniond().setFromTwoVectors(tnormal, -Vec3d::UnitZ()));
|
||||
instance.set_transformation(Geometry::Transformation(trafo.get_offset_matrix() * rotation * trafo.get_matrix_no_offset()));
|
||||
// Drop this instance only: ensure_on_bed() skips instances without auto_drop and measures the first instance.
|
||||
object.translate_instance(instance_idx, -object.instance_bounding_box(instance_idx).min.z() * Vec3d::UnitZ());
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "Point.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ModelObject;
|
||||
|
||||
// A face of an object's convex hull that the object can rest on. These are the faces the
|
||||
// "Lay on Face" gizmo offers and the ones the CLI --ground-* options choose from.
|
||||
//
|
||||
// Frames: "object" coordinates have the volume transformations applied but not the instance
|
||||
// transformation. "Instance" coordinates additionally have the instance rotation, scale and
|
||||
// mirror applied, but not its offset.
|
||||
struct LayOnFacePlane
|
||||
{
|
||||
Vec3d normal; // outward unit normal, object coordinates
|
||||
Vec3d center; // centroid of the outline, object coordinates; on the face's mean plane
|
||||
float area; // mm², instance coordinates
|
||||
Pointf3s outline; // convex outline in the plane frame, where the face is horizontal
|
||||
Transform3d to_plane_frame; // rotation from instance coordinates to the plane frame
|
||||
};
|
||||
|
||||
// Candidate faces of the object's model parts, largest first. The instance transformation
|
||||
// (without offset) is applied before measuring, so faces too small to rest on are dropped
|
||||
// by their printed size: under 5 mm², a side under 1 mm, or an inner angle under 1°.
|
||||
std::vector<LayOnFacePlane> lay_on_face_planes(const ModelObject &object, const Transform3d &instance_matrix_no_offset);
|
||||
|
||||
// Index of the largest plane, or -1 if `planes` is empty. Of planes with the same area, such as
|
||||
// the top and bottom of a box, the one already facing down the most wins, so flat parts stay put.
|
||||
int find_largest_plane(const std::vector<LayOnFacePlane> &planes);
|
||||
|
||||
// Index of the plane whose normal is closest to `direction` (object coordinates),
|
||||
// or -1 if `planes` is empty.
|
||||
int find_plane_by_normal(const std::vector<LayOnFacePlane> &planes, const Vec3d &direction);
|
||||
|
||||
// Index of the plane whose face contains `point` (object coordinates) within `tolerance` mm, or -1
|
||||
// if there is none. `instance_matrix_no_offset` is the one the planes were computed with.
|
||||
int find_plane_at_point(const std::vector<LayOnFacePlane> &planes, const Transform3d &instance_matrix_no_offset,
|
||||
const Vec3d &point, double tolerance);
|
||||
|
||||
// Rotates the instance so that `normal` (object coordinates) points down, the same rotation as
|
||||
// the gizmo applies, then drops the instance so its lowest point is at z = 0.
|
||||
void lay_on_face(ModelObject &object, size_t instance_idx, const Vec3d &normal);
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -153,6 +153,7 @@ bool Layer::is_perimeter_compatible(const Print& print, const PrintRegion& a, co
|
||||
&& config.gap_infill_speed.get_at(print.get_extruder_id(config.outer_wall_filament_id)) == other_config.gap_infill_speed.get_at(print.get_extruder_id(config.outer_wall_filament_id))
|
||||
&& config.filter_out_gap_fill.value == other_config.filter_out_gap_fill.value
|
||||
&& config.detect_overhang_wall == other_config.detect_overhang_wall
|
||||
&& config.unsupported_wall_last == other_config.unsupported_wall_last
|
||||
&& config.overhang_reverse == other_config.overhang_reverse
|
||||
&& config.overhang_reverse_threshold == other_config.overhang_reverse_threshold
|
||||
&& config.wall_direction == other_config.wall_direction
|
||||
|
||||
@@ -550,6 +550,7 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
|
||||
if (!paths.empty()) {
|
||||
if (extrusion->is_closed) {
|
||||
ExtrusionLoop extrusion_loop(std::move(paths), pg_extrusion.is_contour ? elrDefault : elrHole);
|
||||
extrusion_loop.inset_idx = extrusion->inset_idx;
|
||||
if ((perimeter_generator.config->wall_direction == WallDirection::CounterClockwise) ==
|
||||
(pg_extrusion.is_contour || pg_extrusions.size() == 2))
|
||||
extrusion_loop.make_counter_clockwise();
|
||||
@@ -1318,6 +1319,73 @@ static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_
|
||||
}
|
||||
}
|
||||
|
||||
// A loop made of nothing but overhang paths lies entirely off the lower layer.
|
||||
static bool is_unsupported_loop(const ExtrusionEntity *entity)
|
||||
{
|
||||
if (!entity->is_loop())
|
||||
return false;
|
||||
const ExtrusionPaths &paths = static_cast<const ExtrusionLoop *>(entity)->paths;
|
||||
return !paths.empty() && std::all_of(paths.begin(), paths.end(),
|
||||
[](const ExtrusionPath &path) { return path.role() == erOverhangPerimeter; });
|
||||
}
|
||||
|
||||
// ORCA: A wall loop with nothing under it has nothing to lean on, so whatever the configured wall
|
||||
// sequence it is extruded after the loops that anchor it, innermost first. A loop that runs alongside
|
||||
// an anchored one belongs to the same wall stack and keeps its place ahead of the infill, which needs
|
||||
// it as an anchor; one that touches nothing has only that infill to rest on, so it is flagged for the
|
||||
// G-code writer to hold it back until the infill is down.
|
||||
static void defer_unsupported_loops(const PerimeterGenerator &perimeter_generator, ExtrusionEntityCollection &entities)
|
||||
{
|
||||
if (!perimeter_generator.config->unsupported_wall_last)
|
||||
return;
|
||||
|
||||
ExtrusionEntitiesPtr &src = entities.entities;
|
||||
auto first_deferred = std::stable_partition(src.begin(), src.end(),
|
||||
[](const ExtrusionEntity *entity) { return !is_unsupported_loop(entity); });
|
||||
if (first_deferred == src.end())
|
||||
return;
|
||||
|
||||
std::stable_sort(first_deferred, src.end(),
|
||||
[](const ExtrusionEntity *lhs, const ExtrusionEntity *rhs) { return lhs->inset_idx > rhs->inset_idx; });
|
||||
|
||||
auto collect_lines = [](const ExtrusionEntity *entity, Lines &out) {
|
||||
Polylines polylines;
|
||||
entity->collect_polylines(polylines);
|
||||
append(out, to_lines(polylines));
|
||||
};
|
||||
|
||||
Lines anchored;
|
||||
for (auto it = src.begin(); it != first_deferred; ++it)
|
||||
collect_lines(*it, anchored);
|
||||
|
||||
std::vector<ExtrusionLoop *> unattached;
|
||||
for (auto it = first_deferred; it != src.end(); ++it)
|
||||
unattached.emplace_back(static_cast<ExtrusionLoop *>(*it));
|
||||
|
||||
// A loop leaning on a loop that is itself anchored is anchored as well, so spread outwards from
|
||||
// the anchored loops until no unsupported loop is left touching what was reached.
|
||||
const double touch_distance = 1.5 * std::max(perimeter_generator.ext_perimeter_flow.scaled_spacing(),
|
||||
perimeter_generator.perimeter_flow.scaled_spacing());
|
||||
while (!anchored.empty()) {
|
||||
AABBTreeLines::LinesDistancer<Line> distancer{std::move(anchored)};
|
||||
anchored.clear();
|
||||
for (ExtrusionLoop *&loop : unattached) {
|
||||
if (loop == nullptr)
|
||||
continue;
|
||||
const Points points = loop->as_polyline().points;
|
||||
if (std::any_of(points.begin(), points.end(),
|
||||
[&distancer, touch_distance](const Point &point) { return distancer.distance_from_lines<false>(point) < touch_distance; })) {
|
||||
collect_lines(loop, anchored);
|
||||
loop = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ExtrusionLoop *loop : unattached)
|
||||
if (loop != nullptr)
|
||||
loop->print_after_infill = true;
|
||||
}
|
||||
|
||||
void PerimeterGenerator::process_classic()
|
||||
{
|
||||
group_region_by_fuzzify(*this);
|
||||
@@ -1804,6 +1872,8 @@ void PerimeterGenerator::process_classic()
|
||||
}
|
||||
}
|
||||
|
||||
defer_unsupported_loops(*this, entities);
|
||||
|
||||
// append perimeters for this slice as a collection
|
||||
if (! entities.empty())
|
||||
this->loops->append(entities);
|
||||
@@ -2742,6 +2812,7 @@ void PerimeterGenerator::process_arachne()
|
||||
reorient_perimeters(extrusion_coll, steep_overhang_contour, steep_overhang_hole,
|
||||
this->config->overhang_reverse_internal_only);
|
||||
}
|
||||
defer_unsupported_loops(*this, extrusion_coll);
|
||||
this->loops->append(extrusion_coll);
|
||||
}
|
||||
|
||||
|
||||
@@ -545,7 +545,7 @@ std::string generate_preset_setting_id(const std::string& vendor, const std::str
|
||||
return "";
|
||||
|
||||
// Dedicated namespace for preset setting_ids, distinct from the cloud per-user
|
||||
// namespace (OrcaCloudServiceAgent). Keep in sync with scripts/orca_id_tool.py;
|
||||
// namespace (OrcaCloudServiceAgent). Keep in sync with scripts/orca_profile_tool.py;
|
||||
// never change this constant.
|
||||
static const boost::uuids::uuid vendor_namespace =
|
||||
boost::uuids::string_generator()("c1f4d9e2-7a3b-5c8d-9e0f-1a2b3c4d5e6f");
|
||||
@@ -1058,6 +1058,7 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"reduce_crossing_wall",
|
||||
"detect_thin_wall",
|
||||
"detect_overhang_wall",
|
||||
"unsupported_wall_last",
|
||||
"overhang_reverse",
|
||||
"overhang_reverse_threshold",
|
||||
"overhang_reverse_internal_only",
|
||||
@@ -1282,6 +1283,8 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"accel_to_decel_enable",
|
||||
"accel_to_decel_factor",
|
||||
"wipe_on_loops",
|
||||
"wipe_inward",
|
||||
"wipe_inward_distance",
|
||||
"wipe_before_external_loop",
|
||||
"bridge_density",
|
||||
"internal_bridge_density",
|
||||
@@ -1318,6 +1321,8 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"wipe_tower_extra_flow",
|
||||
"single_extruder_multi_material_priming",
|
||||
"toolchange_ordering",
|
||||
"toolchange_cyclic_order",
|
||||
"toolchange_cyclic_first_layer",
|
||||
"wipe_tower_rotation_angle",
|
||||
"tree_support_branch_distance_organic",
|
||||
"tree_support_branch_diameter_organic",
|
||||
@@ -1443,7 +1448,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
||||
"gcode_skip_config_block", "fan_kickstart", "part_cooling_fan_min_pwm", "fan_speedup_time", "fan_speedup_overhangs",
|
||||
"single_extruder_multi_material", "manual_filament_change", "file_start_gcode", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "printing_by_object_gcode", "layer_change_gcode", "time_lapse_gcode", "wrapping_detection_gcode", "change_filament_gcode", "change_extrusion_role_gcode",
|
||||
"printer_model", "printer_variant", "printer_extruder_id", "printer_extruder_variant", "extruder_variant_list", "default_nozzle_volume_type",
|
||||
"printable_height", "extruder_printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod",
|
||||
"printable_height", "extruder_printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", "extruder_clearance_dist_to_rod",
|
||||
"nozzle_height", "master_extruder_id",
|
||||
"default_print_profile", "inherits",
|
||||
"silent_mode",
|
||||
|
||||
@@ -93,8 +93,8 @@ class PresetBundle;
|
||||
|
||||
// Deterministic preset setting_id: uuid5(vendor/type/name) -> 16 base62 chars.
|
||||
// Pure function of a system preset's identity, so the value can be assigned by
|
||||
// scripts/orca_id_tool.py and recomputed here when a profile ships without it.
|
||||
// MUST stay byte-identical to scripts/orca_id_tool.py.
|
||||
// scripts/orca_profile_tool.py and recomputed here when a profile ships without it.
|
||||
// MUST stay byte-identical to scripts/orca_profile_tool.py.
|
||||
// This is NOT the per-user cloud-sync setting_id
|
||||
// (OrcaCloudServiceAgent::generate_uuid_for_setting_id) - do not conflate them.
|
||||
std::string generate_preset_setting_id(const std::string& vendor,
|
||||
|
||||
@@ -6783,7 +6783,7 @@ std::string PresetBundle::load_vendor_preset(
|
||||
loaded.description = entry.description;
|
||||
loaded.setting_id = entry.setting_id;
|
||||
// Derive the preset setting_id on the fly when a profile ships without one,
|
||||
// matching scripts/orca_id_tool.py. Only instantiated presets carry an id;
|
||||
// matching scripts/orca_profile_tool.py. Only instantiated presets carry an id;
|
||||
// non-instantiated base profiles return earlier above. This never
|
||||
// touches the per-user cloud-sync setting_id written into user .info files.
|
||||
if (loaded.setting_id.empty() && entry.instantiation == "true")
|
||||
@@ -7619,6 +7619,9 @@ bool PresetBundle::has_errors(bool check_duplicate_filament_subtypes) const
|
||||
if (this->check_preset_references())
|
||||
has_errors = true;
|
||||
|
||||
if (this->check_printer_default_materials())
|
||||
has_errors = true;
|
||||
|
||||
return has_errors;
|
||||
}
|
||||
|
||||
@@ -7711,6 +7714,70 @@ bool PresetBundle::check_preset_references() const
|
||||
return found;
|
||||
}
|
||||
|
||||
bool PresetBundle::check_printer_default_materials() const
|
||||
{
|
||||
bool found = false;
|
||||
// A model's default_materials list is shared by its variants, so report each unknown name once.
|
||||
std::set<const VendorProfile::PrinterModel *> checked_models;
|
||||
// default_filament_profile is inherited from shared base machine presets, so one bad name can
|
||||
// surface on many variants; report it once, at the first printer that names it.
|
||||
std::set<std::string> reported_unknown_profiles;
|
||||
for (const Preset &printer : printers) {
|
||||
if (!printer.is_system || printer.vendor == nullptr || printer.printer_technology() != ptFFF)
|
||||
continue;
|
||||
|
||||
const VendorProfile::PrinterModel *model = PresetUtils::system_printer_model(printer);
|
||||
const PresetWithVendorProfile active_printer = printers.get_preset_with_vendor_profile(printer);
|
||||
// Use the same name lookup as load_installed_filaments, not UI aliases or fuzzy matching.
|
||||
// A model's defaults can cover different nozzles, but at least one must cover this variant.
|
||||
const bool has_default = model != nullptr && std::any_of(model->default_materials.begin(), model->default_materials.end(),
|
||||
[&](const std::string &name) {
|
||||
const Preset *filament = filaments.find_preset(name, false);
|
||||
return filament != nullptr && filament->is_system &&
|
||||
is_compatible_with_printer(filaments.get_preset_with_vendor_profile(*filament), active_printer);
|
||||
});
|
||||
if (!has_default) {
|
||||
found = true;
|
||||
BOOST_LOG_TRIVIAL(error) << "Printer preset \"" << printer.name << "\" (vendor \"" << printer.vendor->name
|
||||
<< "\", model \"" << printer.config.opt_string("printer_model") << "\", variant \""
|
||||
<< printer.config.opt_string("printer_variant")
|
||||
<< "\") has no compatible system filament in its model's \"default_materials\". "
|
||||
"Add at least one full filament preset name compatible with this printer variant:\n"
|
||||
<< preset_file_uri(printer.file);
|
||||
}
|
||||
|
||||
if (model != nullptr && checked_models.insert(model).second) {
|
||||
for (const std::string &name : model->default_materials) {
|
||||
const Preset *filament = filaments.find_preset(name, false);
|
||||
if (filament == nullptr || !filament->is_system) {
|
||||
found = true;
|
||||
BOOST_LOG_TRIVIAL(error) << "Printer model \"" << model->name << "\" (vendor \"" << printer.vendor->name
|
||||
<< "\") names the unknown system filament \"" << name
|
||||
<< "\" in its \"default_materials\":\n" << preset_file_uri(printer.file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (printer.config.has("default_filament_profile")) {
|
||||
for (const std::string &name : printer.config.opt<ConfigOptionStrings>("default_filament_profile")->values) {
|
||||
// A ";"-separated list can leave an empty trailing segment; formatting noise, not a name.
|
||||
if (name.empty())
|
||||
continue;
|
||||
const Preset *filament = filaments.find_preset(name, false);
|
||||
if ((filament == nullptr || !filament->is_system) && reported_unknown_profiles.insert(name).second) {
|
||||
found = true;
|
||||
BOOST_LOG_TRIVIAL(error) << "Printer preset \"" << printer.name << "\" (vendor \"" << printer.vendor->name
|
||||
<< "\", model \"" << printer.config.opt_string("printer_model") << "\", variant \""
|
||||
<< printer.config.opt_string("printer_variant")
|
||||
<< "\") names the unknown system filament \"" << name
|
||||
<< "\" in its \"default_filament_profile\":\n" << preset_file_uri(printer.file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// Orca: a filament is matched from the AMS by (filament_id + printer compatibility).
|
||||
// For any one printer, at most one instantiated filament preset with a given
|
||||
// filament_id may be compatible - otherwise the AMS match is ambiguous and the
|
||||
|
||||
@@ -617,6 +617,11 @@ public:
|
||||
// compatible_prints references a deleted (unknown) or renamed (old) preset name.
|
||||
bool check_preset_references() const;
|
||||
|
||||
// Validator-only: every system FFF printer variant needs a compatible system filament
|
||||
// named in its model's default_materials, every name there and in the printer's
|
||||
// default_filament_profile must resolve to a system filament.
|
||||
bool check_printer_default_materials() const;
|
||||
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
// Public so per-vendor-cache consumers (e.g. the setup wizard) can assemble a
|
||||
// bundle out of several per-vendor caches loaded into separate PresetBundle instances.
|
||||
|
||||
@@ -233,6 +233,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||
"accel_to_decel_enable",
|
||||
"accel_to_decel_factor",
|
||||
"wipe_on_loops",
|
||||
"wipe_inward",
|
||||
"wipe_inward_distance",
|
||||
"gcode_comments",
|
||||
"gcode_label_objects",
|
||||
"exclude_object",
|
||||
@@ -358,6 +360,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||
|| opt_key == "other_layers_print_sequence"
|
||||
|| opt_key == "other_layers_print_sequence_nums"
|
||||
|| opt_key == "toolchange_ordering"
|
||||
|| opt_key == "toolchange_cyclic_order"
|
||||
|| opt_key == "toolchange_cyclic_first_layer"
|
||||
|| opt_key == "extruder_ams_count"
|
||||
|| opt_key == "extruder_nozzle_stats"
|
||||
|| opt_key == "filament_map_mode"
|
||||
@@ -962,6 +966,377 @@ StringObjectException Print::sequential_print_clearance_valid(const Print &print
|
||||
return single_object_exception;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Clearance rule for a prime tower compacted by wipe_tower_no_sparse_layers.
|
||||
// Ported from BambuStudio and adapted to Orca's printer config: Orca has no
|
||||
// prime_tower_lift_height (z_hop alone bounds the spiral), spells the toolhead radius
|
||||
// extruder_clearance_radius, and derives the spiral slope from the per-filament travel_slope instead
|
||||
// of one global constant.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
double compacted_tower_footprint_padding(const PrintConfig &config, double brim_width)
|
||||
{
|
||||
// The brim is deposited material like any other and reaches past the wall on the first layer, so
|
||||
// the sweeping rod has to clear it too.
|
||||
//
|
||||
// On top of it, two effects make a nominal outline fall short of the printed tower on its low
|
||||
// corner even though it overshoots by millimetres on the high one: WipeTower re-centres the tower
|
||||
// by rib_offset once its first-layer wall is known, and the precise check hulls extrusion centre
|
||||
// lines, so the deposited material reaches half a line width further still. Allowing a line width
|
||||
// per side covers both, which is what keeps an estimated footprint enclosing the real one and the
|
||||
// pre-slice check stricter than the precise one.
|
||||
return std::max(0., brim_width) + 2. * config.nozzle_diameter.get_at(0);
|
||||
}
|
||||
|
||||
Polygons compacted_wipe_tower_rings(const CompactedTowerZone &zone, bool any_body_tier)
|
||||
{
|
||||
Polygons rings = zone.grown_nozzle;
|
||||
if (any_body_tier)
|
||||
append(rings, zone.grown_body);
|
||||
return rings;
|
||||
}
|
||||
|
||||
CompactedTowerZone compacted_wipe_tower_zone(const PrintConfig &config, const Polygon &tower_footprint)
|
||||
{
|
||||
CompactedTowerZone zone;
|
||||
if (tower_footprint.points.empty())
|
||||
return zone;
|
||||
|
||||
// Spiral Z-hop at wipe-tower entry (the G3 Z I J that GCodeWriter emits for a SpiralLift) starts on
|
||||
// the tower outline at a low Z. The spiral centre sits one radius away from the start point, so the
|
||||
// circle reaches 2 * radius beyond the outline. radius = lift / (2*pi*atan(travel_slope)) is the
|
||||
// same formula GCodeWriter uses; both are per filament, so take the widest any filament can make.
|
||||
double spiral_reach = 0.;
|
||||
for (size_t i = 0; i < config.z_hop.size(); ++i) {
|
||||
const double lift = std::min(double(config.z_hop.get_at(i)), 5.);
|
||||
if (lift < EPSILON)
|
||||
continue;
|
||||
const double slope = i < config.travel_slope.size() ? double(config.travel_slope.get_at(i)) : 0.;
|
||||
if (slope < EPSILON)
|
||||
continue;
|
||||
spiral_reach = std::max(spiral_reach, 2. * lift / (2. * PI * std::atan(slope)));
|
||||
}
|
||||
|
||||
// Working footprint = outline grown by the spiral envelope. All later clearance tests use this, so
|
||||
// a travel that leaves the deposited wall at low Z is still treated as part of the tower.
|
||||
zone.hull = tower_footprint;
|
||||
if (spiral_reach > EPSILON) {
|
||||
const Polygons grown = offset(tower_footprint, float(scale_(spiral_reach)), jtRound, scale_(0.1));
|
||||
if (! grown.empty())
|
||||
zone.hull = Geometry::convex_hull(grown);
|
||||
}
|
||||
|
||||
// The rod sweeps the whole X axis, so its keep-out band is the tower's Y span widened by half
|
||||
// the nozzle-to-rod offset per side (the instance carries the other half). Orca's sequential
|
||||
// check has no such margin, having had no option to read it from until now.
|
||||
zone.bbox_rod = zone.hull.bounding_box();
|
||||
zone.bbox_rod.offset(scale_(config.extruder_clearance_dist_to_rod.value * 0.5));
|
||||
|
||||
// Horizontal clearance, mirroring the sequential print check down to how the distance is split:
|
||||
// there each of the two object hulls grows by half of extruder_clearance_radius, so the two
|
||||
// outlines touch exactly when the objects are the full radius apart. Splitting it the same way
|
||||
// here (half on the tower, half on the instance in compacted_wipe_tower_clearance) states the
|
||||
// same criterion, and it is what lets the plater draw both outlines: they meet at the instant the
|
||||
// check trips, instead of one of them being already buried inside the other. The smaller
|
||||
// MAX_OUTER_NOZZLE_DIAMETER tier is the bare nozzle cone, the only part narrow enough to sit
|
||||
// beside an object rising less than nozzle_height. The 0.2 mm shaved off is the same rounding
|
||||
// slack the sequential check applies, 0.1 mm per side. Both rings are built here; which one a
|
||||
// given object is measured against depends on its own height and is decided in
|
||||
// compacted_wipe_tower_clearance().
|
||||
zone.body_radius = config.extruder_clearance_radius.value;
|
||||
zone.grown_body = offset(zone.hull, float(scale_(compacted_tower_half_clearance(zone.body_radius))), jtRound, scale_(0.1));
|
||||
zone.grown_nozzle = offset(zone.hull, float(scale_(compacted_tower_half_clearance(MAX_OUTER_NOZZLE_DIAMETER))), jtRound, scale_(0.1));
|
||||
return zone;
|
||||
}
|
||||
|
||||
CompactedTowerClearance compacted_wipe_tower_clearance(const PrintConfig &config, const CompactedTowerZone &zone,
|
||||
const Polygon &inst_hull, double object_rise)
|
||||
{
|
||||
BoundingBox inst_bbox = inst_hull.bounding_box();
|
||||
inst_bbox.offset(scale_(config.extruder_clearance_dist_to_rod.value * 0.5));
|
||||
|
||||
// Only the Y span matters for the rod: it spans the whole X axis, so an object sharing the tower's
|
||||
// Y band passes under it however far apart the two are in X.
|
||||
const bool overlaps_in_y = std::min(inst_bbox.max.y(), zone.bbox_rod.max.y()) - std::max(inst_bbox.min.y(), zone.bbox_rod.min.y()) > 0;
|
||||
|
||||
CompactedTowerClearance result;
|
||||
result.far_clearance = overlaps_in_y ? config.extruder_clearance_height_to_rod.value : config.extruder_clearance_height_to_lid.value;
|
||||
|
||||
// The rod and the lid are the only obstacles once the object stands far enough away. Closer than
|
||||
// the toolhead radius it is the head body itself that hits the object, and it does so as soon as
|
||||
// the object rises past the nozzle cone, which is far below the rod.
|
||||
// The instance carries the other half of each clearance, the tower rings already hold the first
|
||||
// half; see compacted_wipe_tower_zone(). Both halves are needed for the verdict to mean
|
||||
// "a full radius apart", and drawing what is tested is what keeps the plater honest.
|
||||
//
|
||||
// Which tier applies is a property of this object alone: the head body sits above the nozzle cone,
|
||||
// so it cannot reach an object that stays below nozzle_height however close it stands, and however
|
||||
// tall the rest of the plate is.
|
||||
const bool object_is_short = object_rise <= double(config.nozzle_height.value) + EPSILON;
|
||||
result.body_clearance = object_is_short ? double(MAX_OUTER_NOZZLE_DIAMETER) : zone.body_radius;
|
||||
|
||||
const Polygons inst_near_nozzle = offset(inst_hull, float(scale_(compacted_tower_half_clearance(MAX_OUTER_NOZZLE_DIAMETER))), jtRound, scale_(0.1));
|
||||
const bool near_nozzle = ! intersection(zone.grown_nozzle, inst_near_nozzle).empty();
|
||||
result.near_body = false;
|
||||
if (! object_is_short) {
|
||||
const Polygons inst_near_body = offset(inst_hull, float(scale_(compacted_tower_half_clearance(zone.body_radius))), jtRound, scale_(0.1));
|
||||
result.near_body = ! intersection(zone.grown_body, inst_near_body).empty();
|
||||
}
|
||||
|
||||
result.allowed_rise = result.far_clearance;
|
||||
if (near_nozzle)
|
||||
result.allowed_rise = 0.;
|
||||
else if (result.near_body)
|
||||
result.allowed_rise = std::min(result.far_clearance, double(config.nozzle_height.value));
|
||||
return result;
|
||||
}
|
||||
|
||||
Polygon compacted_wipe_tower_offender_outline(const Polygon &inst_hull, double body_clearance)
|
||||
{
|
||||
// Exactly the half-clearance the check grew this instance by, so the halo drawn around an object is
|
||||
// the very outline that was tested against the tower ring of the same tier. Passing the clearance
|
||||
// the object was actually judged on keeps a short object from being drawn with the wide ring it is
|
||||
// not subject to.
|
||||
const Polygons grown = offset(inst_hull, float(scale_(compacted_tower_half_clearance(body_clearance))), jtRound, scale_(0.1));
|
||||
return grown.empty() ? inst_hull : grown.front();
|
||||
}
|
||||
|
||||
// Shared user-facing message for every compacted-tower clearance failure. Height-limit and too-close
|
||||
// are the same class of layout violation under "No sparse layers", so they share one wording.
|
||||
static std::string compacted_wipe_tower_clearance_error()
|
||||
{
|
||||
return L("The relative position of the model and the prime tower does not meet the requirements of the \"No sparse layers\" feature. Please adjust their relative positions, lower the model height, or turn off \"No sparse layers\".");
|
||||
}
|
||||
|
||||
// Convex hull of one print instance in bed coordinates, the same outline both compacted tower checks
|
||||
// compare against the tower.
|
||||
static Polygon compacted_tower_print_instance_hull(const PrintObject &object, const PrintInstance &instance)
|
||||
{
|
||||
Points pts;
|
||||
for (const ModelVolume *v : object.model_object()->volumes) {
|
||||
if (! v->is_model_part())
|
||||
continue;
|
||||
Polygon hull = v->get_convex_hull_2d(Geometry::assemble_transform(Vec3d::Zero(), instance.model_instance->get_rotation(),
|
||||
instance.model_instance->get_scaling_factor(), instance.model_instance->get_mirror()));
|
||||
hull.translate(instance.shift - object.center_offset());
|
||||
append(pts, hull.points);
|
||||
}
|
||||
return pts.empty() ? Polygon() : Geometry::convex_hull(pts);
|
||||
}
|
||||
|
||||
// Footprint the compacted prime tower is expected to occupy on the plate, in bed coordinates.
|
||||
// Before psWipeTower has run there is no tower geometry at all, so this falls back to the same
|
||||
// estimate the plater builds its preview box from. Answering while the user is still arranging the
|
||||
// plate is the whole point of the pre-slice check, and an estimate is all that can be had then.
|
||||
static Polygon estimated_wipe_tower_footprint(const Print &print)
|
||||
{
|
||||
const PrintConfig &config = print.config();
|
||||
const size_t filaments_cnt = print.extruders().size();
|
||||
if (filaments_cnt == 0)
|
||||
return Polygon();
|
||||
|
||||
const WipeTowerData &wtd = print.wipe_tower_data(filaments_cnt);
|
||||
|
||||
double width, depth, brim;
|
||||
Vec2d local_min;
|
||||
if (wtd.bbx.size().x() > EPSILON && wtd.bbx.size().y() > EPSILON) {
|
||||
// The tower has already been generated once, so use its real box (brim included) instead of
|
||||
// re-estimating. Same frame first_layer_wipe_tower_corners() works in.
|
||||
width = wtd.bbx.size().x();
|
||||
depth = wtd.bbx.size().y();
|
||||
local_min = wtd.bbx.min + wtd.rib_offset.cast<double>();
|
||||
brim = 0.;
|
||||
} else {
|
||||
depth = wtd.depth;
|
||||
if (depth < EPSILON)
|
||||
return Polygon();
|
||||
// PartPlate::estimate_wipe_tower_size() squares the rib tower off and the preview box the user
|
||||
// drags around is built from that, so match it here rather than keeping the nominal width.
|
||||
width = config.wipe_tower_wall_type.value == WipeTowerWallType::wtwRib ? depth : double(config.prime_tower_width.value);
|
||||
local_min = Vec2d::Zero();
|
||||
brim = double(wtd.brim_width);
|
||||
}
|
||||
|
||||
const double padding = compacted_tower_footprint_padding(config, brim);
|
||||
local_min -= Vec2d(padding, padding);
|
||||
width += 2. * padding;
|
||||
depth += 2. * padding;
|
||||
|
||||
const Eigen::Rotation2Dd rot(Geometry::deg2rad(config.wipe_tower_rotation_angle.value));
|
||||
const Vec2d translate(config.wipe_tower_x.get_at(print.get_plate_index()) + print.get_plate_origin()(0),
|
||||
config.wipe_tower_y.get_at(print.get_plate_index()) + print.get_plate_origin()(1));
|
||||
|
||||
Polygon footprint;
|
||||
for (const Vec2d &corner : { local_min,
|
||||
Vec2d(local_min.x() + width, local_min.y()),
|
||||
Vec2d(local_min.x() + width, local_min.y() + depth),
|
||||
Vec2d(local_min.x(), local_min.y() + depth) }) {
|
||||
const Vec2d p = rot * corner + translate;
|
||||
footprint.points.emplace_back(scale_(p.x()), scale_(p.y()));
|
||||
}
|
||||
return footprint;
|
||||
}
|
||||
|
||||
// Pre-slice counterpart of validate_compacted_wipe_tower_clearance(). It applies the very same
|
||||
// clearance rule, but to an estimated tower footprint instead of the real tool-change extrusions,
|
||||
// which is what lets it run from Print::validate() before anything has been sliced. Reporting through
|
||||
// polygons / height_polygons rather than by throwing is what puts the collision area and the height
|
||||
// limit plane on the plater, exactly the way sequential printing does it.
|
||||
StringObjectException Print::compacted_wipe_tower_clearance_valid(const Print &print, Polygons *polygons, std::vector<std::pair<Polygon, float>> *height_polygons)
|
||||
{
|
||||
const PrintConfig &config = print.config();
|
||||
if (! wipe_tower_sparse_layers_skipped(config) || config.print_sequence != PrintSequence::ByLayer || ! print.has_wipe_tower())
|
||||
return {};
|
||||
|
||||
const CompactedTowerZone zone = compacted_wipe_tower_zone(config, estimated_wipe_tower_footprint(print));
|
||||
if (zone.empty())
|
||||
return {};
|
||||
|
||||
StringObjectException exception;
|
||||
Polygons offenders;
|
||||
bool body_tier_used = false;
|
||||
for (const PrintObject *object : print.objects()) {
|
||||
const double object_top = unscaled<double>(object->max_z());
|
||||
for (const PrintInstance &instance : object->instances()) {
|
||||
const Polygon inst_hull = compacted_tower_print_instance_hull(*object, instance);
|
||||
if (inst_hull.points.empty())
|
||||
continue;
|
||||
const CompactedTowerClearance clearance = compacted_wipe_tower_clearance(config, zone, inst_hull, object_top);
|
||||
body_tier_used = body_tier_used || compacted_tower_body_tier(clearance);
|
||||
// Every tier the precise check applies is applied here too, otherwise an object standing
|
||||
// within the toolhead radius would pass here and then be rejected mid-slice, which is the
|
||||
// one outcome this check exists to prevent. The compacted tower base is unknown before
|
||||
// slicing, so the rise is measured from the plate rather than from the tower top; that
|
||||
// overstates it by the tower's own height and makes this check err strict, never lax.
|
||||
if (object_top <= clearance.allowed_rise + EPSILON)
|
||||
continue;
|
||||
|
||||
// Height-limit and too-close cases share one user-facing message: both mean the layout
|
||||
// violates the "No sparse layers" clearance rule, and the remedies are the same.
|
||||
const std::string msg = compacted_wipe_tower_clearance_error();
|
||||
if (exception.string.empty()) {
|
||||
exception.string = msg;
|
||||
exception.object = instance.model_instance;
|
||||
} else {
|
||||
// Same wording for every offender; keep a single copy and drop the object pointer.
|
||||
exception.object = nullptr;
|
||||
}
|
||||
const Polygon outline = compacted_wipe_tower_offender_outline(inst_hull, clearance.body_clearance);
|
||||
offenders.emplace_back(outline);
|
||||
if (height_polygons)
|
||||
height_polygons->emplace_back(outline, float(clearance.allowed_rise));
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the tower's keep-out ring alongside the offending objects, so the collision area reads as
|
||||
// "this object reaches into the space the toolhead needs around the tower" rather than as a lone
|
||||
// highlighted object. Emitted only on a real collision; the plater discards polygons otherwise.
|
||||
// Only the rings some object on this plate is actually measured against are drawn, so that a ring
|
||||
// and an object outline touching always means that object is over its limit.
|
||||
if (polygons && ! offenders.empty()) {
|
||||
append(*polygons, compacted_wipe_tower_rings(zone, body_tier_used));
|
||||
append(*polygons, offenders);
|
||||
}
|
||||
return exception;
|
||||
}
|
||||
|
||||
// With wipe_tower_no_sparse_layers the tower only grows on layers that carry a real toolchange,
|
||||
// so it ends up far below the object and the nozzle has to descend to it. While the nozzle sits
|
||||
// down on the compacted tower the rod is at tower_z + extruder_clearance_height_to_rod, and it
|
||||
// sweeps the tower's Y band across the whole X axis. Anything already printed above that line and
|
||||
// sharing the band gets hit. Nearer than the toolhead radius the head body hits the object well before
|
||||
// the rod does, which is the horizontal half of the same problem. The spiral Z-hop that opens a wipe-
|
||||
// tower travel also leaves the extrusion outline at a low Z, so the footprint used here is the
|
||||
// deposited hull grown by the spiral circle's maximum reach. This mirrors both clearance checks of
|
||||
// sequential printing, except that the tower is revisited over and over, so every object is compared
|
||||
// against it.
|
||||
void Print::validate_compacted_wipe_tower_clearance() const
|
||||
{
|
||||
// Nothing to check when the tower is not compacted: it then follows the object as usual and the
|
||||
// regular by-layer clearance check already covers it. Asking wipe_tower_sparse_layers_skipped()
|
||||
// rather than the raw option keeps this from rejecting plates whose tower is in fact full height.
|
||||
if (! wipe_tower_sparse_layers_skipped(m_config) || m_config.print_sequence != PrintSequence::ByLayer)
|
||||
return;
|
||||
|
||||
const std::vector<std::vector<WipeTower::ToolChangeResult>> &tool_changes = m_wipe_tower_data.tool_changes;
|
||||
if (tool_changes.empty() || m_objects.empty())
|
||||
return;
|
||||
|
||||
// Same accumulation the G-code emitter runs, so validation and output cannot disagree.
|
||||
const std::vector<float> tower_z = compute_compacted_wipe_tower_z(tool_changes, float(m_config.z_offset.value));
|
||||
|
||||
// Wipe tower footprint: build it from the ACTUAL tool-change extrusions rather than the nominal
|
||||
// width x depth rectangle returned by first_layer_wipe_tower_corners(). With a rib wall the printed
|
||||
// wall bulges past the nominal box and the first-layer brim reaches even further; the nominal box
|
||||
// (m_wipe_tower_data.bbx) undercounts that outermost extent by several millimetres, which is
|
||||
// exactly the extent that decides how close the sweeping rod comes to a neighbouring object. The
|
||||
// extrusion end-points are stored in the wipe-tower local frame, so we map them to the bed frame
|
||||
// with the same transform the G-code emitter applies. The two emitters differ in where rib_offset
|
||||
// enters: WipeTowerIntegration::append_tcr() (type 1) rotates the point and then adds the offset,
|
||||
// append_tcr2() (type 2) adds it before rotating. On a rotated rib-wall tower the two land several
|
||||
// millimetres apart, which is exactly the margin this check measures, so follow the emitter in use.
|
||||
const Eigen::Rotation2Dd wt_rot(Geometry::deg2rad(m_config.wipe_tower_rotation_angle.value));
|
||||
const Vec2d wt_translate(m_config.wipe_tower_x.get_at(m_plate_index) + m_origin(0),
|
||||
m_config.wipe_tower_y.get_at(m_plate_index) + m_origin(1));
|
||||
const Vec2d rib_off = m_wipe_tower_data.rib_offset.cast<double>();
|
||||
const bool rib_off_rotates = this->wipe_tower_type() == WipeTowerType::Type2;
|
||||
auto to_bed = [&wt_rot, &wt_translate, &rib_off, rib_off_rotates](const Vec2d &pt) {
|
||||
return rib_off_rotates ? Vec2d(wt_rot * (pt + rib_off) + wt_translate) : Vec2d(wt_rot * pt + wt_translate + rib_off);
|
||||
};
|
||||
|
||||
Points tower_pts;
|
||||
for (const std::vector<WipeTower::ToolChangeResult> &layer : tool_changes) {
|
||||
if (layer.empty() || wipe_tower_layer_is_sparse(layer))
|
||||
continue;
|
||||
for (const WipeTower::ToolChangeResult &tcr : layer)
|
||||
for (size_t i = 0; i < tcr.extrusions.size(); ++i) {
|
||||
// A zero width marks a travel end-point. Keep it only when it opens a real extrusion, so
|
||||
// the hull covers the deposited material and nothing else; travels reach a bit further out
|
||||
// than the walls do.
|
||||
const WipeTower::Extrusion &e = tcr.extrusions[i];
|
||||
if (e.width == 0.f && (i + 1 == tcr.extrusions.size() || tcr.extrusions[i + 1].width == 0.f))
|
||||
continue;
|
||||
const Vec2d p = to_bed(Vec2d(e.pos.x(), e.pos.y()));
|
||||
tower_pts.emplace_back(scale_(p.x()), scale_(p.y()));
|
||||
}
|
||||
}
|
||||
if (tower_pts.empty())
|
||||
return;
|
||||
|
||||
const CompactedTowerZone zone = compacted_wipe_tower_zone(m_config, Geometry::convex_hull(tower_pts));
|
||||
if (zone.empty())
|
||||
return;
|
||||
|
||||
for (const PrintObject *object : m_objects) {
|
||||
const double object_top = unscaled<double>(object->max_z());
|
||||
for (const PrintInstance &instance : object->instances()) {
|
||||
const Polygon inst_hull = compacted_tower_print_instance_hull(*object, instance);
|
||||
if (inst_hull.points.empty())
|
||||
continue;
|
||||
|
||||
// Report the worst layer rather than the first offending one, it is the one that explains the
|
||||
// collision best. The rise has to be known before the clearance: it is what selects the
|
||||
// horizontal tier, the nozzle cone being out of the head body's reach.
|
||||
double max_rise = 0.;
|
||||
for (size_t i = 0; i < tool_changes.size(); ++i) {
|
||||
if (tool_changes[i].empty() || wipe_tower_layer_is_sparse(tool_changes[i]))
|
||||
continue;
|
||||
// Nothing above the current layer exists yet, so a tall object only counts up to it.
|
||||
const double rise = std::min(object_top, double(tool_changes[i].front().print_z)) - tower_z[i];
|
||||
if (rise > max_rise)
|
||||
max_rise = rise;
|
||||
}
|
||||
|
||||
const CompactedTowerClearance clearance = compacted_wipe_tower_clearance(m_config, zone, inst_hull, max_rise);
|
||||
if (max_rise <= clearance.allowed_rise + EPSILON)
|
||||
continue;
|
||||
// Same wording as compacted_wipe_tower_clearance_valid(): height-limit and too-close
|
||||
// share one message, since both are layout violations of "No sparse layers".
|
||||
throw Slic3r::SlicingError(compacted_wipe_tower_clearance_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BBS
|
||||
static StringObjectException layered_print_cleareance_valid(const Print &print, StringObjectException *warning)
|
||||
{
|
||||
@@ -1406,6 +1781,16 @@ StringObjectException Print::validate(std::vector<StringObjectException> *warnin
|
||||
}
|
||||
if (!layer_warning.string.empty())
|
||||
add_warning(layer_warning);
|
||||
|
||||
// Orca: a compacted prime tower drags the nozzle back down to the plate on every toolchange, so
|
||||
// tall objects collide with it much like they do in sequential printing. Checking it here rather
|
||||
// than only during slicing is what lets the plater show the collision area and the height limit
|
||||
// while the plate is still being arranged.
|
||||
ret = compacted_wipe_tower_clearance_valid(*this, collison_polygons, height_polygons);
|
||||
if (!ret.string.empty()) {
|
||||
ret.type = STRING_EXCEPT_OBJECT_COLLISION_IN_LAYER_PRINT;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_config.enable_prime_tower) {
|
||||
@@ -2618,6 +3003,12 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
|
||||
if (this->has_wipe_tower()) {
|
||||
m_fake_wipe_tower.set_pos({ m_config.wipe_tower_x.get_at(m_plate_index), m_config.wipe_tower_y.get_at(m_plate_index) });
|
||||
// Validated on every process() run rather than only when the wipe tower step is (re)generated.
|
||||
// Moving the tower changes only wipe_tower_x/y, which invalidates psSkirtBrim but not psWipeTower,
|
||||
// so a validate call living inside _make_wipe_tower would be skipped and keep using the stale
|
||||
// position, missing a fresh collision. The tower geometry (tool_changes) is stored in the local
|
||||
// frame and is position independent, so re-checking here with the current position is correct.
|
||||
this->validate_compacted_wipe_tower_clearance();
|
||||
}
|
||||
|
||||
if (this->set_started(psSkirtBrim)) {
|
||||
|
||||
@@ -1160,6 +1160,8 @@ public:
|
||||
|
||||
//BBS
|
||||
static StringObjectException sequential_print_clearance_valid(const Print &print, Polygons *polygons = nullptr, std::vector<std::pair<Polygon, float>>* height_polygons = nullptr);
|
||||
// Orca: pre-slice clearance check for a prime tower compacted by "No sparse layers".
|
||||
static StringObjectException compacted_wipe_tower_clearance_valid(const Print &print, Polygons *polygons = nullptr, std::vector<std::pair<Polygon, float>>* height_polygons = nullptr);
|
||||
ConflictResultOpt get_conflict_result() const { return m_conflict_result; }
|
||||
|
||||
// Return 4 wipe tower corners in the world coordinates (shifted and rotated), including the wipe tower brim.
|
||||
@@ -1174,6 +1176,8 @@ public:
|
||||
void set_calib_params(const Calib_Params& params);
|
||||
const Calib_Params& calib_params() const { return m_calib_params; }
|
||||
Vec2d translate_to_print_space(const Vec2d &point) const;
|
||||
// Orca: precise counterpart of compacted_wipe_tower_clearance_valid(), run once the tower exists.
|
||||
void validate_compacted_wipe_tower_clearance() const;
|
||||
float get_wipe_tower_depth() const { return m_wipe_tower_data.depth; }
|
||||
BoundingBoxf get_wipe_tower_bbx() const { return m_wipe_tower_data.bbx; }
|
||||
Vec2f get_rib_offset() const { return m_wipe_tower_data.rib_offset; }
|
||||
@@ -1394,6 +1398,89 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Clearance rule for a prime tower compacted by wipe_tower_no_sparse_layers. Shared by the precise
|
||||
// check that runs on the real extrusions, the pre-slice estimate that feeds the plater with collision
|
||||
// polygons, and the plater's own live preview while the user drags the tower or an object around.
|
||||
// Keeping the rule in one place is what stops those three from drifting apart and reporting different
|
||||
// things for the same plate.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
// Half of a clearance distance, the share each of the two outlines carries. Sequential printing splits
|
||||
// extruder_clearance_radius between the two object hulls this way; the tower checks split their
|
||||
// clearances between the tower ring and the instance hull for the same reason, so that the two
|
||||
// outlines the plater draws touch precisely when the check trips. The 0.2 mm comes off first: it is
|
||||
// the rounding slack the sequential check applies, 0.1 mm per side.
|
||||
inline double compacted_tower_half_clearance(double clearance) { return 0.5 * (clearance - 0.2); }
|
||||
|
||||
// Keep-out geometry a compacted tower projects onto the plate, derived from its bare footprint.
|
||||
struct CompactedTowerZone
|
||||
{
|
||||
// Footprint the checks work on: the raw outline grown by the spiral Z-hop envelope.
|
||||
Polygon hull;
|
||||
// hull grown by half the toolhead radius; an object whose own half-grown hull reaches into it is
|
||||
// hit by the head body. This is also the ring the plater draws.
|
||||
Polygons grown_body;
|
||||
// hull grown by half the bare nozzle cone radius, the innermost tier.
|
||||
Polygons grown_nozzle;
|
||||
// hull bounding box, the Y band the rod sweeps.
|
||||
BoundingBox bbox_rod;
|
||||
// Full body clearance, of which grown_body carries half. Which of the two tiers applies is decided
|
||||
// per object rather than here; see compacted_wipe_tower_clearance().
|
||||
double body_radius { 0. };
|
||||
|
||||
bool empty() const { return hull.points.empty(); }
|
||||
};
|
||||
|
||||
// Per-side padding a bare wipe tower outline needs before the clearance checks may treat it as the
|
||||
// tower's footprint. Callers whose outline already carries the first-layer brim pass zero for it.
|
||||
// Shared by the pre-slice estimate and the plater's live preview: both start from an outline that
|
||||
// falls short of the printed tower in the same two ways, and padding them by different amounts is
|
||||
// exactly how the preview and the validation behind it would end up disagreeing.
|
||||
double compacted_tower_footprint_padding(const PrintConfig &config, double brim_width);
|
||||
|
||||
// Grow a bare tower footprint (bed frame, scaled) into its keep-out zone.
|
||||
CompactedTowerZone compacted_wipe_tower_zone(const PrintConfig &config, const Polygon &tower_footprint);
|
||||
|
||||
// How far an object may rise above the compacted tower base before the toolhead hits it.
|
||||
struct CompactedTowerClearance
|
||||
{
|
||||
// Height the object may reach above the tower base. Zero means it may not rise at all.
|
||||
double allowed_rise;
|
||||
// Clearance that applies once the object stands clear of the toolhead in XY, i.e. rod or lid.
|
||||
double far_clearance;
|
||||
// The object sits within the toolhead radius, so the head body limits it rather than the rod.
|
||||
bool near_body;
|
||||
// Horizontal clearance this particular object has to keep from the tower: the full toolhead
|
||||
// radius once it rises past the nozzle cone, the bare cone while it stays below. It is what the
|
||||
// error message quotes and what the plater grows the object outline by.
|
||||
double body_clearance;
|
||||
};
|
||||
|
||||
// object_rise is the height above the tower base that the caller is going to compare against
|
||||
// allowed_rise. It also selects the horizontal tier, so the two cannot disagree.
|
||||
CompactedTowerClearance compacted_wipe_tower_clearance(const PrintConfig &config, const CompactedTowerZone &zone,
|
||||
const Polygon &inst_hull, double object_rise);
|
||||
|
||||
// This object was judged on a tier reaching past the bare nozzle cone, so the wide ring is the one its
|
||||
// outline has to be drawn against.
|
||||
inline bool compacted_tower_body_tier(const CompactedTowerClearance &clearance)
|
||||
{
|
||||
return clearance.body_clearance > double(MAX_OUTER_NOZZLE_DIAMETER);
|
||||
}
|
||||
|
||||
// Keep-out rings to draw around the tower. The nozzle one always applies; the wide body one is drawn
|
||||
// only when some object on the plate is actually measured against it, otherwise it would show a
|
||||
// keep-out zone no object can violate.
|
||||
Polygons compacted_wipe_tower_rings(const CompactedTowerZone &zone, bool any_body_tier);
|
||||
|
||||
// Outline to hand the plater for an offending object: the instance hull grown by the same half
|
||||
// clearance the check grew it by, which is CompactedTowerClearance::body_clearance for that object.
|
||||
// Sequential printing reports its hulls the same way, and it doubles as the fix for the bare hull
|
||||
// being unusable on screen, where drawn flat it hides under the object and drawn at the height limit
|
||||
// it ends up buried inside the mesh.
|
||||
Polygon compacted_wipe_tower_offender_outline(const Polygon &inst_hull, double body_clearance);
|
||||
|
||||
} /* slic3r_Print_hpp_ */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2549,6 +2549,16 @@ void PrintConfigDef::init_fff_params()
|
||||
def->enum_labels.push_back("5");
|
||||
def->mode = comAdvanced;
|
||||
|
||||
// Orca: already carried by the BBL/Qidi/Geeetech/Eryone machine profiles, which inherited it from
|
||||
// the BambuStudio import; without a definition here it was parsed as an unknown key and dropped.
|
||||
def = this->add("extruder_clearance_dist_to_rod", coFloat);
|
||||
def->label = L("Distance to rod");
|
||||
def->tooltip = L("Horizontal distance of the nozzle tip to the rod's farther edge. Used for collision avoidance in by-object printing.");
|
||||
def->sidetext = L("mm"); // millimeters, CIS languages need translation
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(40));
|
||||
|
||||
def = this->add("extruder_clearance_height_to_rod", coFloat);
|
||||
def->label = L("Height to rod");
|
||||
def->tooltip = L("Distance from the nozzle tip to the lower rod. Used for collision avoidance in by-object printing.");
|
||||
@@ -5537,6 +5547,16 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(true));
|
||||
|
||||
def = this->add("unsupported_wall_last", coBool);
|
||||
def->label = L("Print unsupported walls last");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Wall loops that lie entirely in mid air are printed once something can hold them:\n"
|
||||
"they are extruded after the other walls of their island, innermost first, whatever the wall order is.\n"
|
||||
"A loop that only the bridges of this layer can anchor waits until those bridges are printed, while a loop running "
|
||||
"alongside a supported wall keeps its place before the infill, which needs it as an anchor.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("outer_wall_filament_id", coInt);
|
||||
def->gui_type = ConfigOptionDef::GUIType::i_enum_open;
|
||||
def->label = L("Outer walls");
|
||||
@@ -6267,6 +6287,36 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("wipe_inward", coBool);
|
||||
def->label = L("Wipe inward");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Applies only to external walls, including hole boundaries. Moves the hot nozzle toward printed "
|
||||
"inner walls during wiping to reduce reheating of freshly printed plastic and seam marks.\n\n"
|
||||
"Especially useful at layer heights below 0.1 mm, where wipe marks are more visible.\n\n"
|
||||
"Uses the regular wipe if no adjacent inner wall is already printed (single-wall areas or "
|
||||
"Outer/Inner wall order), or if no supported inward path can be found, for example at tight "
|
||||
"corners or seam gaps.");
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("wipe_inward_distance", coFloatOrPercent);
|
||||
def->label = L("Wipe inward distance");
|
||||
def->category = L("Quality");
|
||||
// xgettext:no-c-format, no-boost-format
|
||||
def->tooltip = L("The distance the wipe path is shifted away from the external perimeter, specified in millimeters "
|
||||
"or as a percentage of the actual outer-wall extrusion width.\n\n"
|
||||
"For example, 50% shifts the path by half of the outer-wall width. The effective offset is limited "
|
||||
"by both the actual outer-wall width and the available spacing to the adjacent wall, so values "
|
||||
"above 100% or an equivalent absolute distance have no additional effect. "
|
||||
"Set to 0 to disable the offset.");
|
||||
def->sidetext = L("mm or %");
|
||||
def->ratio_over = "outer_wall_line_width";
|
||||
def->min = 0;
|
||||
def->max = 100;
|
||||
def->max_literal = 2; // Orca: G-code generation also clamps literal values to the actual outer-wall width.
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionFloatOrPercent(50, true));
|
||||
|
||||
def = this->add("wipe_before_external_loop", coBool);
|
||||
def->label = L("Wipe before external loop");
|
||||
def->category = L("Quality");
|
||||
@@ -6644,8 +6694,10 @@ void PrintConfigDef::init_fff_params()
|
||||
def = this->add("wipe_tower_no_sparse_layers", coBool);
|
||||
def->label = L("No sparse layers (beta)");
|
||||
def->tooltip = L("If enabled, the wipe tower will not be printed on layers with no tool changes. "
|
||||
"On layers with a tool change, extruder will travel downward to print the wipe tower. "
|
||||
"User is responsible for ensuring there is no collision with the print.");
|
||||
"On layers with a tool change, extruder will travel downward to print the wipe tower, "
|
||||
"so the tower ends up below the model and the toolhead has to reach down to it. "
|
||||
"Layouts where that would collide with an already printed object are rejected. "
|
||||
"Has no effect with smooth timelapse or clumping detection, which need a tower on every layer.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
@@ -6671,6 +6723,34 @@ void PrintConfigDef::init_fff_params()
|
||||
def->enum_labels.emplace_back(L("Cyclic"));
|
||||
def->set_default_value(new ConfigOptionEnum<ToolChangeOrderingType>(ToolChangeOrderingType::Default));
|
||||
|
||||
def = this->add("toolchange_cyclic_order", coString);
|
||||
def->label = L("Cyclic order");
|
||||
def->category = L("Advanced");
|
||||
def->tooltip = L(
|
||||
"Custom filament sequence used by the cyclic toolchange ordering, as filament numbers separated by commas (e.g. \"3,2,1,4\").\n"
|
||||
"Each layer prints its filaments following this sequence; filaments not listed are printed last, in ascending order.\n"
|
||||
"Leave empty to cycle through the filaments in ascending order."
|
||||
);
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
def = this->add("toolchange_cyclic_first_layer", coBool);
|
||||
def->label = L("Apply cyclic order to first layer");
|
||||
def->category = L("Advanced");
|
||||
def->tooltip = L(
|
||||
"Applies the cyclic toolchange order to the first layer as well.\n"
|
||||
"By default this is disabled, because the first layer is instead ordered for the best bed "
|
||||
"adhesion: filaments that print small, fragile first-layer features are printed last, so the "
|
||||
"following tool changes and travel moves are less likely to knock those weakly anchored parts "
|
||||
"loose. This first-layer order also honors a custom first layer filament sequence when one is set. "
|
||||
"The cyclic order's benefit (extra tool changes give each layer more time to cool) does not apply "
|
||||
"to the first layer, which is printed slowly and hot for adhesion.\n"
|
||||
"Enable this only if you need the exact same tool sequence on every layer, including the first, at "
|
||||
"the cost of that adhesion optimization."
|
||||
);
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("slice_closing_radius", coFloat);
|
||||
def->label = L("Slice gap closing radius");
|
||||
def->category = L("Quality");
|
||||
@@ -6683,7 +6763,7 @@ void PrintConfigDef::init_fff_params()
|
||||
|
||||
def = this->add("slicing_mode", coEnum);
|
||||
def->label = L("Slicing Mode");
|
||||
def->category = L("Other");
|
||||
def->category = L("Others");
|
||||
def->tooltip = L("Use \"Even-odd\" for 3DLabPrint airplane models. Use \"Close holes\" to close all holes in the model.");
|
||||
def->enum_keys_map = &ConfigOptionEnum<SlicingMode>::get_enum_values();
|
||||
def->enum_values.push_back("regular");
|
||||
@@ -11894,6 +11974,19 @@ CLIActionsConfigDef::CLIActionsConfigDef()
|
||||
def->tooltip = L("Do not run any validity checks, such as G-code path conflicts check.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
// --strict turns the non-critical slicing warnings the CLI otherwise only logs into a
|
||||
// failed run, and records strict_mode in result.json so consumers can tell the modes apart.
|
||||
def = this->add("strict", coBool);
|
||||
def->label = L("Strict mode");
|
||||
def->tooltip = L("Exit non-zero when slicing raises a non-critical warning that is "
|
||||
"otherwise only logged, such as a model that needs support while "
|
||||
"support is disabled. Use this in CI or scripted pipelines that should "
|
||||
"never ship a subtly broken slice. Each such warning is also listed "
|
||||
"with a stable class in the `warnings` array of result.json, which is "
|
||||
"written on Linux only. Cannot be combined with --no-check, which skips "
|
||||
"the support check.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("normative_check", coBool);
|
||||
def->label = L("Normative check");
|
||||
def->tooltip = L("Check the normative items.");
|
||||
@@ -11914,6 +12007,26 @@ CLIActionsConfigDef::CLIActionsConfigDef()
|
||||
def->tooltip = L("This outputs the model\u2019s information.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("inspect_mesh", coBool);
|
||||
def->label = L("Inspect mesh (JSON to stdout)");
|
||||
def->tooltip = L("Print a JSON summary of each loaded object to stdout, then exit: its bounding boxes and the "
|
||||
"convex hull faces it can be laid on, with their normals, areas and centers. These are the faces "
|
||||
"the --ground-* options choose from. Machine-readable alternative to --info.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
// --inspect-paint \u2014 dump the per-facet enforcer/blocker/extruder/fuzzy
|
||||
// paint state stored on the loaded model (supports, seam, MMU color,
|
||||
// fuzzy-skin) as JSON. Read-only; lets CI / scripted / AI tooling
|
||||
// reason about existing paint on a .3mf without loading the GUI.
|
||||
def = this->add("inspect_paint", coBool);
|
||||
def->label = L("Inspect paint (JSON to stdout)");
|
||||
def->tooltip = L("Print a structured JSON summary of every painted layer "
|
||||
"(supports, seam, MMU color, fuzzy-skin) already stored on "
|
||||
"the loaded model \u2014 per-state facet count, surface area, "
|
||||
"and mesh-local bounding box \u2014 then exit. Machine-readable "
|
||||
"alternative to opening the paint gizmos in the GUI.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("export_settings", coString);
|
||||
def->label = L("Export Settings");
|
||||
def->tooltip = L("This exports settings to a file. Use - to write them to stdout.");
|
||||
@@ -12033,6 +12146,34 @@ CLITransformConfigDef::CLITransformConfigDef()
|
||||
def->sidetext = u8"°"; // degrees, don't need translation
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
// The --ground-* options choose from the faces the "Lay on Face" gizmo offers. Like the other
|
||||
// transforms they run in command-line order, so they see the rotations given before them.
|
||||
def = this->add("ground_largest_face", coBool);
|
||||
def->label = L("Ground largest face");
|
||||
def->tooltip = L("Lay each object on the largest face of its convex hull and drop it onto the bed. Of equally large "
|
||||
"faces, the one already facing down is kept. Objects without a face large enough to rest on are left "
|
||||
"as they are. Transforms run in command-line order, so rotations given before this option are respected. "
|
||||
"--orient 1 runs after all transforms and replaces the orientation.");
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("ground_face_normal", coString);
|
||||
def->label = L("Ground face by normal");
|
||||
def->tooltip = L("Lay each object on the convex hull face whose outward normal is closest to the direction NX,NY,NZ "
|
||||
"and drop it onto the bed. The direction is in object coordinates, which include the rotations given "
|
||||
"before this option and match the plate axes unless the input file rotates the object. For example, "
|
||||
"1,0,0 stands the object on its +X side. --orient 1 runs after all transforms and replaces the orientation.");
|
||||
def->cli_params = "NX,NY,NZ";
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
def = this->add("ground_face_point", coString);
|
||||
def->label = L("Ground face at point");
|
||||
def->tooltip = L("Lay each object on the convex hull face that contains the point X,Y,Z and drop it onto the bed. "
|
||||
"The point is in object coordinates, which include the rotations given before this option; "
|
||||
"--inspect-mesh reports face centers in them. Objects without such a face are left as they are, and "
|
||||
"the run fails if no object has one. --orient 1 runs after all transforms and replaces the orientation.");
|
||||
def->cli_params = "X,Y,Z";
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
def = this->add("scale", coFloat);
|
||||
def->label = L("Scale");
|
||||
def->tooltip = L("Scale the model by a float factor.");
|
||||
|
||||
@@ -1353,6 +1353,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
((ConfigOptionFloatsNullable, filament_ironing_speed))
|
||||
// Detect bridging perimeters
|
||||
((ConfigOptionBool, detect_overhang_wall))
|
||||
((ConfigOptionBool, unsupported_wall_last))
|
||||
((ConfigOptionInt, outer_wall_filament_id))
|
||||
((ConfigOptionInt, inner_wall_filament_id))
|
||||
((ConfigOptionFloatOrPercent, inner_wall_line_width))
|
||||
@@ -1391,6 +1392,8 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
((ConfigOptionBool, role_based_wipe_speed))
|
||||
((ConfigOptionFloatOrPercent, wipe_speed))
|
||||
((ConfigOptionBool, wipe_on_loops))
|
||||
((ConfigOptionBool, wipe_inward))
|
||||
((ConfigOptionFloatOrPercent, wipe_inward_distance))
|
||||
((ConfigOptionBool, wipe_before_external_loop))
|
||||
((ConfigOptionEnum<WallInfillOrder>, wall_infill_order))
|
||||
((ConfigOptionBool, precise_outer_wall))
|
||||
@@ -1625,6 +1628,8 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
((ConfigOptionBool, manual_filament_change))
|
||||
((ConfigOptionBool, single_extruder_multi_material_priming))
|
||||
((ConfigOptionEnum<ToolChangeOrderingType>, toolchange_ordering))
|
||||
((ConfigOptionString, toolchange_cyclic_order))
|
||||
((ConfigOptionBool, toolchange_cyclic_first_layer))
|
||||
((ConfigOptionBool, wipe_tower_no_sparse_layers))
|
||||
((ConfigOptionString, change_filament_gcode))
|
||||
((ConfigOptionString, change_extrusion_role_gcode))
|
||||
@@ -1786,6 +1791,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
||||
((ConfigOptionBools, slow_down_for_layer_cooling))
|
||||
((ConfigOptionInts, close_fan_the_first_x_layers))
|
||||
((ConfigOptionEnum<DraftShield>, draft_shield))
|
||||
((ConfigOptionFloat, extruder_clearance_dist_to_rod))//BBS
|
||||
((ConfigOptionFloat, extruder_clearance_height_to_rod))//BBs
|
||||
((ConfigOptionFloat, extruder_clearance_height_to_lid))//BBS
|
||||
((ConfigOptionFloat, extruder_clearance_radius))
|
||||
|
||||
@@ -1501,6 +1501,7 @@ bool PrintObject::invalidate_state_by_config_options(
|
||||
|| opt_key == "fuzzy_skin_octaves"
|
||||
|| opt_key == "fuzzy_skin_persistence"
|
||||
|| opt_key == "detect_overhang_wall"
|
||||
|| opt_key == "unsupported_wall_last"
|
||||
|| opt_key == "overhang_reverse"
|
||||
|| opt_key == "overhang_reverse_internal_only"
|
||||
|| opt_key == "overhang_reverse_threshold"
|
||||
@@ -1574,6 +1575,8 @@ bool PrintObject::invalidate_state_by_config_options(
|
||||
|| opt_key == "brim_flow_ratio"
|
||||
|| opt_key == "filament_flow_ratio"
|
||||
|| opt_key == "scarf_joint_flow_ratio"
|
||||
|| opt_key == "wipe_inward"
|
||||
|| opt_key == "wipe_inward_distance"
|
||||
|| opt_key == "spiral_starting_flow_ratio"
|
||||
|| opt_key == "spiral_finishing_flow_ratio") {
|
||||
invalidated |= m_print->invalidate_step(psGCodeExport);
|
||||
|
||||
@@ -680,6 +680,10 @@ set(SLIC3R_GUI_SOURCES
|
||||
Utils/bambu_networking.hpp
|
||||
Utils/Bonjour.cpp
|
||||
Utils/Bonjour.hpp
|
||||
Utils/MeshInspect.cpp
|
||||
Utils/MeshInspect.hpp
|
||||
Utils/PaintCLI.cpp
|
||||
Utils/PaintCLI.hpp
|
||||
Utils/CalibUtils.cpp
|
||||
Utils/CalibUtils.hpp
|
||||
Utils/ColorSpaceConvert.cpp
|
||||
|
||||
@@ -1197,11 +1197,11 @@ void AMSDryCtrWin::update_normal_description(DevAms* dev_ams)
|
||||
for (const auto& lim : ams_limits) {
|
||||
if (dev_ams->GetAmsType() == lim.type) {
|
||||
if (temp_val > lim.max_temp) {
|
||||
wxString msg = wxString(lim.name) + _L(" maximum drying temperature is ") + wxString::Format(wxT("%d"), lim.max_temp) + wxString::FromUTF8("°C.");
|
||||
wxString msg = wxString::Format(_L("%s maximum drying temperature is %d°C."), wxString(lim.name), lim.max_temp);
|
||||
warning_text += msg + "\n";
|
||||
can_enable_button = false;
|
||||
} else if (temp_val < lim.min_temp) {
|
||||
wxString msg = wxString(lim.name) + _L(" minimum drying temperature is ") + wxString::Format(wxT("%d"), lim.min_temp) + wxString::FromUTF8("°C.");
|
||||
wxString msg = wxString::Format(_L("%s minimum drying temperature is %d°C."), wxString(lim.name), lim.min_temp);
|
||||
warning_text += msg + "\n";
|
||||
can_enable_button = false;
|
||||
}
|
||||
|
||||
@@ -395,8 +395,9 @@ bool confirm_create_decompose_missing_components(wxWindow* parent, const std::ve
|
||||
missing_text += missing[i].display_name;
|
||||
}
|
||||
|
||||
wxString message = _L("The current filament list does not contain ") + missing_text +
|
||||
_L(". A project filament required by the mixed filament will be created automatically after decomposition.");
|
||||
wxString message = wxString::Format(_L("The current filament list does not contain %s. A project filament required by "
|
||||
"the mixed filament will be created automatically after decomposition."),
|
||||
missing_text);
|
||||
|
||||
MessageDialog dlg(parent, message, _L("Tip"), wxOK | wxCANCEL | wxICON_INFORMATION);
|
||||
dlg.show_dsa_button();
|
||||
|
||||
@@ -1041,10 +1041,12 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
|
||||
for (auto el : {"wipe_tower_rotation_angle", "wipe_tower_cone_angle",
|
||||
"wipe_tower_extra_spacing", "wipe_tower_max_purge_speed",
|
||||
"wipe_tower_bridging", "wipe_tower_extra_flow",
|
||||
"wipe_tower_no_sparse_layers"})
|
||||
"wipe_tower_bridging", "wipe_tower_extra_flow"})
|
||||
toggle_line(el, have_prime_tower && supports_wipe_tower_2);
|
||||
|
||||
// Orca: both tower generators skip sparse layers, so this is not a wipe tower 2 exclusive.
|
||||
toggle_line("wipe_tower_no_sparse_layers", have_prime_tower);
|
||||
|
||||
WipeTowerWallType wipe_tower_wall_type = config->opt_enum<WipeTowerWallType>("wipe_tower_wall_type");
|
||||
bool have_rib_wall = (wipe_tower_wall_type == WipeTowerWallType::wtwRib)&&have_prime_tower;
|
||||
toggle_line("wipe_tower_cone_angle", have_prime_tower && supports_wipe_tower_2 && wipe_tower_wall_type == WipeTowerWallType::wtwCone);
|
||||
@@ -1055,6 +1057,10 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
|
||||
toggle_line("single_extruder_multi_material_priming", !bSEMM && have_prime_tower && supports_wipe_tower_2);
|
||||
|
||||
bool use_cyclic_ordering = config->opt_enum<ToolChangeOrderingType>("toolchange_ordering") == ToolChangeOrderingType::Cyclic;
|
||||
toggle_line("toolchange_cyclic_order", use_cyclic_ordering);
|
||||
toggle_line("toolchange_cyclic_first_layer", use_cyclic_ordering);
|
||||
|
||||
toggle_line("prime_volume",have_prime_tower && (!purge_in_primetower || !bSEMM));
|
||||
|
||||
for (auto el : {"flush_into_infill", "flush_into_support", "flush_into_objects"})
|
||||
@@ -1104,6 +1110,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
auto is_role_based_wipe_speed = config->opt_bool("role_based_wipe_speed");
|
||||
toggle_field("wipe_speed",!is_role_based_wipe_speed);
|
||||
|
||||
const bool have_wipe_inward = config->opt_bool("wipe_inward");
|
||||
toggle_line("wipe_inward_distance", have_wipe_inward);
|
||||
|
||||
for (auto el : {"accel_to_decel_enable", "accel_to_decel_factor"})
|
||||
toggle_line(el, gcf_is_klipper);
|
||||
if(gcf_is_klipper)
|
||||
@@ -1125,6 +1134,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, in
|
||||
bool has_detect_overhang_wall = config->opt_bool("detect_overhang_wall");
|
||||
bool has_overhang_reverse = config->opt_bool("overhang_reverse");
|
||||
bool allow_overhang_reverse = !has_spiral_vase;
|
||||
toggle_line("unsupported_wall_last", has_detect_overhang_wall);
|
||||
toggle_line("overhang_reverse", allow_overhang_reverse);
|
||||
toggle_line("overhang_reverse_internal_only", allow_overhang_reverse && has_overhang_reverse);
|
||||
bool has_overhang_reverse_internal_only = config->opt_bool("overhang_reverse_internal_only");
|
||||
|
||||
@@ -188,6 +188,17 @@ wxString get_string_value(const std::string& opt_key, const DynamicPrintConfig&
|
||||
out = double_to_string(opt->value) + (opt->percent ? "%" : "");
|
||||
return out;
|
||||
}
|
||||
case coFloatsOrPercents: {
|
||||
const auto* values = static_cast<const ConfigOptionVector<FloatOrPercent>*>(option);
|
||||
// Orca: Preset comparison may request the entire vector instead of an indexed entry.
|
||||
if (orig_opt_idx < 0)
|
||||
return from_u8(option->serialize());
|
||||
if (opt_idx < values->size()) {
|
||||
const FloatOrPercent& value = values->get_at(opt_idx);
|
||||
return double_to_string(value.value) + (value.percent ? "%" : "");
|
||||
}
|
||||
return _L("Undefined");
|
||||
}
|
||||
case coEnum: {
|
||||
return get_string_from_enum(pure_key, config,
|
||||
pure_key == "top_surface_pattern" ||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Plater.hpp"
|
||||
#include "Camera.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "format.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GLCanvas3D.hpp"
|
||||
@@ -3436,16 +3437,18 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Whole sentences: the bare "up to"/"above"/"from"/"to" these used to be glued from gave a
|
||||
// translator no context, and left the unit and the numbers stuck in English word order.
|
||||
auto upto_label = [](double z) {
|
||||
char buf[64];
|
||||
::sprintf(buf, "%.2f", z);
|
||||
return _u8L("up to") + " " + std::string(buf) + " " + _u8L("mm");
|
||||
return format(_u8L("up to %1% mm"), buf);
|
||||
};
|
||||
|
||||
auto above_label = [](double z) {
|
||||
char buf[64];
|
||||
::sprintf(buf, "%.2f", z);
|
||||
return _u8L("above") + " " + std::string(buf) + " " + _u8L("mm");
|
||||
return format(_u8L("above %1% mm"), buf);
|
||||
};
|
||||
|
||||
auto fromto_label = [](double z1, double z2) {
|
||||
@@ -3453,7 +3456,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
::sprintf(buf1, "%.2f", z1);
|
||||
char buf2[64];
|
||||
::sprintf(buf2, "%.2f", z2);
|
||||
return _u8L("from") + " " + std::string(buf1) + " " + _u8L("to") + " " + std::string(buf2) + " " + _u8L("mm");
|
||||
return format(_u8L("from %1% to %2% mm"), buf1, buf2);
|
||||
};
|
||||
|
||||
auto role_time_and_percent = [this, total_estimated_time](libvgcode::EGCodeExtrusionRole role) {
|
||||
|
||||
@@ -4316,6 +4316,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
if (can_sequential_clearance_show_in_gizmo())
|
||||
update_sequential_clearance();
|
||||
} else {
|
||||
// Orca: by-layer counterpart, for a prime tower compacted by "No sparse layers".
|
||||
if (current_printer_technology() == ptFFF && can_sequential_clearance_show_in_gizmo())
|
||||
update_compacted_wipe_tower_clearance();
|
||||
if (c == GLGizmosManager::EType::Move ||
|
||||
c == GLGizmosManager::EType::Scale ||
|
||||
c == GLGizmosManager::EType::Rotate)
|
||||
@@ -4549,8 +4552,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D, trafo_type);
|
||||
if (current_printer_technology() == ptFFF && (fff_print()->config().print_sequence == PrintSequence::ByObject))
|
||||
update_sequential_clearance();
|
||||
if (current_printer_technology() == ptFFF) {
|
||||
if (fff_print()->config().print_sequence == PrintSequence::ByObject)
|
||||
update_sequential_clearance();
|
||||
else
|
||||
update_compacted_wipe_tower_clearance();
|
||||
}
|
||||
// BBS
|
||||
//wxGetApp().obj_manipul()->set_dirty();
|
||||
m_dirty = true;
|
||||
@@ -5614,6 +5621,101 @@ bool GLCanvas3D::can_sequential_clearance_show_in_gizmo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Live preview of the compacted prime tower clearance, the by-layer counterpart of
|
||||
// update_sequential_clearance(). Called while the user drags a volume / gizmo; idle visibility
|
||||
// matches sequential print (hidden when valid, filled when Print::validate reports a collision).
|
||||
// Print::compacted_wipe_tower_clearance_valid() answers the same question authoritatively, but it
|
||||
// reads the tower position from the config, which only catches up once do_move() writes it back on
|
||||
// mouse release. Recomputing from the volumes here is what makes the keep-out zone follow the tower
|
||||
// while it is still under the cursor.
|
||||
void GLCanvas3D::update_compacted_wipe_tower_clearance()
|
||||
{
|
||||
if (current_printer_technology() != ptFFF)
|
||||
return;
|
||||
const Print *print = fff_print();
|
||||
if (print == nullptr)
|
||||
return;
|
||||
const PrintConfig &config = print->config();
|
||||
if (config.print_sequence != PrintSequence::ByLayer || ! wipe_tower_sparse_layers_skipped(config) || ! print->has_wipe_tower())
|
||||
return;
|
||||
|
||||
PartPlateList &plate_list = wxGetApp().plater()->get_partplate_list();
|
||||
PartPlate *plate = plate_list.get_curr_plate();
|
||||
if (plate == nullptr)
|
||||
return;
|
||||
const int plate_id = plate_list.get_curr_plate_index();
|
||||
|
||||
// Once the tower has been generated the scene shows its real mesh with the brim merged in,
|
||||
// otherwise it is a bare estimated cube with no brim at all. Only the latter needs the brim added
|
||||
// here, and the width comes from WipeTowerData, the same source the preview box is sized from, so
|
||||
// the zone cannot be padded against a brim the preview was not built with.
|
||||
const bool preview_carries_brim = print->is_step_done(psWipeTower) && print->wipe_tower_data().wipe_tower_mesh_data.has_value();
|
||||
const double brim = preview_carries_brim ? 0. : double(print->wipe_tower_data(print->extruders().size()).brim_width);
|
||||
const double padding = compacted_tower_footprint_padding(config, brim);
|
||||
|
||||
// Tower footprint straight from the volume the user sees, so that dragging either the tower or an
|
||||
// object updates the zone on the very next frame.
|
||||
Polygon tower_footprint;
|
||||
for (const GLVolume *v : m_volumes.volumes) {
|
||||
if (! v->is_wipe_tower || v->object_idx() - 1000 != plate_id)
|
||||
continue;
|
||||
const BoundingBoxf3 bbox = v->transformed_convex_hull_bounding_box();
|
||||
tower_footprint = Polygon({ Point(scale_(bbox.min.x() - padding), scale_(bbox.min.y() - padding)),
|
||||
Point(scale_(bbox.max.x() + padding), scale_(bbox.min.y() - padding)),
|
||||
Point(scale_(bbox.max.x() + padding), scale_(bbox.max.y() + padding)),
|
||||
Point(scale_(bbox.min.x() - padding), scale_(bbox.max.y() + padding)) });
|
||||
break;
|
||||
}
|
||||
|
||||
const CompactedTowerZone zone = compacted_wipe_tower_zone(config, tower_footprint);
|
||||
if (zone.empty()) {
|
||||
reset_sequential_print_clearance();
|
||||
return;
|
||||
}
|
||||
|
||||
// While dragging, outline every on-plate instance next to the tower ring, the way sequential print
|
||||
// outlines every object. Both carry half of the clearance, so the two outlines meeting is precisely
|
||||
// the moment that object goes over its limit - which is what makes the pair worth drawing at all.
|
||||
// The tier is per object, so a short object gets the narrow nozzle outline rather than the wide
|
||||
// body one it is not subject to; without that, a 3 mm object parked beside the tower would be drawn
|
||||
// deep inside the keep-out ring while passing the check. Only the instances that already exceed
|
||||
// allowed_rise also get a height limit plane.
|
||||
Polygons outlines;
|
||||
std::vector<std::pair<Polygon, float>> height_polygons;
|
||||
bool body_tier_used = false;
|
||||
const BoundingBox plate_bb = plate->get_bounding_box_crd();
|
||||
for (const ModelObject *model_object : m_model->objects) {
|
||||
for (size_t i = 0; i < model_object->instances.size(); ++i) {
|
||||
Geometry::Transformation trafo(model_object->instances[i]->get_transformation());
|
||||
const Vec3d offset = trafo.get_offset();
|
||||
trafo.set_offset(Vec3d(offset.x(), offset.y(), 0.0));
|
||||
const Polygon inst_hull = model_object->convex_hull_2d(trafo.get_matrix());
|
||||
if (inst_hull.points.empty() || ! plate_bb.overlap(inst_hull.bounding_box()))
|
||||
continue;
|
||||
|
||||
// Same tiers and the same rise measured from the plate as
|
||||
// Print::compacted_wipe_tower_clearance_valid(), so that the preview and the validation
|
||||
// that follows it never contradict each other.
|
||||
const double object_top = model_object->get_instance_max_z(i);
|
||||
const CompactedTowerClearance clearance = compacted_wipe_tower_clearance(config, zone, inst_hull, object_top);
|
||||
body_tier_used = body_tier_used || compacted_tower_body_tier(clearance);
|
||||
|
||||
const Polygon outline = compacted_wipe_tower_offender_outline(inst_hull, clearance.body_clearance);
|
||||
outlines.emplace_back(outline);
|
||||
if (object_top <= clearance.allowed_rise + EPSILON)
|
||||
continue;
|
||||
height_polygons.emplace_back(outline, float(clearance.allowed_rise));
|
||||
}
|
||||
}
|
||||
|
||||
Polygons polygons = compacted_wipe_tower_rings(zone, body_tier_used);
|
||||
append(polygons, outlines);
|
||||
|
||||
set_sequential_print_clearance_visible(true);
|
||||
set_sequential_print_clearance_render_fill(false);
|
||||
set_sequential_print_clearance_polygons(polygons, height_polygons);
|
||||
}
|
||||
|
||||
void GLCanvas3D::update_sequential_clearance()
|
||||
{
|
||||
if (current_printer_technology() != ptFFF || (fff_print()->config().print_sequence == PrintSequence::ByLayer))
|
||||
|
||||
@@ -1191,6 +1191,8 @@ public:
|
||||
|
||||
bool can_sequential_clearance_show_in_gizmo();
|
||||
void update_sequential_clearance();
|
||||
// Orca: by-layer counterpart, for a prime tower compacted by "No sparse layers".
|
||||
void update_compacted_wipe_tower_clearance();
|
||||
|
||||
const Print* fff_print() const;
|
||||
const SLAPrint* sla_print() const;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
|
||||
|
||||
#include "libslic3r/Geometry/ConvexHull.hpp"
|
||||
#include "libslic3r/LayOnFace.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
#include <numeric>
|
||||
@@ -45,10 +45,10 @@ void GLGizmoFlatten::data_changed(bool is_serializing)
|
||||
const ModelObject *model_object = nullptr;
|
||||
int instance_id = -1;
|
||||
if (selection.is_single_full_instance() ||
|
||||
selection.is_from_single_object() ) {
|
||||
selection.is_from_single_object() ) {
|
||||
model_object = selection.get_model()->objects[selection.get_object_idx()];
|
||||
instance_id = selection.get_instance_idx();
|
||||
}
|
||||
}
|
||||
set_flattening_data(model_object, instance_id);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void GLGizmoFlatten::on_render()
|
||||
GLShaderProgram* shader = wxGetApp().get_shader("flat");
|
||||
if (shader == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
shader->start_using();
|
||||
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
|
||||
|
||||
@@ -152,134 +152,18 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object, int in
|
||||
void GLGizmoFlatten::update_planes()
|
||||
{
|
||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||
TriangleMesh ch;
|
||||
for (const ModelVolume* vol : mo->volumes) {
|
||||
if (vol->type() != ModelVolumeType::MODEL_PART)
|
||||
continue;
|
||||
TriangleMesh vol_ch = vol->get_convex_hull();
|
||||
vol_ch.transform(vol->get_matrix());
|
||||
ch.merge(vol_ch);
|
||||
}
|
||||
ch = ch.convex_hull_3d();
|
||||
const Transform3d &inst_matrix = mo->instances.front()->get_matrix_no_offset();
|
||||
// The candidate faces are shared with the CLI --ground-* options, the rest only prepares them for rendering.
|
||||
std::vector<LayOnFacePlane> planes = lay_on_face_planes(*mo, inst_matrix);
|
||||
m_planes.clear();
|
||||
on_unregister_raycasters_for_picking();
|
||||
const Transform3d &inst_matrix = mo->instances.front()->get_matrix_no_offset();
|
||||
|
||||
// Following constants are used for discarding too small polygons.
|
||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||
const float minimal_side = 1.f; // mm
|
||||
const float minimal_angle = 1.f; // degree, initial value was 10, but cause bugs
|
||||
// We only keep the 254 largest planes (because of the picking pass limitations):
|
||||
planes.resize(std::min((int)planes.size(), 254));
|
||||
|
||||
// Now we'll go through all the facets and append Points of facets sharing the same normal.
|
||||
// This part is still performed in mesh coordinate system.
|
||||
const int num_of_facets = ch.facets_count();
|
||||
const std::vector<Vec3f> face_normals = its_face_normals(ch.its);
|
||||
const std::vector<Vec3i32> face_neighbors = its_face_neighbors(ch.its);
|
||||
std::vector<int> facet_queue(num_of_facets, 0);
|
||||
std::vector<bool> facet_visited(num_of_facets, false);
|
||||
int facet_queue_cnt = 0;
|
||||
const stl_normal* normal_ptr = nullptr;
|
||||
int facet_idx = 0;
|
||||
while (1) {
|
||||
// Find next unvisited triangle:
|
||||
for (; facet_idx < num_of_facets; ++ facet_idx)
|
||||
if (!facet_visited[facet_idx]) {
|
||||
facet_queue[facet_queue_cnt ++] = facet_idx;
|
||||
facet_visited[facet_idx] = true;
|
||||
normal_ptr = &face_normals[facet_idx];
|
||||
m_planes.emplace_back();
|
||||
break;
|
||||
}
|
||||
if (facet_idx == num_of_facets)
|
||||
break; // Everything was visited already
|
||||
|
||||
while (facet_queue_cnt > 0) {
|
||||
int facet_idx = facet_queue[-- facet_queue_cnt];
|
||||
const stl_normal& this_normal = face_normals[facet_idx];
|
||||
if (std::abs(this_normal(0) - (*normal_ptr)(0)) < 0.001 && std::abs(this_normal(1) - (*normal_ptr)(1)) < 0.001 && std::abs(this_normal(2) - (*normal_ptr)(2)) < 0.001) {
|
||||
const Vec3i32 face = ch.its.indices[facet_idx];
|
||||
for (int j=0; j<3; ++j)
|
||||
m_planes.back().vertices.emplace_back(ch.its.vertices[face[j]].cast<double>());
|
||||
|
||||
facet_visited[facet_idx] = true;
|
||||
for (int j = 0; j < 3; ++ j)
|
||||
if (int neighbor_idx = face_neighbors[facet_idx][j]; neighbor_idx >= 0 && ! facet_visited[neighbor_idx])
|
||||
facet_queue[facet_queue_cnt ++] = neighbor_idx;
|
||||
}
|
||||
}
|
||||
m_planes.back().normal = normal_ptr->cast<double>();
|
||||
|
||||
Pointf3s& verts = m_planes.back().vertices;
|
||||
// Now we'll transform all the points into world coordinates, so that the areas, angles and distances
|
||||
// make real sense.
|
||||
verts = transform(verts, inst_matrix);
|
||||
|
||||
// if this is a just a very small triangle, remove it to speed up further calculations (it would be rejected later anyway):
|
||||
if (verts.size() == 3 &&
|
||||
((verts[0] - verts[1]).norm() < minimal_side
|
||||
|| (verts[0] - verts[2]).norm() < minimal_side
|
||||
|| (verts[1] - verts[2]).norm() < minimal_side))
|
||||
m_planes.pop_back();
|
||||
}
|
||||
|
||||
// Let's prepare transformation of the normal vector from mesh to instance coordinates.
|
||||
const Matrix3d normal_matrix = inst_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
|
||||
|
||||
// Now we'll go through all the polygons, transform the points into xy plane to process them:
|
||||
for (unsigned int polygon_id=0; polygon_id < m_planes.size(); ++polygon_id) {
|
||||
Pointf3s& polygon = m_planes[polygon_id].vertices;
|
||||
const Vec3d& normal = m_planes[polygon_id].normal;
|
||||
|
||||
// transform the normal according to the instance matrix:
|
||||
const Vec3d normal_transformed = normal_matrix * normal;
|
||||
|
||||
// We are going to rotate about z and y to flatten the plane
|
||||
Eigen::Quaterniond q;
|
||||
Transform3d m = Transform3d::Identity();
|
||||
m.matrix().block(0, 0, 3, 3) = q.setFromTwoVectors(normal_transformed, Vec3d::UnitZ()).toRotationMatrix();
|
||||
polygon = transform(polygon, m);
|
||||
|
||||
// Now to remove the inner points. We'll misuse Geometry::convex_hull for that, but since
|
||||
// it works in fixed point representation, we will rescale the polygon to avoid overflows.
|
||||
// And yes, it is a nasty thing to do. Whoever has time is free to refactor.
|
||||
Vec3d bb_size = BoundingBoxf3(polygon).size();
|
||||
float sf = std::min(1./bb_size(0), 1./bb_size(1));
|
||||
Transform3d tr = Geometry::scale_transform({ sf, sf, 1.f });
|
||||
polygon = transform(polygon, tr);
|
||||
polygon = Slic3r::Geometry::convex_hull(polygon);
|
||||
polygon = transform(polygon, tr.inverse());
|
||||
|
||||
// Calculate area of the polygons and discard ones that are too small
|
||||
float& area = m_planes[polygon_id].area;
|
||||
area = 0.f;
|
||||
for (unsigned int i = 0; i < polygon.size(); i++) // Shoelace formula
|
||||
area += polygon[i](0)*polygon[i + 1 < polygon.size() ? i + 1 : 0](1) - polygon[i + 1 < polygon.size() ? i + 1 : 0](0)*polygon[i](1);
|
||||
area = 0.5f * std::abs(area);
|
||||
|
||||
bool discard = false;
|
||||
if (area < minimal_area)
|
||||
discard = true;
|
||||
else {
|
||||
// We also check the inner angles and discard polygons with angles smaller than the following threshold
|
||||
const double angle_threshold = ::cos(minimal_angle * (double)PI / 180.0);
|
||||
|
||||
for (unsigned int i = 0; i < polygon.size(); ++i) {
|
||||
const Vec3d& prec = polygon[(i == 0) ? polygon.size() - 1 : i - 1];
|
||||
const Vec3d& curr = polygon[i];
|
||||
const Vec3d& next = polygon[(i == polygon.size() - 1) ? 0 : i + 1];
|
||||
|
||||
if ((prec - curr).normalized().dot((next - curr).normalized()) > angle_threshold) {
|
||||
discard = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (discard) {
|
||||
m_planes[polygon_id--] = std::move(m_planes.back());
|
||||
m_planes.pop_back();
|
||||
continue;
|
||||
}
|
||||
for (LayOnFacePlane& plane : planes) {
|
||||
// The outline is convex and lies in the plane frame, where the plane is horizontal.
|
||||
Pointf3s& polygon = plane.outline;
|
||||
|
||||
// We will shrink the polygon a little bit so it does not touch the object edges:
|
||||
Vec3d centroid = std::accumulate(polygon.begin(), polygon.end(), Vec3d(0.0, 0.0, 0.0));
|
||||
@@ -332,13 +216,12 @@ void GLGizmoFlatten::update_planes()
|
||||
b(2) += 0.1f;
|
||||
|
||||
// Transform back to 3D (and also back to mesh coordinates)
|
||||
polygon = transform(polygon, inst_matrix.inverse() * m.inverse());
|
||||
m_planes.emplace_back();
|
||||
m_planes.back().normal = plane.normal;
|
||||
m_planes.back().area = plane.area;
|
||||
m_planes.back().vertices = transform(polygon, inst_matrix.inverse() * plane.to_plane_frame.inverse());
|
||||
}
|
||||
|
||||
// We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
|
||||
std::sort(m_planes.rbegin(), m_planes.rend(), [](const PlaneData& a, const PlaneData& b) { return a.area < b.area; });
|
||||
m_planes.resize(std::min((int)m_planes.size(), 254));
|
||||
|
||||
// Planes are finished - let's save what we calculated it from:
|
||||
m_volumes_matrices.clear();
|
||||
m_volumes_types.clear();
|
||||
|
||||
@@ -1053,7 +1053,13 @@ void PartPlate::render_grid(bool bottom) {
|
||||
|
||||
void PartPlate::render_height_limit(PartPlate::HeightLimitMode mode)
|
||||
{
|
||||
if (m_print && m_print->config().print_sequence == PrintSequence::ByObject && mode != HEIGHT_LIMIT_NONE)
|
||||
// Orca: a prime tower compacted by "No sparse layers" drags the nozzle back down to the plate on
|
||||
// every toolchange, so the rod and the lid limit how tall a neighbouring object may be exactly as
|
||||
// they do in sequential printing. The reference lines are just as useful there.
|
||||
const bool relevant_for_print_mode = m_print && (m_print->config().print_sequence == PrintSequence::ByObject ||
|
||||
(m_print->config().print_sequence == PrintSequence::ByLayer &&
|
||||
wipe_tower_sparse_layers_skipped(m_print->config()) && m_print->has_wipe_tower()));
|
||||
if (relevant_for_print_mode && mode != HEIGHT_LIMIT_NONE)
|
||||
{
|
||||
// draw lower limit
|
||||
// ORCA: OpenGL Core Profile
|
||||
|
||||
@@ -15755,6 +15755,7 @@ void Plater::calib_pa(const Calib_Params& params)
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
print_config->set_key_value("overhang_reverse", new ConfigOptionBool(false));
|
||||
print_config->set_key_value("precise_z_height", new ConfigOptionBool(false));
|
||||
print_config->set_key_value("wipe_inward", new ConfigOptionBool(false));
|
||||
printer_config->set_key_value("resonance_avoidance", new ConfigOptionBool{false});
|
||||
switch (params.mode) {
|
||||
case CalibMode::Calib_PA_Line:
|
||||
@@ -16440,6 +16441,7 @@ void Plater::calib_retraction(const Calib_Params& params)
|
||||
auto obj = model().objects[0];
|
||||
|
||||
print_config->set_key_value("enable_wrapping_detection", new ConfigOptionBool(false));
|
||||
print_config->set_key_value("wipe_inward", new ConfigOptionBool(false));
|
||||
|
||||
float nozzle_diameter = printer_config->option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
|
||||
float layer_height;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <wx/dcmemory.h>
|
||||
#include <wx/dcgraph.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/wrapsizer.h>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -416,12 +417,54 @@ std::set<size_t> project_used_filament_slots(const PresetBundle& bundle, const D
|
||||
return used;
|
||||
}
|
||||
|
||||
// Lays a translated sentence out along `row`, replacing each "%1%"-style placeholder with the
|
||||
// matching window from `chips`. Keeping the sentence in one msgid lets a translation put the
|
||||
// placeholders wherever its own grammar needs them; spacing comes from the translation itself.
|
||||
void add_sentence_with_chips(wxWindow* parent, wxSizer* row, const wxString& sentence, const std::vector<wxWindow*>& chips)
|
||||
{
|
||||
std::vector<bool> placed(chips.size(), false);
|
||||
auto add_text = [&](wxString text) {
|
||||
text.Replace("%%", "%"); // the sentence is a format string
|
||||
if (text.IsEmpty())
|
||||
return;
|
||||
auto* label = new wxStaticText(parent, wxID_ANY, text);
|
||||
label->SetFont(Label::Body_12);
|
||||
label->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#6B6B6B")));
|
||||
row->Add(label, 0, wxALIGN_CENTER_VERTICAL);
|
||||
};
|
||||
auto add_chip = [&](size_t i) {
|
||||
if (i < chips.size() && chips[i] != nullptr && !placed[i]) {
|
||||
placed[i] = true;
|
||||
row->Add(chips[i], 0, wxALIGN_CENTER_VERTICAL);
|
||||
}
|
||||
};
|
||||
|
||||
size_t literal = 0, pos = 0;
|
||||
while ((pos = sentence.find('%', pos)) != wxString::npos) {
|
||||
size_t end = pos + 1;
|
||||
while (end < sentence.length() && sentence[end] >= '0' && sentence[end] <= '9')
|
||||
++end;
|
||||
if (end == pos + 1 || end >= sentence.length() || sentence[end] != '%') {
|
||||
++pos; // a bare '%'
|
||||
continue;
|
||||
}
|
||||
long index = 0;
|
||||
sentence.Mid(pos + 1, end - pos - 1).ToLong(&index);
|
||||
add_text(sentence.Mid(literal, pos - literal));
|
||||
add_chip(size_t(index - 1));
|
||||
literal = pos = end + 1;
|
||||
}
|
||||
add_text(sentence.Mid(literal));
|
||||
for (size_t i = 0; i < chips.size(); ++i) // whatever the translation left out
|
||||
add_chip(i);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Warning shown on OK when an enabled mixed-filament slot relies on a filament that would ship
|
||||
// without its material. One row per unmet dependency: the mixed slot's colour chip, the
|
||||
// component filament's colour chip, and the reason. "Cancel" is the safe choice and keeps the
|
||||
// dialog open; "Publish anyway" continues.
|
||||
// without its material. One row per unmet dependency, each a single translated sentence whose
|
||||
// two placeholders are the mixed slot's and the component filament's colour chips. "Cancel" is
|
||||
// the safe choice and keeps the dialog open; "Publish anyway" continues.
|
||||
class MixedFilamentWarningDialog : public MsgDialog
|
||||
{
|
||||
public:
|
||||
@@ -437,47 +480,37 @@ public:
|
||||
content->AddSpacer(FromDIP(10));
|
||||
|
||||
const int swatch = FromDIP(20);
|
||||
for (const MixedDependencyIssue& issue : issues) {
|
||||
auto* row = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
// The mixed slot as just its own chip (gradient-aware, numbered like its tab);
|
||||
// falls back to a plain label when the chip cannot be built.
|
||||
const wxString mix_label = wxString::Format(_L("Filament %d (mixed)"), int(issue.mixed_slot) + 1);
|
||||
const wxBitmap mix_bmp = mixed_filament_chip_bitmap(full, issue.mixed_slot, swatch);
|
||||
if (mix_bmp.IsOk()) {
|
||||
auto* bmp = new wxStaticBitmap(this, wxID_ANY, mix_bmp);
|
||||
bmp->SetToolTip(mix_label);
|
||||
row->Add(bmp, 0, wxALIGN_CENTER_VERTICAL);
|
||||
} else {
|
||||
auto* label = new wxStaticText(this, wxID_ANY, mix_label);
|
||||
label->SetFont(Label::Body_12);
|
||||
row->Add(label, 0, wxALIGN_CENTER_VERTICAL);
|
||||
// The slot's colour swatch, numbered like its tab, with the slot name on hover; falls
|
||||
// back to a label so the sentence always names both filaments.
|
||||
auto make_chip = [&](const wxBitmap& bmp, const wxString& name) -> wxWindow* {
|
||||
if (bmp.IsOk()) {
|
||||
auto* chip = new wxStaticBitmap(this, wxID_ANY, bmp);
|
||||
chip->SetToolTip(name);
|
||||
return chip;
|
||||
}
|
||||
auto* label = new wxStaticText(this, wxID_ANY, name);
|
||||
label->SetFont(Label::Body_12);
|
||||
return label;
|
||||
};
|
||||
|
||||
auto* needs = new wxStaticText(this, wxID_ANY, _L("needs"));
|
||||
needs->SetFont(Label::Body_12);
|
||||
needs->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#6B6B6B")));
|
||||
row->Add(needs, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, FromDIP(6));
|
||||
|
||||
// The component filament's colour chip, numbered like the tab strips; the slot
|
||||
// name stays on hover to keep the row itself short.
|
||||
for (const MixedDependencyIssue& issue : issues) {
|
||||
std::string hex = filament_color_hex(full, issue.component_slot);
|
||||
if (hex.empty())
|
||||
hex = "#D9D9D9";
|
||||
if (wxBitmap* chip = get_extruder_color_icon(hex, std::to_string(issue.component_slot + 1), swatch, swatch)) {
|
||||
auto* comp_bmp = new wxStaticBitmap(this, wxID_ANY, *chip);
|
||||
comp_bmp->SetToolTip(wxString::Format(_L("Filament %d"), int(issue.component_slot) + 1));
|
||||
row->Add(comp_bmp, 0, wxALIGN_CENTER_VERTICAL);
|
||||
}
|
||||
const wxBitmap* comp_bmp = get_extruder_color_icon(hex, std::to_string(issue.component_slot + 1), swatch, swatch);
|
||||
|
||||
auto* reason = new wxStaticText(this, wxID_ANY,
|
||||
issue.reason == MixedDependencyIssue::Reason::Disabled ? _L("not enabled") :
|
||||
_L("material not published"));
|
||||
reason->SetFont(Label::Body_12);
|
||||
reason->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#989898")));
|
||||
row->Add(reason, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(8));
|
||||
wxWindow* mix_chip = make_chip(mixed_filament_chip_bitmap(full, issue.mixed_slot, swatch),
|
||||
wxString::Format(_L("Filament %d (mixed)"), int(issue.mixed_slot) + 1));
|
||||
wxWindow* comp_chip = make_chip(comp_bmp != nullptr ? *comp_bmp : wxNullBitmap,
|
||||
wxString::Format(_L("Filament %d"), int(issue.component_slot) + 1));
|
||||
|
||||
content->Add(row, 0, wxLEFT, FromDIP(10));
|
||||
auto* row = new wxWrapSizer(wxHORIZONTAL);
|
||||
add_sentence_with_chips(this, row,
|
||||
issue.reason == MixedDependencyIssue::Reason::Disabled ?
|
||||
_L("%1% needs %2%, which is not enabled.") :
|
||||
_L("%1% needs %2%, whose material will not be published."),
|
||||
{mix_chip, comp_chip});
|
||||
content->Add(row, 0, wxEXPAND | wxLEFT, FromDIP(10));
|
||||
content->AddSpacer(FromDIP(6));
|
||||
}
|
||||
|
||||
@@ -665,7 +698,7 @@ PublishSettingsDialog::PublishSettingsDialog(wxWindow* parent,
|
||||
};
|
||||
wxBoxSizer* links_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
links_sizer->Add(make_link(_L("Publish 3MF Wiki"), "https://www.orcaslicer.com/wiki/publishing_3mf/publish_3mf.html"), 0, wxALIGN_LEFT);
|
||||
links_sizer->Add(make_link(_L("Publish 3MF Video Guide"), "https://www.youtube.com/@OfficialOrcaSlicer/videos"), 0,
|
||||
links_sizer->Add(make_link(_L("Publish 3MF Video Guide"), "https://www.youtube.com/watch?v=-xt1N29UIOg"), 0,
|
||||
wxTOP | wxALIGN_LEFT, FromDIP(4));
|
||||
|
||||
wxBoxSizer* footer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
+34
-16
@@ -62,7 +62,7 @@ static char marker_by_type(Preset::Type type, PrinterTechnology pt)
|
||||
}
|
||||
}
|
||||
|
||||
std::string Option::opt_key() const { return into_u8(key).substr(2); }
|
||||
std::string Option::opt_key() const { return key.size() < 2 ? std::string() : into_u8(key).substr(2); }
|
||||
|
||||
void FoundOption::get_marked_label_and_tooltip(const char **label_, const char **tooltip_) const
|
||||
{
|
||||
@@ -116,6 +116,7 @@ void OptionsSearcher::append_options(DynamicPrintConfig *config, Preset::Type ty
|
||||
case coFloats: change_opt_key<ConfigOptionFloats>(opt_key, config, cnt); break;
|
||||
case coStrings: change_opt_key<ConfigOptionStrings>(opt_key, config, cnt); break;
|
||||
case coPercents: change_opt_key<ConfigOptionPercents>(opt_key, config, cnt); break;
|
||||
case coFloatsOrPercents: change_opt_key<ConfigOptionVector<FloatOrPercent>>(opt_key, config, cnt); break;
|
||||
case coPoints: change_opt_key<ConfigOptionPoints>(opt_key, config, cnt); break;
|
||||
// BBS
|
||||
case coEnums: change_opt_key<ConfigOptionInts>(opt_key, config, cnt); break;
|
||||
@@ -334,29 +335,46 @@ const Option &OptionsSearcher::get_option(size_t pos_in_filter) const
|
||||
|
||||
const Option &OptionsSearcher::get_option(const std::string &opt_key, Preset::Type type, int &variant_index) const
|
||||
{
|
||||
auto not_found = [&variant_index]() -> const Option& {
|
||||
static const Option empty_option;
|
||||
variant_index = -2;
|
||||
return empty_option;
|
||||
};
|
||||
|
||||
variant_index = -1;
|
||||
std::string opt_key2 = opt_key;
|
||||
if (auto n = opt_key.find('#'); n != std::string::npos) {
|
||||
variant_index = std::atoi(opt_key.c_str() + n + 1);
|
||||
opt_key2 = opt_key.substr(0, n);
|
||||
}
|
||||
auto it = std::lower_bound(options.begin(), options.end(), Option({boost::nowide::widen(get_key(opt_key2, type))}));
|
||||
// BBS: return the 0th option when not found in searcher caused by mode difference
|
||||
// assert(it != options.end());
|
||||
if (it == options.end()) { variant_index = -2 ; return options[0]; }
|
||||
if (it->opt_key() == opt_key2) {
|
||||
const std::wstring key = boost::nowide::widen(get_key(opt_key2, type));
|
||||
auto it = std::lower_bound(options.begin(), options.end(), Option({key}));
|
||||
if (it == options.end()) return not_found();
|
||||
if (it->key == key) {
|
||||
variant_index = -1;
|
||||
} else {
|
||||
const std::string opt_key3 = opt_key2 + "#";
|
||||
it = std::lower_bound(it, options.end(), Option({boost::nowide::widen(get_key(opt_key3, type))}));
|
||||
if (it == options.end() || it->opt_key().compare(0, opt_key3.length(), opt_key3) != 0) {
|
||||
variant_index = -2; // Not found
|
||||
return options[0];
|
||||
const std::wstring prefix = key + L"#";
|
||||
it = std::lower_bound(it, options.end(), Option({prefix}));
|
||||
if (it == options.end() || it->key.compare(0, prefix.length(), prefix) != 0)
|
||||
return not_found();
|
||||
// Orca: Copy-parameters dialogs request the base key, without a vector index.
|
||||
if (variant_index < 0) return *it;
|
||||
|
||||
const bool has_mode = type == Preset::TYPE_PRINTER && printer_options_with_variant_2.count(opt_key2) > 0;
|
||||
const bool has_variant =
|
||||
(type == Preset::TYPE_PRINT && print_options_with_variant.count(opt_key2) > 0) ||
|
||||
(type == Preset::TYPE_FILAMENT && filament_options_with_variant.count(opt_key2) > 0) ||
|
||||
(type == Preset::TYPE_PRINTER && printer_options_with_variant_1.count(opt_key2) > 0) || has_mode;
|
||||
if (!has_variant || has_mode) {
|
||||
// Orca: Machine limits store (Normal, Silent) pairs per variant; the UI registers only #0/#1.
|
||||
const std::wstring indexed_key = has_mode ? prefix + std::to_wstring(variant_index % 2) :
|
||||
boost::nowide::widen(get_key(opt_key, type));
|
||||
it = std::lower_bound(it, options.end(), Option({indexed_key}));
|
||||
if (it == options.end() || it->key != indexed_key)
|
||||
return not_found();
|
||||
if (!has_variant)
|
||||
variant_index = -1;
|
||||
}
|
||||
auto it2 = it;
|
||||
++it2;
|
||||
if (it2 != options.end() && it2->opt_key().compare(0, opt_key3.length(), opt_key3) == 0
|
||||
&& printer_options_with_variant_1.find(opt_key2) == printer_options_with_variant_1.end())
|
||||
variant_index = -2;
|
||||
}
|
||||
|
||||
return options[it - options.begin()];
|
||||
|
||||
@@ -1992,6 +1992,20 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
|
||||
// reload scene to update timelapse wipe tower
|
||||
if (opt_key == "timelapse_type") {
|
||||
// Smooth timelapse parks the nozzle on the prime tower every layer, so it needs a tower on
|
||||
// every layer. That is exactly what "No sparse layers" removes, and with both on the tower is
|
||||
// planned full height and then dropped on emission. Drop "No sparse layers" and tell the user.
|
||||
if (boost::any_cast<int>(value) == (int) TimelapseType::tlSmooth && m_config->opt_bool("wipe_tower_no_sparse_layers")) {
|
||||
MessageDialog dlg(wxGetApp().plater(),
|
||||
_L("Smooth timelapse needs a prime tower on every layer, which is not compatible with \"No sparse layers\". "
|
||||
"\"No sparse layers\" has been turned off."),
|
||||
_L("Warning"), wxICON_WARNING | wxOK);
|
||||
dlg.ShowModal();
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value("wipe_tower_no_sparse_layers", new ConfigOptionBool(false));
|
||||
m_config_manipulation.apply(m_config, &new_conf);
|
||||
}
|
||||
|
||||
bool wipe_tower_enabled = m_config->option<ConfigOptionBool>("enable_prime_tower")->value;
|
||||
if (!wipe_tower_enabled && boost::any_cast<int>(value) == (int)TimelapseType::tlSmooth) {
|
||||
MessageDialog dlg(wxGetApp().plater(), _L("A prime tower is required for smooth timelapse mode. There may be flaws on the model without prime tower. Do you want to enable the prime tower\?"),
|
||||
@@ -2007,6 +2021,23 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
}
|
||||
}
|
||||
|
||||
// Mirror of the timelapse_type branch above: enabling "No sparse layers" while smooth timelapse
|
||||
// is active would leave the tower on every layer anyway, so fall back to traditional timelapse.
|
||||
if (opt_key == "wipe_tower_no_sparse_layers" && boost::any_cast<bool>(value)) {
|
||||
auto timelapse_type = m_config->option<ConfigOptionEnum<TimelapseType>>("timelapse_type");
|
||||
if (timelapse_type && timelapse_type->value == TimelapseType::tlSmooth) {
|
||||
MessageDialog dlg(wxGetApp().plater(),
|
||||
_L("\"No sparse layers\" is not compatible with smooth timelapse, which needs a prime tower on every layer. "
|
||||
"Timelapse has been switched to traditional mode."),
|
||||
_L("Warning"), wxICON_WARNING | wxOK);
|
||||
dlg.ShowModal();
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(TimelapseType::tlTraditional));
|
||||
m_config_manipulation.apply(m_config, &new_conf);
|
||||
wxGetApp().plater()->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_key == "print_sequence" && m_config->opt_enum<PrintSequence>("print_sequence") == PrintSequence::ByObject) {
|
||||
auto printer_structure_opt = m_preset_bundle->printers.get_edited_preset().config.option<ConfigOptionEnum<PrinterStructure>>("printer_structure");
|
||||
if (printer_structure_opt && printer_structure_opt->value == PrinterStructure::psI3) {
|
||||
@@ -2669,6 +2700,8 @@ void TabPrint::build()
|
||||
optgroup->append_single_option_line("role_based_wipe_speed","quality_settings_seam#role-based-wipe-speed");
|
||||
optgroup->append_single_option_line("wipe_speed", "quality_settings_seam#wipe-speed");
|
||||
optgroup->append_single_option_line("wipe_on_loops","quality_settings_seam#wipe-on-loop-inward-movement");
|
||||
optgroup->append_single_option_line("wipe_inward", "quality_settings_seam#wipe-inward");
|
||||
optgroup->append_single_option_line("wipe_inward_distance", "quality_settings_seam#wipe-inward");
|
||||
optgroup->append_single_option_line("wipe_before_external_loop","quality_settings_seam#wipe-before-external");
|
||||
|
||||
|
||||
@@ -2761,6 +2794,7 @@ void TabPrint::build()
|
||||
|
||||
optgroup = page->new_optgroup(L("Overhangs"), L"param_overhang");
|
||||
optgroup->append_single_option_line("detect_overhang_wall", "quality_settings_overhangs#detect-overhang-wall");
|
||||
optgroup->append_single_option_line("unsupported_wall_last", "quality_settings_overhangs#unsupported-wall-last");
|
||||
optgroup->append_single_option_line("make_overhang_printable", "quality_settings_overhangs#make-overhang-printable");
|
||||
optgroup->append_single_option_line("make_overhang_printable_angle", "quality_settings_overhangs#maximum-angle");
|
||||
optgroup->append_single_option_line("make_overhang_printable_hole_size", "quality_settings_overhangs#hole-area");
|
||||
@@ -3024,6 +3058,8 @@ void TabPrint::build()
|
||||
optgroup = page->new_optgroup(L("Advanced"), L"advanced");
|
||||
optgroup->append_single_option_line("interlocking_beam", "multimaterial_settings_advanced#interlocking-beam");
|
||||
optgroup->append_single_option_line("toolchange_ordering", "multimaterial_settings_advanced#toolchange-ordering");
|
||||
optgroup->append_single_option_line("toolchange_cyclic_order", "multimaterial_settings_advanced#toolchange-order");
|
||||
optgroup->append_single_option_line("toolchange_cyclic_first_layer", "multimaterial_settings_advanced#toolchange-order");
|
||||
optgroup->append_single_option_line("interface_shells", "multimaterial_settings_advanced#interface-shells");
|
||||
optgroup->append_single_option_line("mmu_segmented_region_max_width", "multimaterial_settings_advanced#maximum-width-of-segmented-region");
|
||||
optgroup->append_single_option_line("mmu_segmented_region_interlocking_depth", "multimaterial_settings_advanced#interlocking-depth-of-segmented-region");
|
||||
@@ -5105,6 +5141,7 @@ void TabPrinter::build_fff()
|
||||
|
||||
optgroup = page->new_optgroup(L("Extruder Clearance"), "param_extruder_clearance");
|
||||
optgroup->append_single_option_line("extruder_clearance_radius", "printer_basic_information_extruder_clearance#radius");
|
||||
optgroup->append_single_option_line("extruder_clearance_dist_to_rod", "printer_basic_information_extruder_clearance#distance-to-rod");
|
||||
optgroup->append_single_option_line("extruder_clearance_height_to_rod", "printer_basic_information_extruder_clearance#height-to-rod");
|
||||
optgroup->append_single_option_line("extruder_clearance_height_to_lid", "printer_basic_information_extruder_clearance#height-to-lid");
|
||||
|
||||
|
||||
@@ -1490,7 +1490,15 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, DynamicConfig * config
|
||||
|
||||
for (const std::string &opt_key : config->keys()) {
|
||||
int variant_index = -2;
|
||||
const Search::Option &option = searcher.get_option(opt_key, type, variant_index);
|
||||
Search::Option option = searcher.get_option(opt_key, type, variant_index);
|
||||
if (variant_index == -2) {
|
||||
// Orca: Every transferred setting must remain visible even when it is absent from the search index.
|
||||
const ConfigOptionDef* def = print_config_def.get(opt_key);
|
||||
const std::string label = def ? (def->full_label.empty() ? def->label : def->full_label) : std::string();
|
||||
option.label_local = (label.empty() ? from_u8(opt_key) : _L(label)).ToStdWstring();
|
||||
option.category_local = (def && !def->category.empty() ?
|
||||
Tab::translate_category(from_u8(def->category), type) : _L("Others")).ToStdWstring();
|
||||
}
|
||||
auto category = option.category_local;
|
||||
auto opt = dynamic_cast<ConfigOptionVectorBase*>(config->option(opt_key));
|
||||
std::string value_from = opt->vserialize()[from];
|
||||
@@ -1518,6 +1526,8 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
||||
else
|
||||
presets_list.emplace_back(presets_);
|
||||
|
||||
const bool multiple_extruders = wxGetApp().preset_bundle->get_printer_extruder_count() > 1;
|
||||
|
||||
// Display a dialog showing the dirty options in a human readable form.
|
||||
for (PresetCollection* presets : presets_list)
|
||||
{
|
||||
@@ -1553,29 +1563,41 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
||||
|
||||
auto variant_key = Preset::get_iot_type_string(type) + "_extruder_variant";
|
||||
auto id_key = Preset::get_iot_type_string(type) + "_extruder_id";
|
||||
auto extruder_variant = dynamic_cast<ConfigOptionStrings const *>(old_config.option(variant_key));
|
||||
auto extruder_id = dynamic_cast<ConfigOptionInts const *>(old_config.option(id_key));
|
||||
// Orca: Dirty indices belong to the edited config, which may contain newly added variants.
|
||||
auto extruder_variant = dynamic_cast<ConfigOptionStrings const *>(new_config.option(variant_key));
|
||||
auto extruder_id = dynamic_cast<ConfigOptionInts const *>(new_config.option(id_key));
|
||||
|
||||
for (const std::string& opt_key : dirty_options) {
|
||||
int variant_index = -2;
|
||||
const Search::Option &option = searcher.get_option(opt_key, type, variant_index);
|
||||
if (option.opt_key() != opt_key && variant_index < -1) {
|
||||
if (variant_index == -2) {
|
||||
// When founded option isn't the correct one.
|
||||
// It can be for dirty_options: "default_print_profile", "printer_model", "printer_settings_id",
|
||||
// because of they don't exist in searcher
|
||||
continue;
|
||||
}
|
||||
auto category = option.category_local;
|
||||
if (variant_index >= 0) {
|
||||
if (printer_options_with_variant_2.count(opt_key.substr(0, opt_key.find_last_of('#'))) > 0)
|
||||
variant_index /= 2;
|
||||
if (boost::nowide::narrow(category).find("Extruder ") == 0)
|
||||
category = category.substr(0, 8);
|
||||
if (extruder_id)
|
||||
category = category + (wxString(" {") + (extruder_id->values[variant_index] == 1 ? _L("Left: ") : _L("Right: "))
|
||||
+ L(extruder_variant->values[variant_index]) + "}");
|
||||
else
|
||||
category = category + (wxString(" {") + L(extruder_variant->values[variant_index]) + "}");
|
||||
wxString category = option.category_local;
|
||||
wxString label = option.label_local;
|
||||
if (type == Preset::TYPE_PRINTER && variant_index >= 0 &&
|
||||
printer_options_with_variant_2.count(get_pure_opt_key(opt_key)) > 0) {
|
||||
// Orca: silent_mode is obsolete on import, but its option and two-column UI still exist.
|
||||
// Keep mode labels for configs that explicitly enable it; omit them in the default single-mode UI.
|
||||
if (new_config.opt_bool("silent_mode"))
|
||||
label += " (" + (variant_index % 2 == 0 ? _L("Normal") : _L("Silent")) + ")";
|
||||
variant_index /= 2;
|
||||
}
|
||||
if (variant_index >= 0 && extruder_variant && variant_index < extruder_variant->size()) {
|
||||
// Orca: Match the untranslated category and use the same extruder names as the printer tabs.
|
||||
if (option.category.compare(0, 9, L"Extruder ") == 0)
|
||||
category = _L("Extruder");
|
||||
wxString variant_label = L(extruder_variant->values[variant_index]);
|
||||
// Orca: An extruder name only disambiguates variants on printers with multiple extruders.
|
||||
if (multiple_extruders && extruder_id && variant_index < extruder_id->size() && extruder_id->values[variant_index] > 0) {
|
||||
const wxString extruder_name = Tab::translate_category(
|
||||
wxString::Format("Extruder %d", extruder_id->values[variant_index]), Preset::TYPE_PRINTER);
|
||||
variant_label = extruder_name + " (" + variant_label + ")";
|
||||
}
|
||||
category = variant_label + ": " + category;
|
||||
}
|
||||
|
||||
/*m_tree->Append(opt_key, type, option.category_local, option.group_local, option.label_local,
|
||||
@@ -1584,7 +1606,7 @@ void UnsavedChangesDialog::update_tree(Preset::Type type, PresetCollection* pres
|
||||
|
||||
//PresetItem pi = {opt_key, type, 1983};
|
||||
//m_presetitems.push_back()
|
||||
PresetItem pi = {type, opt_key, category, option.group_local, option.label_local, get_string_value(opt_key, old_config), get_string_value(opt_key, new_config)};
|
||||
PresetItem pi = {type, opt_key, category, option.group_local, label, get_string_value(opt_key, old_config), get_string_value(opt_key, new_config)};
|
||||
m_presetitems.push_back(pi);
|
||||
|
||||
}
|
||||
|
||||
@@ -275,9 +275,9 @@ void TempInput::Warning(bool warn, WarningType type)
|
||||
|
||||
wxString warning_string;
|
||||
if (type == WarningType::WARNING_TOO_HIGH)
|
||||
warning_string = _L("The maximum temperature cannot exceed ") + wxString::Format("%d", max_temp);
|
||||
warning_string = wxString::Format(_L("The maximum temperature cannot exceed %d"), max_temp);
|
||||
else if (type == WarningType::WARNING_TOO_LOW)
|
||||
warning_string = _L("The minmum temperature should not be less than ") + wxString::Format("%d", min_temp);
|
||||
warning_string = wxString::Format(_L("The minimum temperature should not be less than %d"), min_temp);
|
||||
warning_text->SetLabel(warning_string);
|
||||
warning_text->Wrap(-1);
|
||||
warning_text->Fit();
|
||||
|
||||
@@ -1096,6 +1096,7 @@ bool CalibUtils::calib_generic_PA(const CalibInfo &calib_info, wxString &error_m
|
||||
calib_pa_pattern(calib_info, model);
|
||||
|
||||
DynamicPrintConfig print_config = calib_info.print_prest->config;
|
||||
print_config.set_key_value("wipe_inward", new ConfigOptionBool(false));
|
||||
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
|
||||
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
|
||||
|
||||
@@ -1357,6 +1358,7 @@ void CalibUtils::calib_retraction(const CalibInfo &calib_info, wxString &error_m
|
||||
read_model_from_file(input_file, model);
|
||||
|
||||
DynamicPrintConfig print_config = calib_info.print_prest->config;
|
||||
print_config.set_key_value("wipe_inward", new ConfigOptionBool(false));
|
||||
DynamicPrintConfig filament_config = calib_info.filament_prest->config;
|
||||
DynamicPrintConfig printer_config = calib_info.printer_prest->config;
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#include "MeshInspect.hpp"
|
||||
|
||||
#include "libslic3r/LayOnFace.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <ostream>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace MeshInspect {
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
static json to_json(const Vec3d &v) { return json::array({ v.x(), v.y(), v.z() }); }
|
||||
|
||||
static json to_json(const BoundingBoxf3 &bb)
|
||||
{
|
||||
return { { "min", to_json(bb.min) }, { "max", to_json(bb.max) }, { "size", to_json(bb.size()) } };
|
||||
}
|
||||
|
||||
void inspect_to_json(const Model &model, const std::vector<std::string> &source_paths, std::ostream &out, size_t max_planes)
|
||||
{
|
||||
json objects = json::array();
|
||||
for (const ModelObject *mo : model.objects) {
|
||||
json obj = { { "name", mo->name },
|
||||
{ "triangle_count", mo->facets_count() },
|
||||
{ "instance_count", mo->instances.size() },
|
||||
{ "bbox_object", to_json(mo->raw_mesh_bounding_box()) } };
|
||||
if (!mo->instances.empty()) {
|
||||
const std::vector<LayOnFacePlane> planes = lay_on_face_planes(*mo, mo->instances.front()->get_matrix_no_offset());
|
||||
json planes_json = json::array();
|
||||
for (size_t i = 0; i < std::min(planes.size(), max_planes); ++i)
|
||||
planes_json.push_back({ { "normal", to_json(planes[i].normal) },
|
||||
{ "area_mm2", std::round(double(planes[i].area) * 1000.) / 1000. },
|
||||
{ "center", to_json(planes[i].center) } });
|
||||
obj["bbox_world"] = to_json(mo->instance_bounding_box(0));
|
||||
obj["instance_offset"] = to_json(mo->instances.front()->get_offset());
|
||||
obj["plane_count"] = planes.size();
|
||||
obj["planes"] = std::move(planes_json);
|
||||
}
|
||||
objects.push_back(std::move(obj));
|
||||
}
|
||||
|
||||
const json root = {
|
||||
{ "sources", source_paths },
|
||||
{ "note", "Lengths in mm. bbox_object and the plane normals and centers are in object coordinates: the parts as "
|
||||
"currently transformed, without the instance transformation. --ground-face-normal and "
|
||||
"--ground-face-point take values in these coordinates. area_mm2 uses instance 0's scale, "
|
||||
"bbox_world is instance 0 on the plate." },
|
||||
{ "objects", std::move(objects) },
|
||||
};
|
||||
// Object names and file paths are arbitrary bytes, and dump() throws on invalid UTF-8 by default.
|
||||
// Replace such sequences with U+FFFD so the output is always valid JSON.
|
||||
out << root.dump(2, ' ', false, json::error_handler_t::replace) << std::endl;
|
||||
}
|
||||
|
||||
} // namespace MeshInspect
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class Model;
|
||||
|
||||
namespace MeshInspect {
|
||||
|
||||
// Writes the --inspect-mesh JSON for `model` to `out`: per object its bounding boxes and the faces
|
||||
// it can be laid on, taken from lay_on_face_planes() so they are the faces the --ground-* options
|
||||
// choose from, in the frame those options take. At most `max_planes` faces are listed per object,
|
||||
// largest first. `source_paths` lists every input file; the CLI merges them into one model.
|
||||
void inspect_to_json(const Model &model, const std::vector<std::string> &source_paths, std::ostream &out, size_t max_planes = 8);
|
||||
|
||||
} // namespace MeshInspect
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,204 @@
|
||||
// PaintCLI.cpp — CLI paint-inspection primitives. See PaintCLI.hpp.
|
||||
#include "PaintCLI.hpp"
|
||||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
#include "libslic3r/TriangleSelector.hpp"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace PaintCLI {
|
||||
|
||||
namespace {
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
double its_surface_area(const indexed_triangle_set &its)
|
||||
{
|
||||
double total = 0.0;
|
||||
for (const stl_triangle_vertex_indices &t : its.indices) {
|
||||
const Vec3f &a = its.vertices[t(0)];
|
||||
const Vec3f &b = its.vertices[t(1)];
|
||||
const Vec3f &c = its.vertices[t(2)];
|
||||
total += 0.5 * (b - a).cross(c - a).norm();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// Bbox over triangle-referenced vertices only. get_facets_strict() returns
|
||||
// an itset with the full source vertex list — using bounding_box() on it
|
||||
// would report the whole mesh's bbox even when only a few facets are painted.
|
||||
BoundingBoxf3 its_referenced_bbox(const indexed_triangle_set &its)
|
||||
{
|
||||
BoundingBoxf3 bb;
|
||||
bool first = true;
|
||||
for (const stl_triangle_vertex_indices &t : its.indices) {
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
const Vec3d v = its.vertices[t(k)].cast<double>();
|
||||
if (first) { bb.min = bb.max = v; first = false; }
|
||||
else bb.merge(v);
|
||||
}
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
json vec3_to_json(const Vec3d &v)
|
||||
{
|
||||
return json::array({ v.x(), v.y(), v.z() });
|
||||
}
|
||||
|
||||
json bbox_to_json(const BoundingBoxf3 &bb)
|
||||
{
|
||||
return {
|
||||
{ "min", vec3_to_json(bb.min) },
|
||||
{ "max", vec3_to_json(bb.max) },
|
||||
{ "size", vec3_to_json(Vec3d(bb.max - bb.min)) },
|
||||
};
|
||||
}
|
||||
|
||||
// One (layer, state) row — empty ones are omitted at the caller level.
|
||||
json state_entry(const std::string &label, const indexed_triangle_set &its)
|
||||
{
|
||||
return {
|
||||
{ "state", label },
|
||||
{ "facets", its.indices.size() },
|
||||
{ "area_mm2", its_surface_area(its) },
|
||||
{ "bbox", bbox_to_json(its_referenced_bbox(its)) },
|
||||
};
|
||||
}
|
||||
|
||||
// Iterate the states relevant to one FacetsAnnotation kind, collecting
|
||||
// non-empty entries. Empty layer → {"empty": true}. `n_facets_out` is the
|
||||
// running total of painted facets — bumped for the summary.
|
||||
json inspect_layer(const ModelVolume &mv, const FacetsAnnotation &fa,
|
||||
const std::vector<std::pair<EnforcerBlockerType, std::string>> &states,
|
||||
size_t &n_facets_out)
|
||||
{
|
||||
if (fa.empty())
|
||||
return { { "empty", true } };
|
||||
|
||||
json entries = json::array();
|
||||
for (const auto &st : states) {
|
||||
if (!fa.has_facets(mv, st.first))
|
||||
continue;
|
||||
indexed_triangle_set its = fa.get_facets_strict(mv, st.first);
|
||||
if (its.indices.empty())
|
||||
continue;
|
||||
n_facets_out += its.indices.size();
|
||||
entries.push_back(state_entry(st.second, its));
|
||||
}
|
||||
return {
|
||||
{ "empty", entries.empty() },
|
||||
{ "states", std::move(entries) },
|
||||
};
|
||||
}
|
||||
|
||||
const std::vector<std::pair<EnforcerBlockerType, std::string>> &supports_states()
|
||||
{
|
||||
static const std::vector<std::pair<EnforcerBlockerType, std::string>> s = {
|
||||
{ EnforcerBlockerType::ENFORCER, "ENFORCER" },
|
||||
{ EnforcerBlockerType::BLOCKER, "BLOCKER" },
|
||||
};
|
||||
return s;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<EnforcerBlockerType, std::string>> &fuzzy_states()
|
||||
{
|
||||
// FUZZY_SKIN is an enum alias for ENFORCER; the layer is single-state.
|
||||
static const std::vector<std::pair<EnforcerBlockerType, std::string>> s = {
|
||||
{ EnforcerBlockerType::FUZZY_SKIN, "FUZZY_SKIN" },
|
||||
};
|
||||
return s;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<EnforcerBlockerType, std::string>> &mmu_states()
|
||||
{
|
||||
static std::vector<std::pair<EnforcerBlockerType, std::string>> s = []{
|
||||
std::vector<std::pair<EnforcerBlockerType, std::string>> v;
|
||||
for (int i = 1; i <= int(EnforcerBlockerType::ExtruderMax); ++i)
|
||||
v.emplace_back(EnforcerBlockerType(i), "extruder_" + std::to_string(i));
|
||||
return v;
|
||||
}();
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void inspect_to_json(const Model &model, const std::vector<std::string> &source_paths,
|
||||
std::ostream &out)
|
||||
{
|
||||
json root;
|
||||
root["sources"] = source_paths;
|
||||
root["frame"] = "mesh_local";
|
||||
root["note"] = "Coordinates are mesh-local (each volume's own frame). "
|
||||
"Paint gizmos operate in this frame.";
|
||||
|
||||
json objects = json::array();
|
||||
size_t total_objects = 0, total_volumes = 0, total_painted = 0, total_facets = 0;
|
||||
|
||||
for (size_t oi = 0; oi < model.objects.size(); ++oi) {
|
||||
const ModelObject *mo = model.objects[oi];
|
||||
if (!mo) continue;
|
||||
++total_objects;
|
||||
|
||||
json obj;
|
||||
obj["index"] = oi;
|
||||
obj["name"] = mo->name;
|
||||
|
||||
json volumes = json::array();
|
||||
for (size_t vi = 0; vi < mo->volumes.size(); ++vi) {
|
||||
const ModelVolume *mv = mo->volumes[vi];
|
||||
if (!mv) continue;
|
||||
++total_volumes;
|
||||
|
||||
const indexed_triangle_set &its = mv->mesh().its;
|
||||
json vol;
|
||||
vol["index"] = vi;
|
||||
vol["name"] = mv->name;
|
||||
vol["n_facets"] = its.indices.size();
|
||||
vol["is_model_part"] = mv->is_model_part();
|
||||
vol["bbox_mesh_local"] = bbox_to_json(bounding_box(its));
|
||||
|
||||
size_t vol_painted = 0;
|
||||
json paints;
|
||||
paints["supports"] = inspect_layer(*mv, mv->supported_facets,
|
||||
supports_states(), vol_painted);
|
||||
paints["seam"] = inspect_layer(*mv, mv->seam_facets,
|
||||
supports_states(), vol_painted);
|
||||
paints["mmu_segmentation"] = inspect_layer(*mv, mv->mmu_segmentation_facets,
|
||||
mmu_states(), vol_painted);
|
||||
paints["fuzzy_skin"] = inspect_layer(*mv, mv->fuzzy_skin_facets,
|
||||
fuzzy_states(), vol_painted);
|
||||
vol["paints"] = std::move(paints);
|
||||
vol["painted_facets_total"] = vol_painted;
|
||||
|
||||
if (vol_painted > 0) ++total_painted;
|
||||
total_facets += vol_painted;
|
||||
|
||||
volumes.push_back(std::move(vol));
|
||||
}
|
||||
obj["volumes"] = std::move(volumes);
|
||||
objects.push_back(std::move(obj));
|
||||
}
|
||||
root["objects"] = std::move(objects);
|
||||
root["summary"] = {
|
||||
{ "objects", total_objects },
|
||||
{ "volumes", total_volumes },
|
||||
{ "volumes_with_paint", total_painted },
|
||||
{ "painted_facets_total", total_facets },
|
||||
};
|
||||
|
||||
// Object names and file paths are arbitrary bytes, and dump() throws on invalid
|
||||
// UTF-8 by default. Replace such sequences with U+FFFD so the output is always
|
||||
// valid JSON rather than an exception out of the CLI.
|
||||
out << root.dump(2, ' ', false, json::error_handler_t::replace) << std::endl;
|
||||
}
|
||||
|
||||
} // namespace PaintCLI
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,31 @@
|
||||
// PaintCLI.hpp — CLI paint-inspection primitives.
|
||||
//
|
||||
// Backs the --inspect-paint CLI action. Reads the per-facet enforcer /
|
||||
// blocker / extruder / fuzzy-skin state that OrcaSlicer stores on every
|
||||
// ModelVolume (supports, seam, MMU color, fuzzy-skin) and emits a
|
||||
// structured JSON summary — facet count, surface area, and mesh-local
|
||||
// bounding box per state — so CI / scripted / AI tooling can reason
|
||||
// about existing paint on a .3mf without opening the GUI.
|
||||
//
|
||||
// Coordinates are mesh-local (each volume's own frame), matching the
|
||||
// frame that the paint gizmos operate in.
|
||||
#ifndef slic3r_PaintCLI_hpp_
|
||||
#define slic3r_PaintCLI_hpp_
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
class Model;
|
||||
|
||||
namespace PaintCLI {
|
||||
|
||||
// `source_paths` lists every input file; the CLI merges them into one Model.
|
||||
void inspect_to_json(const Model &model, const std::vector<std::string> &source_paths,
|
||||
std::ostream &out);
|
||||
|
||||
} // namespace PaintCLI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
@@ -1711,7 +1711,7 @@ void PresetUpdater::priv::check_new_vendors(const std::set<std::string>& system_
|
||||
GUI::wxGetApp().plater()->get_notification_manager()->push_notification(
|
||||
GUI::NotificationType::PresetUpdateFinished,
|
||||
GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel,
|
||||
_u8L("Configuration package: ") + vendor_id + _u8L(" updated to ") + cur_ver.to_string());
|
||||
Slic3r::format(_u8L("Configuration package: %1% updated to %2%"), vendor_id, cur_ver.to_string()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1806,7 +1806,7 @@ PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3
|
||||
->get_notification_manager()
|
||||
->push_notification(GUI::NotificationType::PresetUpdateFinished,
|
||||
GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel,
|
||||
_u8L("Configuration package: ") + b + _u8L(" updated to ") + cur_ver.to_string());
|
||||
Slic3r::format(_u8L("Configuration package: %1% updated to %2%"), b, cur_ver.to_string()));
|
||||
}
|
||||
return R_UPDATE_INSTALLED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user