mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
Merge remote-tracking branch 'origin/master' into feature_arrange_with_libnest2d
This commit is contained in:
commit
230c681482
504 changed files with 199758 additions and 11973 deletions
|
@ -458,6 +458,19 @@ offset2_ex(const Polygons &polygons, const float delta1, const float delta2,
|
|||
return ClipperPaths_to_Slic3rExPolygons(output);
|
||||
}
|
||||
|
||||
//FIXME Vojtech: This functon may likely be optimized to avoid some of the Slic3r to Clipper
|
||||
// conversions and unnecessary Clipper calls.
|
||||
ExPolygons offset2_ex(const ExPolygons &expolygons, const float delta1,
|
||||
const float delta2, ClipperLib::JoinType joinType, double miterLimit)
|
||||
{
|
||||
Polygons polys;
|
||||
for (const ExPolygon &expoly : expolygons)
|
||||
append(polys,
|
||||
offset(offset_ex(expoly, delta1, joinType, miterLimit),
|
||||
delta2, joinType, miterLimit));
|
||||
return union_ex(polys);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T
|
||||
_clipper_do(const ClipperLib::ClipType clipType, const Polygons &subject,
|
||||
|
@ -650,8 +663,7 @@ union_pt_chained(const Polygons &subject, bool safety_offset_)
|
|||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval)
|
||||
void traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval)
|
||||
{
|
||||
/* use a nearest neighbor search to order these children
|
||||
TODO: supply start_near to chained_path() too? */
|
||||
|
@ -677,8 +689,7 @@ traverse_pt(ClipperLib::PolyNodes &nodes, Polygons* retval)
|
|||
}
|
||||
}
|
||||
|
||||
Polygons
|
||||
simplify_polygons(const Polygons &subject, bool preserve_collinear)
|
||||
Polygons simplify_polygons(const Polygons &subject, bool preserve_collinear)
|
||||
{
|
||||
// convert into Clipper polygons
|
||||
ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject);
|
||||
|
@ -698,13 +709,11 @@ simplify_polygons(const Polygons &subject, bool preserve_collinear)
|
|||
return ClipperPaths_to_Slic3rPolygons(output);
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
simplify_polygons_ex(const Polygons &subject, bool preserve_collinear)
|
||||
ExPolygons simplify_polygons_ex(const Polygons &subject, bool preserve_collinear)
|
||||
{
|
||||
if (!preserve_collinear) {
|
||||
return union_ex(simplify_polygons(subject, preserve_collinear));
|
||||
}
|
||||
|
||||
if (! preserve_collinear)
|
||||
return union_ex(simplify_polygons(subject, false));
|
||||
|
||||
// convert into Clipper polygons
|
||||
ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject);
|
||||
|
||||
|
|
|
@ -80,6 +80,9 @@ Slic3r::Polygons offset2(const Slic3r::Polygons &polygons, const float delta1,
|
|||
Slic3r::ExPolygons offset2_ex(const Slic3r::Polygons &polygons, const float delta1,
|
||||
const float delta2, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
|
||||
double miterLimit = 3);
|
||||
Slic3r::ExPolygons offset2_ex(const Slic3r::ExPolygons &expolygons, const float delta1,
|
||||
const float delta2, ClipperLib::JoinType joinType = ClipperLib::jtMiter,
|
||||
double miterLimit = 3);
|
||||
|
||||
Slic3r::Polygons _clipper(ClipperLib::ClipType clipType,
|
||||
const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, bool safety_offset_ = false);
|
||||
|
|
|
@ -644,12 +644,9 @@ public:
|
|||
bool deserialize(const std::string &str, bool append = false) override
|
||||
{
|
||||
UNUSED(append);
|
||||
std::istringstream iss(str);
|
||||
iss >> this->value.x;
|
||||
iss.ignore(std::numeric_limits<std::streamsize>::max(), ',');
|
||||
iss.ignore(std::numeric_limits<std::streamsize>::max(), 'x');
|
||||
iss >> this->value.y;
|
||||
return true;
|
||||
char dummy;
|
||||
return sscanf(str.data(), " %lf , %lf %c", &this->value.x, &this->value.y, &dummy) == 2 ||
|
||||
sscanf(str.data(), " %lf x %lf %c", &this->value.x, &this->value.y, &dummy) == 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -168,52 +168,42 @@ ExPolygon::overlaps(const ExPolygon &other) const
|
|||
return ! other.contour.points.empty() && this->contains_b(other.contour.points.front());
|
||||
}
|
||||
|
||||
void
|
||||
ExPolygon::simplify_p(double tolerance, Polygons* polygons) const
|
||||
void ExPolygon::simplify_p(double tolerance, Polygons* polygons) const
|
||||
{
|
||||
Polygons pp = this->simplify_p(tolerance);
|
||||
polygons->insert(polygons->end(), pp.begin(), pp.end());
|
||||
}
|
||||
|
||||
Polygons
|
||||
ExPolygon::simplify_p(double tolerance) const
|
||||
Polygons ExPolygon::simplify_p(double tolerance) const
|
||||
{
|
||||
Polygons pp;
|
||||
pp.reserve(this->holes.size() + 1);
|
||||
|
||||
// contour
|
||||
{
|
||||
Polygon p = this->contour;
|
||||
p.points.push_back(p.points.front());
|
||||
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
|
||||
p.points.pop_back();
|
||||
pp.push_back(p);
|
||||
pp.emplace_back(std::move(p));
|
||||
}
|
||||
|
||||
// holes
|
||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
||||
Polygon p = *it;
|
||||
for (Polygon p : this->holes) {
|
||||
p.points.push_back(p.points.front());
|
||||
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
|
||||
p.points.pop_back();
|
||||
pp.push_back(p);
|
||||
pp.emplace_back(std::move(p));
|
||||
}
|
||||
pp = simplify_polygons(pp);
|
||||
return pp;
|
||||
return simplify_polygons(pp);
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
ExPolygon::simplify(double tolerance) const
|
||||
ExPolygons ExPolygon::simplify(double tolerance) const
|
||||
{
|
||||
Polygons pp = this->simplify_p(tolerance);
|
||||
return union_ex(pp);
|
||||
return union_ex(this->simplify_p(tolerance));
|
||||
}
|
||||
|
||||
void
|
||||
ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const
|
||||
void ExPolygon::simplify(double tolerance, ExPolygons* expolygons) const
|
||||
{
|
||||
ExPolygons ep = this->simplify(tolerance);
|
||||
expolygons->insert(expolygons->end(), ep.begin(), ep.end());
|
||||
append(*expolygons, this->simplify(tolerance));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -42,14 +42,32 @@ namespace PrusaMultiMaterial {
|
|||
class Writer
|
||||
{
|
||||
public:
|
||||
Writer() :
|
||||
Writer(float layer_height, float line_width) :
|
||||
m_current_pos(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()),
|
||||
m_current_z(0.f),
|
||||
m_current_feedrate(0.f),
|
||||
m_layer_height(0.f),
|
||||
m_layer_height(layer_height),
|
||||
m_extrusion_flow(0.f),
|
||||
m_preview_suppressed(false),
|
||||
m_elapsed_time(0.f) {}
|
||||
m_elapsed_time(0.f),
|
||||
m_default_analyzer_line_width(line_width)
|
||||
{
|
||||
// adds tag for analyzer:
|
||||
char buf[64];
|
||||
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Height_Tag.c_str(), m_layer_height); // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
|
||||
m_gcode += buf;
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
m_gcode += buf;
|
||||
change_analyzer_line_width(line_width);
|
||||
}
|
||||
|
||||
Writer& change_analyzer_line_width(float line_width) {
|
||||
// adds tag for analyzer:
|
||||
char buf[64];
|
||||
sprintf(buf, ";%s%f\n", GCodeAnalyzer::Width_Tag.c_str(), line_width);
|
||||
m_gcode += buf;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Writer& set_initial_position(const WipeTower::xy &pos) {
|
||||
m_start_pos = WipeTower::xy(pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg);
|
||||
|
@ -62,9 +80,6 @@ public:
|
|||
Writer& set_z(float z)
|
||||
{ m_current_z = z; return *this; }
|
||||
|
||||
Writer& set_layer_height(float layer_height)
|
||||
{ m_layer_height = layer_height; return *this; }
|
||||
|
||||
Writer& set_extrusion_flow(float flow)
|
||||
{ m_extrusion_flow = flow; return *this; }
|
||||
|
||||
|
@ -80,8 +95,8 @@ public:
|
|||
// Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various
|
||||
// filament loading and cooling moves from normal extrusion moves. Therefore the writer
|
||||
// is asked to suppres output of some lines, which look like extrusions.
|
||||
Writer& suppress_preview() { m_preview_suppressed = true; return *this; }
|
||||
Writer& resume_preview() { m_preview_suppressed = false; return *this; }
|
||||
Writer& suppress_preview() { change_analyzer_line_width(0.f); m_preview_suppressed = true; return *this; }
|
||||
Writer& resume_preview() { change_analyzer_line_width(m_default_analyzer_line_width); m_preview_suppressed = false; return *this; }
|
||||
|
||||
Writer& feedrate(float f)
|
||||
{
|
||||
|
@ -126,11 +141,6 @@ public:
|
|||
m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool));
|
||||
}
|
||||
|
||||
// adds tag for analyzer
|
||||
char buf[64];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
m_gcode += buf;
|
||||
|
||||
m_gcode += "G1";
|
||||
if (rot.x != rotated_current_pos.x) {
|
||||
m_gcode += set_format_X(rot.x); // Transform current position back to wipe tower coordinates (was updated by set_format_X)
|
||||
|
@ -197,7 +207,7 @@ public:
|
|||
do {
|
||||
++i;
|
||||
if (i==4) i=0;
|
||||
extrude(corners[i]);
|
||||
extrude(corners[i], f);
|
||||
} while (i != index_of_closest);
|
||||
return (*this);
|
||||
}
|
||||
|
@ -390,6 +400,7 @@ private:
|
|||
float m_wipe_tower_depth = 0.f;
|
||||
float m_last_fan_speed = 0.f;
|
||||
int current_temp = -1;
|
||||
const float m_default_analyzer_line_width;
|
||||
|
||||
std::string
|
||||
set_format_X(float x)
|
||||
|
@ -479,10 +490,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
|||
const float prime_section_width = std::min(240.f / tools.size(), 60.f);
|
||||
box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 100.f);
|
||||
|
||||
PrusaMultiMaterial::Writer writer;
|
||||
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
|
||||
writer.set_extrusion_flow(m_extrusion_flow)
|
||||
.set_z(m_z_pos)
|
||||
.set_layer_height(m_layer_height)
|
||||
.set_initial_tool(m_current_tool)
|
||||
.append(";--------------------\n"
|
||||
"; CP PRIMING START\n")
|
||||
|
@ -568,10 +578,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
|
|||
(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width
|
||||
: m_wipe_tower_depth-m_perimeter_width));
|
||||
|
||||
PrusaMultiMaterial::Writer writer;
|
||||
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
|
||||
writer.set_extrusion_flow(m_extrusion_flow)
|
||||
.set_z(m_z_pos)
|
||||
.set_layer_height(m_layer_height)
|
||||
.set_initial_tool(m_current_tool)
|
||||
.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle)
|
||||
.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f))
|
||||
|
@ -640,10 +649,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo
|
|||
m_wipe_tower_width,
|
||||
m_wipe_tower_depth);
|
||||
|
||||
PrusaMultiMaterial::Writer writer;
|
||||
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
|
||||
writer.set_extrusion_flow(m_extrusion_flow * 1.1f)
|
||||
.set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
|
||||
.set_layer_height(m_layer_height)
|
||||
.set_initial_tool(m_current_tool)
|
||||
.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle)
|
||||
.append(";-------------------------------------\n"
|
||||
|
@ -697,11 +705,12 @@ void WipeTowerPrusaMM::toolchange_Unload(
|
|||
float xl = cleaning_box.ld.x + 1.f * m_perimeter_width;
|
||||
float xr = cleaning_box.rd.x - 1.f * m_perimeter_width;
|
||||
|
||||
writer.append("; CP TOOLCHANGE UNLOAD\n");
|
||||
|
||||
const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator; // desired ramming line thickness
|
||||
const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm
|
||||
|
||||
writer.append("; CP TOOLCHANGE UNLOAD\n")
|
||||
.change_analyzer_line_width(line_width);
|
||||
|
||||
unsigned i = 0; // iterates through ramming_speed
|
||||
m_left_to_right = true; // current direction of ramming
|
||||
float remaining = xr - xl ; // keeps track of distance to the next turnaround
|
||||
|
@ -775,12 +784,14 @@ void WipeTowerPrusaMM::toolchange_Unload(
|
|||
}
|
||||
}
|
||||
WipeTower::xy end_of_ramming(writer.x(),writer.y());
|
||||
writer.change_analyzer_line_width(m_perimeter_width); // so the next lines are not affected by ramming_line_width_multiplier
|
||||
|
||||
// Pull the filament end to the BEGINNING of the cooling tube while still moving the print head
|
||||
float oldx = writer.x();
|
||||
float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far
|
||||
float xdist = std::abs(oldx-turning_point);
|
||||
float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42);
|
||||
|
||||
writer.suppress_preview()
|
||||
.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ) // fixed speed after ramming
|
||||
.load_move_x(oldx ,edist , 60.f * std::hypot(xdist,edist)/std::abs(edist) * m_filpar[m_current_tool].unloading_speed )
|
||||
|
@ -959,10 +970,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer()
|
|||
// Otherwise the caller would likely travel to the wipe tower in vain.
|
||||
assert(! this->layer_finished());
|
||||
|
||||
PrusaMultiMaterial::Writer writer;
|
||||
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
|
||||
writer.set_extrusion_flow(m_extrusion_flow)
|
||||
.set_z(m_z_pos)
|
||||
.set_layer_height(m_layer_height)
|
||||
.set_initial_tool(m_current_tool)
|
||||
.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle)
|
||||
.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f))
|
||||
|
@ -1137,7 +1147,8 @@ void WipeTowerPrusaMM::save_on_last_wipe()
|
|||
// Resulting ToolChangeResults are appended into vector "result"
|
||||
void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result)
|
||||
{
|
||||
if (m_plan.empty()) return;
|
||||
if (m_plan.empty())
|
||||
return;
|
||||
|
||||
m_extra_spacing = 1.f;
|
||||
|
||||
|
@ -1151,8 +1162,9 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes
|
|||
make_wipe_tower_square();
|
||||
|
||||
m_layer_info = m_plan.begin();
|
||||
m_current_tool = (unsigned int)(-2); // we don't know which extruder to start with - we'll set it according to the first toolchange
|
||||
|
||||
std::vector<WipeTower::ToolChangeResult> layer_result;
|
||||
std::vector<WipeTower::ToolChangeResult> layer_result;
|
||||
for (auto layer : m_plan)
|
||||
{
|
||||
set_layer(layer.z,layer.height,0,layer.z == m_plan.front().z,layer.z == m_plan.back().z);
|
||||
|
@ -1166,8 +1178,11 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes
|
|||
if (!m_peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width)
|
||||
m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f;
|
||||
|
||||
for (const auto &toolchange : layer.tool_changes)
|
||||
for (const auto &toolchange : layer.tool_changes) {
|
||||
if (m_current_tool == (unsigned int)(-2))
|
||||
m_current_tool = toolchange.old_tool;
|
||||
layer_result.emplace_back(tool_change(toolchange.new_tool, false));
|
||||
}
|
||||
|
||||
if (! layer_finished()) {
|
||||
auto finish_layer_toolchange = finish_layer();
|
||||
|
|
|
@ -229,7 +229,7 @@ private:
|
|||
bool m_print_brim = true;
|
||||
// A fill-in direction (positive Y, negative Y) alternates with each layer.
|
||||
wipe_shape m_current_shape = SHAPE_NORMAL;
|
||||
unsigned int m_current_tool = 0;
|
||||
unsigned int m_current_tool;
|
||||
std::vector<std::vector<float>> wipe_volumes;
|
||||
|
||||
float m_depth_traversed = 0.f; // Current y position at the wipe tower.
|
||||
|
|
|
@ -41,6 +41,7 @@ struct termios2 {
|
|||
|
||||
//#define DEBUG_SERIAL
|
||||
#ifdef DEBUG_SERIAL
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
std::fstream fs;
|
||||
#endif
|
||||
|
@ -52,7 +53,11 @@ namespace Slic3r {
|
|||
GCodeSender::GCodeSender()
|
||||
: io(), serial(io), can_send(false), sent(0), open(false), error(false),
|
||||
connected(false), queue_paused(false)
|
||||
{}
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
std::srand(std::time(nullptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
GCodeSender::~GCodeSender()
|
||||
{
|
||||
|
@ -358,15 +363,23 @@ GCodeSender::on_read(const boost::system::error_code& error,
|
|||
// extract the first number from line
|
||||
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
|
||||
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
|
||||
++ toresend; // N is 0-based
|
||||
if (toresend >= this->sent - this->last_sent.size() && toresend < this->last_sent.size()) {
|
||||
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "!! line num out of sync: toresend = " << toresend << ", sent = " << sent << ", last_sent.size = " << last_sent.size() << std::endl;
|
||||
#endif
|
||||
|
||||
if (toresend > this->sent - this->last_sent.size() && toresend <= this->sent) {
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||
|
||||
const auto lines_to_resend = this->sent - toresend + 1;
|
||||
#ifdef DEBUG_SERIAL
|
||||
fs << "!! resending " << lines_to_resend << " lines" << std::endl;
|
||||
#endif
|
||||
// move the unsent lines to priqueue
|
||||
this->priqueue.insert(
|
||||
this->priqueue.begin(), // insert at the beginning
|
||||
this->last_sent.begin() + toresend - (this->sent - this->last_sent.size()) - 1,
|
||||
this->last_sent.begin() + this->last_sent.size() - lines_to_resend,
|
||||
this->last_sent.end()
|
||||
);
|
||||
|
||||
|
@ -477,8 +490,14 @@ GCodeSender::do_send()
|
|||
if (line.empty()) return;
|
||||
|
||||
// compute full line
|
||||
std::string full_line = "N" + boost::lexical_cast<std::string>(this->sent) + " " + line;
|
||||
++ this->sent;
|
||||
#ifndef DEBUG_SERIAL
|
||||
const auto line_num = this->sent;
|
||||
#else
|
||||
// In DEBUG_SERIAL mode, test line re-synchronization by sending bad line number 1/4 of the time
|
||||
const auto line_num = std::rand() < RAND_MAX/4 ? 0 : this->sent;
|
||||
#endif
|
||||
std::string full_line = "N" + boost::lexical_cast<std::string>(line_num) + " " + line;
|
||||
|
||||
// calculate checksum
|
||||
int cs = 0;
|
||||
|
@ -497,8 +516,9 @@ GCodeSender::do_send()
|
|||
this->last_sent.push_back(line);
|
||||
this->can_send = false;
|
||||
|
||||
if (this->last_sent.size() > KEEP_SENT)
|
||||
this->last_sent.erase(this->last_sent.begin(), this->last_sent.end() - KEEP_SENT);
|
||||
while (this->last_sent.size() > KEEP_SENT) {
|
||||
this->last_sent.pop_front();
|
||||
}
|
||||
|
||||
// we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the
|
||||
// stack and the buffer would lose its underlying storage causing memory corruption
|
||||
|
|
|
@ -51,7 +51,7 @@ class GCodeSender : private boost::noncopyable {
|
|||
bool can_send;
|
||||
bool queue_paused;
|
||||
size_t sent;
|
||||
std::vector<std::string> last_sent;
|
||||
std::deque<std::string> last_sent;
|
||||
|
||||
// this mutex guards log, T, B
|
||||
mutable boost::mutex log_mutex;
|
||||
|
|
|
@ -685,36 +685,6 @@ void Model::adjust_min_z()
|
|||
}
|
||||
}
|
||||
|
||||
bool Model::fits_print_volume(const DynamicPrintConfig* config) const
|
||||
{
|
||||
if (config == nullptr)
|
||||
return false;
|
||||
|
||||
if (objects.empty())
|
||||
return true;
|
||||
|
||||
const ConfigOptionPoints* opt = dynamic_cast<const ConfigOptionPoints*>(config->option("bed_shape"));
|
||||
if (opt == nullptr)
|
||||
return false;
|
||||
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values));
|
||||
BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config->opt_float("max_print_height")));
|
||||
// Allow the objects to protrude below the print bed
|
||||
print_volume.min.z = -1e10;
|
||||
return print_volume.contains(transformed_bounding_box());
|
||||
}
|
||||
|
||||
bool Model::fits_print_volume(const FullPrintConfig &config) const
|
||||
{
|
||||
if (objects.empty())
|
||||
return true;
|
||||
BoundingBox bed_box_2D = get_extents(Polygon::new_scale(config.bed_shape.values));
|
||||
BoundingBoxf3 print_volume(Pointf3(unscale(bed_box_2D.min.x), unscale(bed_box_2D.min.y), 0.0), Pointf3(unscale(bed_box_2D.max.x), unscale(bed_box_2D.max.y), config.max_print_height));
|
||||
// Allow the objects to protrude below the print bed
|
||||
print_volume.min.z = -1e10;
|
||||
return print_volume.contains(transformed_bounding_box());
|
||||
}
|
||||
|
||||
unsigned int Model::get_auto_extruder_id(unsigned int max_extruders)
|
||||
{
|
||||
unsigned int id = s_auto_extruder_id;
|
||||
|
|
|
@ -285,10 +285,6 @@ public:
|
|||
// Ensures that the min z of the model is not negative
|
||||
void adjust_min_z();
|
||||
|
||||
// Returs true if this model is contained into the print volume defined inside the given config
|
||||
bool fits_print_volume(const DynamicPrintConfig* config) const;
|
||||
bool fits_print_volume(const FullPrintConfig &config) const;
|
||||
|
||||
void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); }
|
||||
|
||||
static unsigned int get_auto_extruder_id(unsigned int max_extruders);
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
void
|
||||
PerimeterGenerator::process()
|
||||
void PerimeterGenerator::process()
|
||||
{
|
||||
// other perimeters
|
||||
this->_mm3_per_mm = this->perimeter_flow.mm3_per_mm();
|
||||
|
@ -45,7 +44,6 @@ PerimeterGenerator::process()
|
|||
// lower layer, so we take lower slices and offset them by half the nozzle diameter used
|
||||
// in the current layer
|
||||
double nozzle_diameter = this->print_config->nozzle_diameter.get_at(this->config->perimeter_extruder-1);
|
||||
|
||||
this->_lower_slices_p = offset(*this->lower_slices, float(scale_(+nozzle_diameter/2)));
|
||||
}
|
||||
|
||||
|
@ -53,149 +51,115 @@ PerimeterGenerator::process()
|
|||
// extra perimeters for each one
|
||||
for (const Surface &surface : this->slices->surfaces) {
|
||||
// detect how many perimeters must be generated for this island
|
||||
const int loop_number = this->config->perimeters + surface.extra_perimeters -1; // 0-indexed loops
|
||||
|
||||
Polygons gaps;
|
||||
|
||||
Polygons last = surface.expolygon.simplify_p(SCALED_RESOLUTION);
|
||||
if (loop_number >= 0) { // no loops = -1
|
||||
|
||||
int loop_number = this->config->perimeters + surface.extra_perimeters - 1; // 0-indexed loops
|
||||
ExPolygons last = union_ex(surface.expolygon.simplify_p(SCALED_RESOLUTION));
|
||||
ExPolygons gaps;
|
||||
if (loop_number >= 0) {
|
||||
// In case no perimeters are to be generated, loop_number will equal to -1.
|
||||
std::vector<PerimeterGeneratorLoops> contours(loop_number+1); // depth => loops
|
||||
std::vector<PerimeterGeneratorLoops> holes(loop_number+1); // depth => loops
|
||||
ThickPolylines thin_walls;
|
||||
|
||||
// we loop one time more than needed in order to find gaps after the last perimeter was applied
|
||||
for (int i = 0; i <= loop_number+1; ++i) { // outer loop is 0
|
||||
Polygons offsets;
|
||||
for (int i = 0;; ++ i) { // outer loop is 0
|
||||
// Calculate next onion shell of perimeters.
|
||||
ExPolygons offsets;
|
||||
if (i == 0) {
|
||||
// the minimum thickness of a single loop is:
|
||||
// ext_width/2 + ext_spacing/2 + spacing/2 + width/2
|
||||
if (this->config->thin_walls) {
|
||||
offsets = offset2(
|
||||
offsets = this->config->thin_walls ?
|
||||
offset2_ex(
|
||||
last,
|
||||
-(ext_perimeter_width / 2 + ext_min_spacing / 2 - 1),
|
||||
+(ext_min_spacing/2 - 1)
|
||||
);
|
||||
} else {
|
||||
offsets = offset(last, - ext_perimeter_width / 2);
|
||||
}
|
||||
|
||||
+(ext_min_spacing / 2 - 1)) :
|
||||
offset_ex(last, - ext_perimeter_width / 2);
|
||||
// look for thin walls
|
||||
if (this->config->thin_walls) {
|
||||
Polygons diffpp = diff(
|
||||
last,
|
||||
offset(offsets, ext_perimeter_width / 2),
|
||||
true // medial axis requires non-overlapping geometry
|
||||
);
|
||||
|
||||
// the following offset2 ensures almost nothing in @thin_walls is narrower than $min_width
|
||||
// (actually, something larger than that still may exist due to mitering or other causes)
|
||||
coord_t min_width = scale_(this->ext_perimeter_flow.nozzle_diameter / 3);
|
||||
ExPolygons expp = offset2_ex(diffpp, -min_width/2, +min_width/2);
|
||||
|
||||
ExPolygons expp = offset2_ex(
|
||||
// medial axis requires non-overlapping geometry
|
||||
diff_ex(to_polygons(last),
|
||||
offset(offsets, ext_perimeter_width / 2),
|
||||
true),
|
||||
- min_width / 2, min_width / 2);
|
||||
// the maximum thickness of our thin wall area is equal to the minimum thickness of a single loop
|
||||
for (ExPolygons::const_iterator ex = expp.begin(); ex != expp.end(); ++ex)
|
||||
ex->medial_axis(ext_perimeter_width + ext_perimeter_spacing2, min_width, &thin_walls);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf(" " PRINTF_ZU " thin walls detected\n", thin_walls.size());
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (false) {
|
||||
require "Slic3r/SVG.pm";
|
||||
Slic3r::SVG::output(
|
||||
"medial_axis.svg",
|
||||
no_arrows => 1,
|
||||
#expolygons => \@expp,
|
||||
polylines => \@thin_walls,
|
||||
);
|
||||
}
|
||||
*/
|
||||
for (ExPolygon &ex : expp)
|
||||
ex.medial_axis(ext_perimeter_width + ext_perimeter_spacing2, min_width, &thin_walls);
|
||||
}
|
||||
} else {
|
||||
//FIXME Is this offset correct if the line width of the inner perimeters differs
|
||||
// from the line width of the infill?
|
||||
coord_t distance = (i == 1) ? ext_perimeter_spacing2 : perimeter_spacing;
|
||||
|
||||
if (this->config->thin_walls) {
|
||||
offsets = this->config->thin_walls ?
|
||||
// This path will ensure, that the perimeters do not overfill, as in
|
||||
// prusa3d/Slic3r GH #32, but with the cost of rounding the perimeters
|
||||
// excessively, creating gaps, which then need to be filled in by the not very
|
||||
// reliable gap fill algorithm.
|
||||
// Also the offset2(perimeter, -x, x) may sometimes lead to a perimeter, which is larger than
|
||||
// the original.
|
||||
offsets = offset2(
|
||||
last,
|
||||
-(distance + min_spacing/2 - 1),
|
||||
+(min_spacing/2 - 1)
|
||||
);
|
||||
} else {
|
||||
offset2_ex(last,
|
||||
- (distance + min_spacing / 2 - 1),
|
||||
min_spacing / 2 - 1) :
|
||||
// If "detect thin walls" is not enabled, this paths will be entered, which
|
||||
// leads to overflows, as in prusa3d/Slic3r GH #32
|
||||
offsets = offset(
|
||||
last,
|
||||
-distance
|
||||
);
|
||||
}
|
||||
|
||||
offset_ex(last, - distance);
|
||||
// look for gaps
|
||||
if (this->config->gap_fill_speed.value > 0 && this->config->fill_density.value > 0) {
|
||||
if (this->config->gap_fill_speed.value > 0 && this->config->fill_density.value > 0)
|
||||
// not using safety offset here would "detect" very narrow gaps
|
||||
// (but still long enough to escape the area threshold) that gap fill
|
||||
// won't be able to fill but we'd still remove from infill area
|
||||
Polygons diff_pp = diff(
|
||||
offset(last, -0.5*distance),
|
||||
offset(offsets, +0.5*distance + 10) // safety offset
|
||||
);
|
||||
gaps.insert(gaps.end(), diff_pp.begin(), diff_pp.end());
|
||||
}
|
||||
}
|
||||
|
||||
if (offsets.empty()) break;
|
||||
if (i > loop_number) break; // we were only looking for gaps this time
|
||||
|
||||
last = offsets;
|
||||
for (Polygons::const_iterator polygon = offsets.begin(); polygon != offsets.end(); ++polygon) {
|
||||
PerimeterGeneratorLoop loop(*polygon, i);
|
||||
loop.is_contour = polygon->is_counter_clockwise();
|
||||
if (loop.is_contour) {
|
||||
contours[i].push_back(loop);
|
||||
} else {
|
||||
holes[i].push_back(loop);
|
||||
append(gaps, diff_ex(
|
||||
offset(last, -0.5 * distance),
|
||||
offset(offsets, 0.5 * distance + 10))); // safety offset
|
||||
}
|
||||
if (offsets.empty()) {
|
||||
// Store the number of loops actually generated.
|
||||
loop_number = i - 1;
|
||||
// No region left to be filled in.
|
||||
last.clear();
|
||||
break;
|
||||
} else if (i > loop_number) {
|
||||
// If i > loop_number, we were looking just for gaps.
|
||||
break;
|
||||
}
|
||||
for (const ExPolygon &expolygon : offsets) {
|
||||
contours[i].emplace_back(PerimeterGeneratorLoop(expolygon.contour, i, true));
|
||||
if (! expolygon.holes.empty()) {
|
||||
holes[i].reserve(holes[i].size() + expolygon.holes.size());
|
||||
for (const Polygon &hole : expolygon.holes)
|
||||
holes[i].emplace_back(PerimeterGeneratorLoop(hole, i, false));
|
||||
}
|
||||
}
|
||||
last = std::move(offsets);
|
||||
}
|
||||
|
||||
|
||||
// nest loops: holes first
|
||||
for (int d = 0; d <= loop_number; ++d) {
|
||||
for (int d = 0; d <= loop_number; ++ d) {
|
||||
PerimeterGeneratorLoops &holes_d = holes[d];
|
||||
|
||||
// loop through all holes having depth == d
|
||||
for (int i = 0; i < (int)holes_d.size(); ++i) {
|
||||
for (int i = 0; i < (int)holes_d.size(); ++ i) {
|
||||
const PerimeterGeneratorLoop &loop = holes_d[i];
|
||||
|
||||
// find the hole loop that contains this one, if any
|
||||
for (int t = d+1; t <= loop_number; ++t) {
|
||||
for (int j = 0; j < (int)holes[t].size(); ++j) {
|
||||
for (int t = d + 1; t <= loop_number; ++ t) {
|
||||
for (int j = 0; j < (int)holes[t].size(); ++ j) {
|
||||
PerimeterGeneratorLoop &candidate_parent = holes[t][j];
|
||||
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
|
||||
candidate_parent.children.push_back(loop);
|
||||
holes_d.erase(holes_d.begin() + i);
|
||||
--i;
|
||||
-- i;
|
||||
goto NEXT_LOOP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no hole contains this hole, find the contour loop that contains it
|
||||
for (int t = loop_number; t >= 0; --t) {
|
||||
for (int j = 0; j < (int)contours[t].size(); ++j) {
|
||||
for (int t = loop_number; t >= 0; -- t) {
|
||||
for (int j = 0; j < (int)contours[t].size(); ++ j) {
|
||||
PerimeterGeneratorLoop &candidate_parent = contours[t][j];
|
||||
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
|
||||
candidate_parent.children.push_back(loop);
|
||||
holes_d.erase(holes_d.begin() + i);
|
||||
--i;
|
||||
-- i;
|
||||
goto NEXT_LOOP;
|
||||
}
|
||||
}
|
||||
|
@ -203,75 +167,57 @@ PerimeterGenerator::process()
|
|||
NEXT_LOOP: ;
|
||||
}
|
||||
}
|
||||
|
||||
// nest contour loops
|
||||
for (int d = loop_number; d >= 1; --d) {
|
||||
for (int d = loop_number; d >= 1; -- d) {
|
||||
PerimeterGeneratorLoops &contours_d = contours[d];
|
||||
|
||||
// loop through all contours having depth == d
|
||||
for (int i = 0; i < (int)contours_d.size(); ++i) {
|
||||
for (int i = 0; i < (int)contours_d.size(); ++ i) {
|
||||
const PerimeterGeneratorLoop &loop = contours_d[i];
|
||||
|
||||
// find the contour loop that contains it
|
||||
for (int t = d-1; t >= 0; --t) {
|
||||
for (int j = 0; j < contours[t].size(); ++j) {
|
||||
for (int t = d - 1; t >= 0; -- t) {
|
||||
for (int j = 0; j < contours[t].size(); ++ j) {
|
||||
PerimeterGeneratorLoop &candidate_parent = contours[t][j];
|
||||
if (candidate_parent.polygon.contains(loop.polygon.first_point())) {
|
||||
candidate_parent.children.push_back(loop);
|
||||
contours_d.erase(contours_d.begin() + i);
|
||||
--i;
|
||||
-- i;
|
||||
goto NEXT_CONTOUR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NEXT_CONTOUR: ;
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, all loops should be in contours[0]
|
||||
|
||||
ExtrusionEntityCollection entities = this->_traverse_loops(contours.front(), thin_walls);
|
||||
|
||||
// if brim will be printed, reverse the order of perimeters so that
|
||||
// we continue inwards after having finished the brim
|
||||
// TODO: add test for perimeter order
|
||||
if (this->config->external_perimeters_first
|
||||
|| (this->layer_id == 0 && this->print_config->brim_width.value > 0))
|
||||
entities.reverse();
|
||||
|
||||
if (this->config->external_perimeters_first ||
|
||||
(this->layer_id == 0 && this->print_config->brim_width.value > 0))
|
||||
entities.reverse();
|
||||
// append perimeters for this slice as a collection
|
||||
if (!entities.empty())
|
||||
if (! entities.empty())
|
||||
this->loops->append(entities);
|
||||
} // for each loop of an island
|
||||
|
||||
// fill gaps
|
||||
if (!gaps.empty()) {
|
||||
/*
|
||||
SVG svg("gaps.svg");
|
||||
svg.draw(union_ex(gaps));
|
||||
svg.Close();
|
||||
*/
|
||||
|
||||
if (! gaps.empty()) {
|
||||
// collapse
|
||||
double min = 0.2 * perimeter_width * (1 - INSET_OVERLAP_TOLERANCE);
|
||||
double max = 2. * perimeter_spacing;
|
||||
ExPolygons gaps_ex = diff_ex(
|
||||
offset2(gaps, -min/2, +min/2),
|
||||
offset2(gaps, -max/2, +max/2),
|
||||
true
|
||||
);
|
||||
|
||||
//FIXME offset2 would be enough and cheaper.
|
||||
offset2_ex(gaps, -min/2, +min/2),
|
||||
offset2_ex(gaps, -max/2, +max/2),
|
||||
true);
|
||||
ThickPolylines polylines;
|
||||
for (ExPolygons::const_iterator ex = gaps_ex.begin(); ex != gaps_ex.end(); ++ex)
|
||||
ex->medial_axis(max, min, &polylines);
|
||||
|
||||
if (!polylines.empty()) {
|
||||
for (const ExPolygon &ex : gaps_ex)
|
||||
ex.medial_axis(max, min, &polylines);
|
||||
if (! polylines.empty()) {
|
||||
ExtrusionEntityCollection gap_fill = this->_variable_width(polylines,
|
||||
erGapFill, this->solid_infill_flow);
|
||||
|
||||
this->gap_fill->append(gap_fill.entities);
|
||||
|
||||
/* Make sure we don't infill narrow parts that are already gap-filled
|
||||
(we only consider this surface's gaps to reduce the diff() complexity).
|
||||
Growing actual extrusions ensures that gaps not filled by medial axis
|
||||
|
@ -280,7 +226,7 @@ PerimeterGenerator::process()
|
|||
and use zigzag). */
|
||||
//FIXME Vojtech: This grows by a rounded extrusion width, not by line spacing,
|
||||
// therefore it may cover the area, but no the volume.
|
||||
last = diff(last, gap_fill.polygons_covered_by_width(10.f));
|
||||
last = diff_ex(to_polygons(last), gap_fill.polygons_covered_by_width(10.f));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,36 +234,34 @@ PerimeterGenerator::process()
|
|||
// we offset by half the perimeter spacing (to get to the actual infill boundary)
|
||||
// and then we offset back and forth by half the infill spacing to only consider the
|
||||
// non-collapsing regions
|
||||
coord_t inset = 0;
|
||||
if (loop_number == 0) {
|
||||
// one loop
|
||||
inset += ext_perimeter_spacing / 2;
|
||||
} else if (loop_number > 0) {
|
||||
// two or more loops
|
||||
inset += perimeter_spacing / 2;
|
||||
}
|
||||
coord_t inset =
|
||||
(loop_number < 0) ? 0 :
|
||||
(loop_number == 0) ?
|
||||
// one loop
|
||||
ext_perimeter_spacing / 2 :
|
||||
// two or more loops?
|
||||
perimeter_spacing / 2;
|
||||
// only apply infill overlap if we actually have one perimeter
|
||||
if (inset > 0)
|
||||
inset -= this->config->get_abs_value("infill_overlap", inset + solid_infill_spacing / 2);
|
||||
inset -= scale_(this->config->get_abs_value("infill_overlap", unscale(inset + solid_infill_spacing / 2)));
|
||||
// simplify infill contours according to resolution
|
||||
Polygons pp;
|
||||
for (ExPolygon &ex : union_ex(last))
|
||||
for (ExPolygon &ex : last)
|
||||
ex.simplify_p(SCALED_RESOLUTION, &pp);
|
||||
// collapse too narrow infill areas
|
||||
coord_t min_perimeter_infill_spacing = solid_infill_spacing * (1 - INSET_OVERLAP_TOLERANCE);
|
||||
coord_t min_perimeter_infill_spacing = solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE);
|
||||
// append infill areas to fill_surfaces
|
||||
this->fill_surfaces->append(
|
||||
offset2_ex(
|
||||
pp,
|
||||
-inset -min_perimeter_infill_spacing/2,
|
||||
+min_perimeter_infill_spacing/2),
|
||||
union_ex(pp),
|
||||
- inset - min_perimeter_infill_spacing / 2,
|
||||
min_perimeter_infill_spacing / 2),
|
||||
stInternal);
|
||||
} // for each island
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection
|
||||
PerimeterGenerator::_traverse_loops(const PerimeterGeneratorLoops &loops,
|
||||
ThickPolylines &thin_walls) const
|
||||
ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
|
||||
const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls) const
|
||||
{
|
||||
// loops is an arrayref of ::Loop objects
|
||||
// turn each one into an ExtrusionLoop object
|
||||
|
@ -422,8 +366,7 @@ PerimeterGenerator::_traverse_loops(const PerimeterGeneratorLoops &loops,
|
|||
return entities;
|
||||
}
|
||||
|
||||
ExtrusionEntityCollection
|
||||
PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) const
|
||||
ExtrusionEntityCollection PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRole role, Flow flow) const
|
||||
{
|
||||
// this value determines granularity of adaptive width, as G-code does not allow
|
||||
// variable extrusion within a single move; this value shall only affect the amount
|
||||
|
@ -431,10 +374,10 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
|
|||
const double tolerance = scale_(0.05);
|
||||
|
||||
ExtrusionEntityCollection coll;
|
||||
for (ThickPolylines::const_iterator p = polylines.begin(); p != polylines.end(); ++p) {
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
ExtrusionPaths paths;
|
||||
ExtrusionPath path(role);
|
||||
ThickLines lines = p->thicklines();
|
||||
ThickLines lines = p.thicklines();
|
||||
|
||||
for (int i = 0; i < (int)lines.size(); ++i) {
|
||||
const ThickLine& line = lines[i];
|
||||
|
@ -474,12 +417,11 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
|
|||
lines.insert(lines.begin() + i + j, new_line);
|
||||
}
|
||||
|
||||
--i;
|
||||
-- i;
|
||||
continue;
|
||||
}
|
||||
|
||||
const double w = fmax(line.a_width, line.b_width);
|
||||
|
||||
if (path.polyline.points.empty()) {
|
||||
path.polyline.append(line.a);
|
||||
path.polyline.append(line.b);
|
||||
|
@ -497,21 +439,19 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
|
|||
if (thickness_delta <= tolerance) {
|
||||
// the width difference between this line and the current flow width is
|
||||
// within the accepted tolerance
|
||||
|
||||
path.polyline.append(line.b);
|
||||
} else {
|
||||
// we need to initialize a new line
|
||||
paths.push_back(path);
|
||||
paths.emplace_back(std::move(path));
|
||||
path = ExtrusionPath(role);
|
||||
--i;
|
||||
-- i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (path.polyline.is_valid())
|
||||
paths.push_back(path);
|
||||
|
||||
// append paths to collection
|
||||
if (!paths.empty()) {
|
||||
paths.emplace_back(std::move(path));
|
||||
// Append paths to collection.
|
||||
if (! paths.empty()) {
|
||||
if (paths.front().first_point().coincides_with(paths.back().last_point()))
|
||||
coll.append(ExtrusionLoop(paths));
|
||||
else
|
||||
|
@ -522,20 +462,15 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
|
|||
return coll;
|
||||
}
|
||||
|
||||
bool
|
||||
PerimeterGeneratorLoop::is_internal_contour() const
|
||||
bool PerimeterGeneratorLoop::is_internal_contour() const
|
||||
{
|
||||
if (this->is_contour) {
|
||||
// an internal contour is a contour containing no other contours
|
||||
for (std::vector<PerimeterGeneratorLoop>::const_iterator loop = this->children.begin();
|
||||
loop != this->children.end(); ++loop) {
|
||||
if (loop->is_contour) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// An internal contour is a contour containing no other contours
|
||||
if (! this->is_contour)
|
||||
return false;
|
||||
for (const PerimeterGeneratorLoop &loop : this->children)
|
||||
if (loop.is_contour)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@ public:
|
|||
// Children contour, may be both CCW and CW oriented (outer contours or holes).
|
||||
std::vector<PerimeterGeneratorLoop> children;
|
||||
|
||||
PerimeterGeneratorLoop(Polygon polygon, unsigned short depth)
|
||||
: polygon(polygon), is_contour(false), depth(depth)
|
||||
{};
|
||||
PerimeterGeneratorLoop(Polygon polygon, unsigned short depth, bool is_contour) :
|
||||
polygon(polygon), is_contour(is_contour), depth(depth) {}
|
||||
// External perimeter. It may be CCW or CW oriented (outer contour or hole contour).
|
||||
bool is_external() const { return this->depth == 0; }
|
||||
// An island, which may have holes, but it does not have another internal island.
|
||||
|
|
|
@ -522,7 +522,7 @@ std::string Print::validate() const
|
|||
// Allow the objects to protrude below the print bed, only the part of the object above the print bed will be sliced.
|
||||
print_volume.min.z = -1e10;
|
||||
for (PrintObject *po : this->objects) {
|
||||
if (! print_volume.contains(po->model_object()->tight_bounding_box(false)))
|
||||
if (!print_volume.contains(po->model_object()->tight_bounding_box(false)))
|
||||
return "Some objects are outside of the print volume.";
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,9 @@ void Print::_make_skirt()
|
|||
|
||||
// Initial offset of the brim inner edge from the object (possible with a support & raft).
|
||||
// The skirt will touch the brim if the brim is extruded.
|
||||
coord_t distance = scale_(std::max(this->config.skirt_distance.value, this->config.brim_width.value));
|
||||
Flow brim_flow = this->brim_flow();
|
||||
double actual_brim_width = brim_flow.spacing() * floor(this->config.brim_width.value / brim_flow.spacing());
|
||||
coord_t distance = scale_(std::max(this->config.skirt_distance.value, actual_brim_width) - spacing/2.);
|
||||
// Draw outlines from outside to inside.
|
||||
// Loop while we have less skirts than required or any extruder hasn't reached the min length if any.
|
||||
std::vector<coordf_t> extruded_length(extruders.size(), 0.);
|
||||
|
@ -989,7 +991,7 @@ void Print::_make_brim()
|
|||
}
|
||||
}
|
||||
Polygons loops;
|
||||
size_t num_loops = size_t(floor(this->config.brim_width.value / flow.width));
|
||||
size_t num_loops = size_t(floor(this->config.brim_width.value / flow.spacing()));
|
||||
for (size_t i = 0; i < num_loops; ++ i) {
|
||||
islands = offset(islands, float(flow.scaled_spacing()), jtSquare);
|
||||
for (Polygon &poly : islands) {
|
||||
|
|
|
@ -948,7 +948,7 @@ PrintConfigDef::PrintConfigDef()
|
|||
def->default_value = new ConfigOptionFloats { 10. };
|
||||
|
||||
def = this->add("min_skirt_length", coFloat);
|
||||
def->label = L("Minimum extrusion length");
|
||||
def->label = L("Minimal filament extrusion length");
|
||||
def->tooltip = L("Generate no less than the number of skirt loops required to consume "
|
||||
"the specified amount of filament on the bottom layer. For multi-extruder machines, "
|
||||
"this minimum applies to each extruder.");
|
||||
|
@ -1911,8 +1911,10 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
std::ostringstream oss;
|
||||
oss << "0x0," << p.value.x << "x0," << p.value.x << "x" << p.value.y << ",0x" << p.value.y;
|
||||
value = oss.str();
|
||||
} else if (opt_key == "octoprint_host" && !value.empty()) {
|
||||
opt_key = "print_host";
|
||||
// Maybe one day we will rename octoprint_host to print_host as it has been done in the upstream Slic3r.
|
||||
// Commenting this out fixes github issue #869 for now.
|
||||
// } else if (opt_key == "octoprint_host" && !value.empty()) {
|
||||
// opt_key = "print_host";
|
||||
} else if ((opt_key == "perimeter_acceleration" && value == "25")
|
||||
|| (opt_key == "infill_acceleration" && value == "50")) {
|
||||
/* For historical reasons, the world's full of configs having these very low values;
|
||||
|
@ -1923,10 +1925,6 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
} else if (opt_key == "support_material_pattern" && value == "pillars") {
|
||||
// Slic3r PE does not support the pillars. They never worked well.
|
||||
value = "rectilinear";
|
||||
} else if (opt_key == "support_material_threshold" && value == "0") {
|
||||
// 0 used to be automatic threshold, but we introduced percent values so let's
|
||||
// transform it into the default value
|
||||
value = "60%";
|
||||
}
|
||||
|
||||
// Ignore the following obsolete configuration keys:
|
||||
|
@ -1935,7 +1933,10 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
"support_material_tool", "acceleration", "adjust_overhang_flow",
|
||||
"standby_temperature", "scale", "rotate", "duplicate", "duplicate_grid",
|
||||
"start_perimeters_at_concave_points", "start_perimeters_at_non_overhang", "randomize_start",
|
||||
"seal_position", "vibration_limit", "bed_size", "octoprint_host",
|
||||
"seal_position", "vibration_limit", "bed_size",
|
||||
// Maybe one day we will rename octoprint_host to print_host as it has been done in the upstream Slic3r.
|
||||
// Commenting this out fixes github issue #869 for now.
|
||||
// "octoprint_host",
|
||||
"print_center", "g0", "threads", "pressure_advance", "wipe_tower_per_color_wipe"
|
||||
};
|
||||
|
||||
|
|
|
@ -1459,7 +1459,6 @@ void PrintObject::_make_perimeters()
|
|||
size_t region_id = region_it - this->_print->regions.begin();
|
||||
const PrintRegion ®ion = **region_it;
|
||||
|
||||
|
||||
if (!region.config.extra_perimeters
|
||||
|| region.config.perimeters == 0
|
||||
|| region.config.fill_density == 0
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <boost/thread.hpp>
|
||||
|
||||
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
|
||||
#define SLIC3R_VERSION "1.40.0-alpha"
|
||||
#define SLIC3R_VERSION "1.40.0"
|
||||
#define SLIC3R_BUILD "UNKNOWN"
|
||||
|
||||
typedef int32_t coord_t;
|
||||
|
|
|
@ -95,7 +95,7 @@ const std::string& var_dir()
|
|||
|
||||
std::string var(const std::string &file_name)
|
||||
{
|
||||
auto file = boost::filesystem::canonical(boost::filesystem::path(g_var_dir) / file_name).make_preferred();
|
||||
auto file = (boost::filesystem::path(g_var_dir) / file_name).make_preferred();
|
||||
return file.string();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue