mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Fixed conflicts after merge with master
This commit is contained in:
commit
cc0688678c
51 changed files with 7369 additions and 6120 deletions
|
@ -109,6 +109,7 @@ void fill_config(PConf& pcfg, const ArrangeParams ¶ms) {
|
|||
|
||||
// Apply penalty to object function result. This is used only when alignment
|
||||
// after arrange is explicitly disabled (PConfig::Alignment::DONT_ALIGN)
|
||||
// Also, this will only work well for Box shaped beds.
|
||||
static double fixed_overfit(const std::tuple<double, Box>& result, const Box &binbb)
|
||||
{
|
||||
double score = std::get<0>(result);
|
||||
|
@ -348,6 +349,17 @@ public:
|
|||
|
||||
m_pconf.object_function = get_objfn();
|
||||
|
||||
m_pconf.on_preload = [this](const ItemGroup &items, PConfig &cfg) {
|
||||
if (items.empty()) return;
|
||||
|
||||
cfg.alignment = PConfig::Alignment::DONT_ALIGN;
|
||||
auto bb = sl::boundingBox(m_bin);
|
||||
auto bbcenter = bb.center();
|
||||
cfg.object_function = [this, bb, bbcenter](const Item &item) {
|
||||
return fixed_overfit(objfunc(item, bbcenter), bb);
|
||||
};
|
||||
};
|
||||
|
||||
auto on_packed = params.on_packed;
|
||||
|
||||
if (progressind || on_packed)
|
||||
|
@ -383,22 +395,12 @@ public:
|
|||
PConfig& config() { return m_pconf; }
|
||||
const PConfig& config() const { return m_pconf; }
|
||||
|
||||
inline void preload(std::vector<Item>& fixeditems) {
|
||||
m_pconf.alignment = PConfig::Alignment::DONT_ALIGN;
|
||||
auto bb = sl::boundingBox(m_bin);
|
||||
auto bbcenter = bb.center();
|
||||
m_pconf.object_function = [this, bb, bbcenter](const Item &item) {
|
||||
return fixed_overfit(objfunc(item, bbcenter), bb);
|
||||
};
|
||||
|
||||
// Build the rtree for queries to work
|
||||
|
||||
inline void preload(std::vector<Item>& fixeditems) {
|
||||
for(unsigned idx = 0; idx < fixeditems.size(); ++idx) {
|
||||
Item& itm = fixeditems[idx];
|
||||
itm.markAsFixedInBin(itm.binId());
|
||||
}
|
||||
|
||||
m_pck.configure(m_pconf);
|
||||
m_item_count += fixeditems.size();
|
||||
}
|
||||
};
|
||||
|
@ -412,13 +414,10 @@ template<> std::function<double(const Item&)> AutoArranger<Box>::get_objfn()
|
|||
|
||||
double score = std::get<0>(result);
|
||||
auto& fullbb = std::get<1>(result);
|
||||
|
||||
auto bin = m_bin;
|
||||
sl::offset(bin, -EPSILON * (m_bin.width() + m_bin.height()));
|
||||
|
||||
double miss = Placer::overfit(fullbb, bin);
|
||||
double miss = Placer::overfit(fullbb, m_bin);
|
||||
miss = miss > 0? miss : 0;
|
||||
score += miss*miss;
|
||||
score += miss * miss;
|
||||
|
||||
return score;
|
||||
};
|
||||
|
@ -486,7 +485,7 @@ void _arrange(
|
|||
{
|
||||
// Integer ceiling the min distance from the bed perimeters
|
||||
coord_t md = params.min_obj_distance;
|
||||
md = (md % 2) ? md / 2 + 1 : md / 2;
|
||||
md = md / 2;
|
||||
|
||||
auto corrected_bin = bin;
|
||||
sl::offset(corrected_bin, md);
|
||||
|
@ -573,10 +572,13 @@ static void process_arrangeable(const ArrangePolygon &arrpoly,
|
|||
|
||||
clppr::Polygon clpath(Slic3rMultiPoint_to_ClipperPath(p));
|
||||
|
||||
if (!clpath.Contour.empty()) {
|
||||
auto firstp = clpath.Contour.front();
|
||||
clpath.Contour.emplace_back(firstp);
|
||||
}
|
||||
// This fixes:
|
||||
// https://github.com/prusa3d/PrusaSlicer/issues/2209
|
||||
if (clpath.Contour.size() < 3)
|
||||
return;
|
||||
|
||||
auto firstp = clpath.Contour.front();
|
||||
clpath.Contour.emplace_back(firstp);
|
||||
|
||||
outp.emplace_back(std::move(clpath));
|
||||
outp.back().rotation(rotation);
|
||||
|
|
|
@ -62,6 +62,15 @@ struct ArrangePolygon {
|
|||
|
||||
/// Test if arrange() was called previously and gave a successful result.
|
||||
bool is_arranged() const { return bed_idx != UNARRANGED; }
|
||||
|
||||
inline ExPolygon transformed_poly() const
|
||||
{
|
||||
ExPolygon ret = poly;
|
||||
ret.rotate(rotation);
|
||||
ret.translate(translation.x(), translation.y());
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
using ArrangePolygons = std::vector<ArrangePolygon>;
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
return point(0) >= this->min(0) && point(0) <= this->max(0)
|
||||
&& point(1) >= this->min(1) && point(1) <= this->max(1);
|
||||
}
|
||||
bool contains(const BoundingBoxBase<PointClass> &other) const {
|
||||
return contains(other.min) && contains(other.max);
|
||||
}
|
||||
bool overlap(const BoundingBoxBase<PointClass> &other) const {
|
||||
return ! (this->max(0) < other.min(0) || this->min(0) > other.max(0) ||
|
||||
this->max(1) < other.min(1) || this->min(1) > other.max(1));
|
||||
|
|
|
@ -20,7 +20,8 @@ SLIC3R_DERIVE_EXCEPTION(OutOfRange, LogicError);
|
|||
SLIC3R_DERIVE_EXCEPTION(IOError, CriticalException);
|
||||
SLIC3R_DERIVE_EXCEPTION(FileIOError, IOError);
|
||||
SLIC3R_DERIVE_EXCEPTION(HostNetworkError, IOError);
|
||||
SLIC3R_DERIVE_EXCEPTION(ExportError, CriticalException);
|
||||
SLIC3R_DERIVE_EXCEPTION(ExportError, CriticalException);
|
||||
SLIC3R_DERIVE_EXCEPTION(PlaceholderParserError, RuntimeError);
|
||||
// Runtime exception produced by Slicer. Such exception cancels the slicing process and it shall be shown in notifications.
|
||||
SLIC3R_DERIVE_EXCEPTION(SlicingError, Exception);
|
||||
#undef SLIC3R_DERIVE_EXCEPTION
|
||||
|
|
|
@ -748,15 +748,17 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* re
|
|||
|
||||
if (! m_placeholder_parser_failed_templates.empty()) {
|
||||
// G-code export proceeded, but some of the PlaceholderParser substitutions failed.
|
||||
//FIXME localize!
|
||||
std::string msg = std::string("G-code export to ") + path + " failed due to invalid custom G-code sections:\n\n";
|
||||
for (const std::string &name : m_placeholder_parser_failed_templates)
|
||||
msg += std::string("\t") + name + "\n";
|
||||
for (const auto &name_and_error : m_placeholder_parser_failed_templates)
|
||||
msg += name_and_error.first + "\n" + name_and_error.second + "\n";
|
||||
msg += "\nPlease inspect the file ";
|
||||
msg += path_tmp + " for error messages enclosed between\n";
|
||||
msg += " !!!!! Failed to process the custom G-code template ...\n";
|
||||
msg += "and\n";
|
||||
msg += " !!!!! End of an error report for the custom G-code template ...\n";
|
||||
throw Slic3r::RuntimeError(msg);
|
||||
msg += "for all macro processing errors.";
|
||||
throw Slic3r::PlaceholderParserError(msg);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(debug) << "Start processing gcode, " << log_memory_info();
|
||||
|
@ -1434,7 +1436,11 @@ std::string GCode::placeholder_parser_process(const std::string &name, const std
|
|||
return m_placeholder_parser.process(templ, current_extruder_id, config_override);
|
||||
} catch (std::runtime_error &err) {
|
||||
// Collect the names of failed template substitutions for error reporting.
|
||||
m_placeholder_parser_failed_templates.insert(name);
|
||||
auto it = m_placeholder_parser_failed_templates.find(name);
|
||||
if (it == m_placeholder_parser_failed_templates.end())
|
||||
// Only if there was no error reported for this template, store the first error message into the map to be reported.
|
||||
// We don't want to collect error message for each and every occurence of a single custom G-code section.
|
||||
m_placeholder_parser_failed_templates.insert(it, std::make_pair(name, std::string(err.what())));
|
||||
// Insert the macro error message into the G-code.
|
||||
return
|
||||
std::string("\n!!!!! Failed to process the custom G-code template ") + name + "\n" +
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "GCode/ThumbnailData.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#ifdef HAS_PRESSURE_EQUALIZER
|
||||
|
@ -323,7 +324,7 @@ private:
|
|||
GCodeWriter m_writer;
|
||||
PlaceholderParser m_placeholder_parser;
|
||||
// Collection of templates, on which the placeholder substitution failed.
|
||||
std::set<std::string> m_placeholder_parser_failed_templates;
|
||||
std::map<std::string, std::string> m_placeholder_parser_failed_templates;
|
||||
OozePrevention m_ooze_prevention;
|
||||
Wipe m_wipe;
|
||||
AvoidCrossingPerimeters m_avoid_crossing_perimeters;
|
||||
|
|
|
@ -266,8 +266,9 @@ inline bool liang_barsky_line_clipping(
|
|||
// Clipped successfully.
|
||||
x1 = x0 + interval.second * v;
|
||||
x0 += interval.first * v;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Based on Liang-Barsky function by Daniel White @ http://www.skytopia.com/project/articles/compsci/clipping.html
|
||||
|
|
|
@ -1273,6 +1273,10 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
|
|||
ModelVolume* volume = this->volumes.front();
|
||||
TriangleMeshPtrs meshptrs = volume->mesh().split();
|
||||
for (TriangleMesh *mesh : meshptrs) {
|
||||
|
||||
// FIXME: crashes if not satisfied
|
||||
if (mesh->facets_count() < 3) continue;
|
||||
|
||||
mesh->repair();
|
||||
|
||||
// XXX: this seems to be the only real usage of m_model, maybe refactor this so that it's not needed?
|
||||
|
@ -1846,7 +1850,7 @@ void ModelInstance::transform_polygon(Polygon* polygon) const
|
|||
|
||||
arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const
|
||||
{
|
||||
static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
||||
// static const double SIMPLIFY_TOLERANCE_MM = 0.1;
|
||||
|
||||
Vec3d rotation = get_rotation();
|
||||
rotation.z() = 0.;
|
||||
|
@ -1858,13 +1862,11 @@ arrangement::ArrangePolygon ModelInstance::get_arrange_polygon() const
|
|||
|
||||
assert(!p.points.empty());
|
||||
|
||||
// this may happen for malformed models, see:
|
||||
// https://github.com/prusa3d/PrusaSlicer/issues/2209
|
||||
if (!p.points.empty()) {
|
||||
Polygons pp{p};
|
||||
pp = p.simplify(scaled<double>(SIMPLIFY_TOLERANCE_MM));
|
||||
if (!pp.empty()) p = pp.front();
|
||||
}
|
||||
// if (!p.points.empty()) {
|
||||
// Polygons pp{p};
|
||||
// pp = p.simplify(scaled<double>(SIMPLIFY_TOLERANCE_MM));
|
||||
// if (!pp.empty()) p = pp.front();
|
||||
// }
|
||||
|
||||
arrangement::ArrangePolygon ret;
|
||||
ret.poly.contour = std::move(p);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <boost/nowide/convert.hpp>
|
||||
#ifdef _MSC_VER
|
||||
#include <stdlib.h> // provides **_environ
|
||||
#else
|
||||
|
@ -870,7 +871,9 @@ namespace client
|
|||
}
|
||||
}
|
||||
msg += '\n';
|
||||
msg += error_line;
|
||||
// This hack removes all non-UTF8 characters from the source line, so that the upstream wxWidgets conversions
|
||||
// from UTF8 to UTF16 don't bail out.
|
||||
msg += boost::nowide::narrow(boost::nowide::widen(error_line));
|
||||
msg += '\n';
|
||||
for (size_t i = 0; i < error_pos; ++ i)
|
||||
msg += ' ';
|
||||
|
@ -1304,7 +1307,7 @@ static std::string process_macro(const std::string &templ, client::MyContext &co
|
|||
if (!context.error_message.empty()) {
|
||||
if (context.error_message.back() != '\n' && context.error_message.back() != '\r')
|
||||
context.error_message += '\n';
|
||||
throw Slic3r::RuntimeError(context.error_message);
|
||||
throw Slic3r::PlaceholderParserError(context.error_message);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ public:
|
|||
const DynamicConfig* external_config() const { return m_external_config; }
|
||||
|
||||
// Fill in the template using a macro processing language.
|
||||
// Throws Slic3r::RuntimeError on syntax or runtime error.
|
||||
// Throws Slic3r::PlaceholderParserError on syntax or runtime error.
|
||||
std::string process(const std::string &templ, unsigned int current_extruder_id = 0, const DynamicConfig *config_override = nullptr) const;
|
||||
|
||||
// Evaluate a boolean expression using the full expressive power of the PlaceholderParser boolean expression syntax.
|
||||
// Throws Slic3r::RuntimeError on syntax or runtime error.
|
||||
// Throws Slic3r::PlaceholderParserError on syntax or runtime error.
|
||||
static bool evaluate_boolean_expression(const std::string &templ, const DynamicConfig &config, const DynamicConfig *config_override = nullptr);
|
||||
|
||||
// Update timestamp, year, month, day, hour, minute, second variables at the provided config.
|
||||
|
|
|
@ -69,7 +69,7 @@ std::string PrintBase::output_filename(const std::string &format, const std::str
|
|||
filename = boost::filesystem::change_extension(filename, default_ext);
|
||||
return filename.string();
|
||||
} catch (std::runtime_error &err) {
|
||||
throw Slic3r::RuntimeError(L("Failed processing of the output_filename_format template.") + "\n" + err.what());
|
||||
throw Slic3r::PlaceholderParserError(L("Failed processing of the output_filename_format template.") + "\n" + err.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,9 @@ void PrintConfigDef::init_common_params()
|
|||
def = this->add("print_host", coString);
|
||||
def->label = L("Hostname, IP or URL");
|
||||
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field should contain "
|
||||
"the hostname, IP address or URL of the printer host instance.");
|
||||
"the hostname, IP address or URL of the printer host instance. "
|
||||
"Print host behind HAProxy with basic auth enabled can be accessed by putting the user name and password into the URL "
|
||||
"in the following format: https://username:password@your-octopi-address/");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
|
||||
|
@ -159,8 +161,8 @@ void PrintConfigDef::init_common_params()
|
|||
def->enum_keys_map = &ConfigOptionEnum<AuthorizationType>::get_enum_values();
|
||||
def->enum_values.push_back("key");
|
||||
def->enum_values.push_back("user");
|
||||
def->enum_labels.push_back("API key");
|
||||
def->enum_labels.push_back("HTTP digest");
|
||||
def->enum_labels.push_back(L("API key"));
|
||||
def->enum_labels.push_back(L("HTTP digest"));
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionEnum<AuthorizationType>(atKeyPassword));
|
||||
}
|
||||
|
@ -534,7 +536,7 @@ void PrintConfigDef::init_fff_params()
|
|||
def->tooltip = L("The extruder to use (unless more specific extruder settings are specified). "
|
||||
"This value overrides perimeter and infill extruders, but not the support extruders.");
|
||||
def->min = 0; // 0 = inherit defaults
|
||||
def->enum_labels.push_back("default"); // override label for item 0
|
||||
def->enum_labels.push_back(L("default")); // override label for item 0
|
||||
def->enum_labels.push_back("1");
|
||||
def->enum_labels.push_back("2");
|
||||
def->enum_labels.push_back("3");
|
||||
|
@ -1207,9 +1209,9 @@ void PrintConfigDef::init_fff_params()
|
|||
def->enum_values.push_back("top");
|
||||
def->enum_values.push_back("topmost");
|
||||
def->enum_values.push_back("solid");
|
||||
def->enum_labels.push_back("All top surfaces");
|
||||
def->enum_labels.push_back("Topmost surface only");
|
||||
def->enum_labels.push_back("All solid surfaces");
|
||||
def->enum_labels.push_back(L("All top surfaces"));
|
||||
def->enum_labels.push_back(L("Topmost surface only"));
|
||||
def->enum_labels.push_back(L("All solid surfaces"));
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionEnum<IroningType>(IroningType::TopSurfaces));
|
||||
|
||||
|
|
|
@ -552,6 +552,7 @@ std::string encode_path(const char *src)
|
|||
}
|
||||
|
||||
// Encode an 8-bit string from a local code page to UTF-8.
|
||||
// Multibyte to utf8
|
||||
std::string decode_path(const char *src)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue