Make sure that we have the lower_layer_edge_grid when placing seams
This commit is contained in:
parent
19eb984d72
commit
00dfb8f69c
2 changed files with 30 additions and 20 deletions
src
|
@ -2479,31 +2479,36 @@ std::string GCode::change_layer(coordf_t print_z)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static std::unique_ptr<EdgeGrid::Grid> calculate_layer_edge_grid(const Layer& layer)
|
||||||
|
{
|
||||||
|
auto out = make_unique<EdgeGrid::Grid>();
|
||||||
|
|
||||||
|
// Create the distance field for a layer below.
|
||||||
|
const coord_t distance_field_resolution = coord_t(scale_(1.) + 0.5);
|
||||||
|
out->create(layer.lslices, distance_field_resolution);
|
||||||
|
out->calculate_sdf();
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
static int iRun = 0;
|
||||||
|
BoundingBox bbox = (*lower_layer_edge_grid)->bbox();
|
||||||
|
bbox.min(0) -= scale_(5.f);
|
||||||
|
bbox.min(1) -= scale_(5.f);
|
||||||
|
bbox.max(0) += scale_(5.f);
|
||||||
|
bbox.max(1) += scale_(5.f);
|
||||||
|
EdgeGrid::save_png(*(*lower_layer_edge_grid), bbox, scale_(0.1f), debug_out_path("GCode_extrude_loop_edge_grid-%d.png", iRun++));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, double speed, std::unique_ptr<EdgeGrid::Grid> *lower_layer_edge_grid)
|
std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, double speed, std::unique_ptr<EdgeGrid::Grid> *lower_layer_edge_grid)
|
||||||
{
|
{
|
||||||
// get a copy; don't modify the orientation of the original loop object otherwise
|
// get a copy; don't modify the orientation of the original loop object otherwise
|
||||||
// next copies (if any) would not detect the correct orientation
|
// next copies (if any) would not detect the correct orientation
|
||||||
|
|
||||||
if (m_layer->lower_layer != nullptr && lower_layer_edge_grid != nullptr) {
|
if (m_layer->lower_layer && lower_layer_edge_grid != nullptr && ! *lower_layer_edge_grid)
|
||||||
if (! *lower_layer_edge_grid) {
|
*lower_layer_edge_grid = calculate_layer_edge_grid(*m_layer->lower_layer);
|
||||||
// Create the distance field for a layer below.
|
|
||||||
const coord_t distance_field_resolution = coord_t(scale_(1.) + 0.5);
|
|
||||||
*lower_layer_edge_grid = make_unique<EdgeGrid::Grid>();
|
|
||||||
(*lower_layer_edge_grid)->create(m_layer->lower_layer->lslices, distance_field_resolution);
|
|
||||||
(*lower_layer_edge_grid)->calculate_sdf();
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
static int iRun = 0;
|
|
||||||
BoundingBox bbox = (*lower_layer_edge_grid)->bbox();
|
|
||||||
bbox.min(0) -= scale_(5.f);
|
|
||||||
bbox.min(1) -= scale_(5.f);
|
|
||||||
bbox.max(0) += scale_(5.f);
|
|
||||||
bbox.max(1) += scale_(5.f);
|
|
||||||
EdgeGrid::save_png(*(*lower_layer_edge_grid), bbox, scale_(0.1f), debug_out_path("GCode_extrude_loop_edge_grid-%d.png", iRun++));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// extrude all loops ccw
|
// extrude all loops ccw
|
||||||
bool was_clockwise = loop.make_counter_clockwise();
|
bool was_clockwise = loop.make_counter_clockwise();
|
||||||
|
@ -2640,6 +2645,10 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
|
||||||
if (! region.perimeters.empty()) {
|
if (! region.perimeters.empty()) {
|
||||||
m_config.apply(print.get_print_region(®ion - &by_region.front()).config());
|
m_config.apply(print.get_print_region(®ion - &by_region.front()).config());
|
||||||
|
|
||||||
|
// plan_perimeters tries to place seams, it needs to have the lower_layer_edge_grid calculated already.
|
||||||
|
if (m_layer->lower_layer && ! lower_layer_edge_grid)
|
||||||
|
lower_layer_edge_grid = calculate_layer_edge_grid(*m_layer->lower_layer);
|
||||||
|
|
||||||
m_seam_placer.plan_perimeters(std::vector<const ExtrusionEntity*>(region.perimeters.begin(), region.perimeters.end()),
|
m_seam_placer.plan_perimeters(std::vector<const ExtrusionEntity*>(region.perimeters.begin(), region.perimeters.end()),
|
||||||
*m_layer, m_config.seam_position, this->last_pos(), EXTRUDER_CONFIG(nozzle_diameter),
|
*m_layer, m_config.seam_position, this->last_pos(), EXTRUDER_CONFIG(nozzle_diameter),
|
||||||
(m_layer == NULL ? nullptr : m_layer->object()),
|
(m_layer == NULL ? nullptr : m_layer->object()),
|
||||||
|
|
|
@ -673,6 +673,7 @@ void GUI_App::post_init()
|
||||||
// to popup a modal dialog on start without screwing combo boxes.
|
// to popup a modal dialog on start without screwing combo boxes.
|
||||||
// This is ugly but I honestly found no better way to do it.
|
// This is ugly but I honestly found no better way to do it.
|
||||||
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
|
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
|
||||||
|
assert(this->preset_updater); // FIXME Following condition is probably not neccessary.
|
||||||
if (this->preset_updater) {
|
if (this->preset_updater) {
|
||||||
this->check_updates(false);
|
this->check_updates(false);
|
||||||
CallAfter([this] {
|
CallAfter([this] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue