Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_sinking_objects_collision

This commit is contained in:
enricoturri1966 2021-10-05 09:51:04 +02:00
commit ddcbbee3b0
11 changed files with 68 additions and 61 deletions

View file

@ -423,7 +423,7 @@ void fill_slicerconf(ConfMap &m, const SLAPrint &print)
} // namespace
uqptr<sla::RasterBase> SL1Archive::create_raster() const
std::unique_ptr<sla::RasterBase> SL1Archive::create_raster() const
{
sla::RasterBase::Resolution res;
sla::RasterBase::PixelDim pxdim;

View file

@ -12,7 +12,7 @@ class SL1Archive: public SLAArchive {
SLAPrinterConfig m_cfg;
protected:
uqptr<sla::RasterBase> create_raster() const override;
std::unique_ptr<sla::RasterBase> create_raster() const override;
sla::RasterEncoder get_encoder() const override;
public:

View file

@ -13,10 +13,6 @@
namespace Slic3r {
template<class T> using uqptr = std::unique_ptr<T>;
template<class T> using shptr = std::shared_ptr<T>;
template<class T> using wkptr = std::weak_ptr<T>;
namespace sla {
// Raw byte buffer paired with its size. Suitable for compressed image data.
@ -112,7 +108,7 @@ struct PPMRasterEncoder {
std::ostream& operator<<(std::ostream &stream, const EncodedRaster &bytes);
// If gamma is zero, thresholding will be performed which disables AA.
uqptr<RasterBase> create_raster_grayscale_aa(
std::unique_ptr<RasterBase> create_raster_grayscale_aa(
const RasterBase::Resolution &res,
const RasterBase::PixelDim & pxdim,
double gamma = 1.0,

View file

@ -391,7 +391,7 @@ class SLAArchive {
protected:
std::vector<sla::EncodedRaster> m_layers;
virtual uqptr<sla::RasterBase> create_raster() const = 0;
virtual std::unique_ptr<sla::RasterBase> create_raster() const = 0;
virtual sla::RasterEncoder get_encoder() const = 0;
public:

View file

@ -2055,21 +2055,21 @@ static inline PrintObjectSupportMaterial::MyLayer* detect_bottom_contacts(
// Trim the already created base layers above the current layer intersecting with the new bottom contacts layer.
//FIXME Maybe this is no more needed, as the overlapping base layers are trimmed by the bottom layers at the final stage?
touching = offset(touching, float(SCALED_EPSILON));
for (int layer_id_above = layer_id + 1; layer_id_above < int(object.total_layer_count()); ++layer_id_above) {
for (int layer_id_above = layer_id + 1; layer_id_above < int(object.total_layer_count()); ++ layer_id_above) {
const Layer &layer_above = *object.layers()[layer_id_above];
if (layer_above.print_z > layer_new.print_z - EPSILON)
break;
if (! layer_support_areas[layer_id_above].empty()) {
if (Polygons &above = layer_support_areas[layer_id_above]; ! above.empty()) {
#ifdef SLIC3R_DEBUG
SVG::export_expolygons(debug_out_path("support-support-areas-raw-before-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z),
{ { { union_ex(touching) }, { "touching", "blue", 0.5f } },
{ { union_safety_offset_ex(layer_support_areas[layer_id_above]) }, { "above", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
{ { { union_ex(touching) }, { "touching", "blue", 0.5f } },
{ { union_safety_offset_ex(above) }, { "above", "red", "black", "", scaled<coord_t>(0.1f), 0.5f } } });
#endif /* SLIC3R_DEBUG */
layer_support_areas[layer_id_above] = diff(layer_support_areas[layer_id_above], touching);
above = diff(above, touching);
#ifdef SLIC3R_DEBUG
Slic3r::SVG::export_expolygons(
debug_out_path("support-support-areas-raw-after-trimming-%d-with-%f-%lf.svg", iRun, layer.print_z, layer_above.print_z),
union_ex(layer_support_areas[layer_id_above]));
union_ex(above));
#endif /* SLIC3R_DEBUG */
}
}
@ -2622,10 +2622,9 @@ void PrintObjectSupportMaterial::generate_base_layers(
// New polygons for layer_intermediate.
Polygons polygons_new;
// Use the precomputed layer_support_areas.
idx_object_layer_above = std::max(0, idx_lower_or_equal(object.layers().begin(), object.layers().end(), idx_object_layer_above,
[&layer_intermediate](const Layer *layer){ return layer->print_z <= layer_intermediate.print_z + EPSILON; }));
polygons_new = layer_support_areas[idx_object_layer_above];
// Use the precomputed layer_support_areas. "idx_object_layer_above": above means above since the last iteration, not above after this call.
idx_object_layer_above = idx_lower_or_equal(object.layers().begin(), object.layers().end(), idx_object_layer_above,
[&layer_intermediate](const Layer* layer) { return layer->print_z <= layer_intermediate.print_z + EPSILON; });
// Polygons to trim polygons_new.
Polygons polygons_trimming;
@ -2640,7 +2639,7 @@ void PrintObjectSupportMaterial::generate_base_layers(
idx_top_contact_above = idx_lower_or_equal(top_contacts, idx_top_contact_above,
[&layer_intermediate](const MyLayer *layer){ return layer->bottom_z <= layer_intermediate.print_z - EPSILON; });
// Collect all the top_contact layer intersecting with this layer.
for ( int idx_top_contact_overlapping = idx_top_contact_above; idx_top_contact_overlapping >= 0; -- idx_top_contact_overlapping) {
for (int idx_top_contact_overlapping = idx_top_contact_above; idx_top_contact_overlapping >= 0; -- idx_top_contact_overlapping) {
MyLayer &layer_top_overlapping = *top_contacts[idx_top_contact_overlapping];
if (layer_top_overlapping.print_z < layer_intermediate.bottom_z + EPSILON)
break;
@ -2651,6 +2650,22 @@ void PrintObjectSupportMaterial::generate_base_layers(
polygons_append(polygons_trimming, layer_top_overlapping.polygons);
}
if (idx_object_layer_above < 0) {
// layer_support_areas are synchronized with object layers and they contain projections of the contact layers above them.
// This intermediate layer is not above any object layer, thus there is no information in layer_support_areas about
// towers supporting contact layers intersecting the first object layer. Project these contact layers now.
polygons_new = layer_support_areas.front();
double first_layer_z = object.layers().front()->print_z;
for (int i = idx_top_contact_above + 1; i < int(top_contacts.size()); ++ i) {
MyLayer &contacts = *top_contacts[i];
if (contacts.print_z > first_layer_z + EPSILON)
break;
assert(contacts.bottom_z > layer_intermediate.print_z - EPSILON);
polygons_append(polygons_new, contacts.polygons);
}
} else
polygons_new = layer_support_areas[idx_object_layer_above];
// Trimming the base layer with any overlapping bottom layer.
// Following cases are recognized:
// 1) bottom.bottom_z >= base.top_z -> No overlap, no trimming needed.

View file

@ -228,7 +228,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
return;
}
// check unsaved changes only if project wasn't saved
else if (saved_project == wxID_NO && event.CanVeto() &&
else if (plater()->is_project_dirty() && saved_project == wxID_NO && event.CanVeto() &&
!wxGetApp().check_and_save_current_preset_changes(_L("PrusaSlicer is closing"), _L("Closing PrusaSlicer while some presets are modified."))) {
event.Veto();
return;

View file

@ -2109,13 +2109,14 @@ void Plater::priv::update(unsigned int flags)
}
unsigned int update_status = 0;
if (this->printer_technology == ptSLA || (flags & (unsigned int)UpdateParams::FORCE_BACKGROUND_PROCESSING_UPDATE))
const bool force_background_processing_restart = this->printer_technology == ptSLA || (flags & (unsigned int)UpdateParams::FORCE_BACKGROUND_PROCESSING_UPDATE);
if (force_background_processing_restart)
// Update the SLAPrint from the current Model, so that the reload_scene()
// pulls the correct data.
update_status = this->update_background_process(false, flags & (unsigned int)UpdateParams::POSTPONE_VALIDATION_ERROR_MESSAGE);
this->view3D->reload_scene(false, flags & (unsigned int)UpdateParams::FORCE_FULL_SCREEN_REFRESH);
this->preview->reload_print();
if (this->printer_technology == ptSLA)
if (force_background_processing_restart)
this->restart_background_process(update_status);
else
this->schedule_background_process();