Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsupermerill <merill@free.fr>2022-07-28 04:40:00 +0300
committersupermerill <merill@free.fr>2022-08-11 00:41:11 +0300
commit10dd647e72f751543dd79f8796875f3879adb126 (patch)
tree875337fbc6545b09f0aa36dd0ec0e56afd6abe6e /src
parent76a9eda1c26a030ef652b03da2d126dbef66dc6b (diff)
Protecting SlicingParameters behind a shared_ptr.
Some code cleaning
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/Brim.cpp10
-rw-r--r--src/libslic3r/Print.hpp8
-rw-r--r--src/libslic3r/PrintObject.cpp12
-rw-r--r--src/libslic3r/PrintObjectSlice.cpp4
-rw-r--r--src/libslic3r/Slicing.cpp12
-rw-r--r--src/libslic3r/Slicing.hpp4
-rw-r--r--src/libslic3r/SlicingAdaptive.cpp26
-rw-r--r--src/libslic3r/SlicingAdaptive.hpp4
-rw-r--r--src/libslic3r/SupportMaterial.cpp140
-rw-r--r--src/libslic3r/SupportMaterial.hpp8
-rw-r--r--src/libslic3r/libslic3r.h27
-rw-r--r--src/slic3r/GUI/GLCanvas3D.cpp13
-rw-r--r--src/slic3r/GUI/GLCanvas3D.hpp2
-rw-r--r--src/slic3r/GUI/ScriptExecutor.cpp9
14 files changed, 156 insertions, 123 deletions
diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp
index 99970199b..e3202d781 100644
--- a/src/libslic3r/Brim.cpp
+++ b/src/libslic3r/Brim.cpp
@@ -838,10 +838,10 @@ void extrude_brim_from_tree(const Print& print, std::vector<std::vector<BrimLoop
(*extrude_ptr)(child, mycoll);
//remove un-needed collection if possible
if (mycoll->entities().size() == 1) {
- parent->append(*mycoll->entities().front());
- delete mycoll;
+ parent->append(*mycoll->entities().front()); //add clone
+ delete mycoll; // remove coll & content
} else if (mycoll->entities().size() == 0) {
- delete mycoll;
+ delete mycoll;// remove coll & content
} else {
parent->append(ExtrusionEntitiesPtr{ mycoll });
}
@@ -856,10 +856,10 @@ void extrude_brim_from_tree(const Print& print, std::vector<std::vector<BrimLoop
if (line.points.back() == line.points.front()) {
ExtrusionPath path(erSkirt, mm3_per_mm, width, height);
path.polyline.points = line.points;
- to_add.emplace_back(new ExtrusionLoop(std::move(path), elrSkirt));
+ to_add.push_back(new ExtrusionLoop(std::move(path), elrSkirt));
} else {
ExtrusionPath* extrusion_path = new ExtrusionPath(erSkirt, mm3_per_mm, width, height);
- to_add.emplace_back(extrusion_path);
+ to_add.push_back(extrusion_path);
extrusion_path->polyline = line;
}
}
diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp
index 2078fb4f5..c74dfeeb6 100644
--- a/src/libslic3r/Print.hpp
+++ b/src/libslic3r/Print.hpp
@@ -121,7 +121,7 @@ public:
T * const * begin() const { return m_data->data(); }
T * const * end() const { return m_data->data() + m_data->size(); }
const T* front() const { return m_data->front(); }
- const T* back() const { return m_data->front(); }
+ const T* back() const { return m_data->back(); }
size_t size() const { return m_data->size(); }
bool empty() const { return m_data->empty(); }
const T* operator[](size_t i) const { return (*m_data)[i]; }
@@ -314,8 +314,8 @@ public:
// by the interactive layer height editor and by the printing process itself.
// The slicing parameters are dependent on various configuration values
// (layer height, first layer height, raft settings, print nozzle diameter etc).
- const SlicingParameters& slicing_parameters() const { return m_slicing_params; }
- static SlicingParameters slicing_parameters(const DynamicPrintConfig &full_config, const ModelObject &model_object, float object_max_z);
+ const SlicingParameters& slicing_parameters() const { return *m_slicing_params; }
+ static std::shared_ptr<SlicingParameters> slicing_parameters(const DynamicPrintConfig &full_config, const ModelObject &model_object, float object_max_z);
size_t num_printing_regions() const throw() { return m_shared_regions->all_regions.size(); }
const PrintRegion& printing_region(size_t idx) const throw() { return *m_shared_regions->all_regions[idx].get(); }
@@ -412,7 +412,7 @@ private:
// Shared among PrintObjects created for the same ModelObject.
PrintObjectRegions *m_shared_regions { nullptr };
- SlicingParameters m_slicing_params;
+ std::shared_ptr<SlicingParameters> m_slicing_params;
LayerPtrs m_layers;
SupportLayerPtrs m_support_layers;
diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp
index 8fbc24f3f..84ba3ecd6 100644
--- a/src/libslic3r/PrintObject.cpp
+++ b/src/libslic3r/PrintObject.cpp
@@ -994,10 +994,10 @@ bool PrintObject::invalidate_state_by_config_options(
} else if (step == posSlice) {
invalidated |= this->invalidate_steps({ posPerimeters, posPrepareInfill, posInfill, posIroning, posSupportMaterial });
invalidated |= m_print->invalidate_steps({ psSkirtBrim });
- m_slicing_params.valid = false;
+ m_slicing_params->valid = false;
} else if (step == posSupportMaterial) {
invalidated |= m_print->invalidate_steps({ psSkirtBrim });
- m_slicing_params.valid = false;
+ m_slicing_params->valid = false;
}
// Wipe tower depends on the ordering of extruders, which in turn depends on everything.
@@ -1014,7 +1014,7 @@ bool PrintObject::invalidate_state_by_config_options(
// First call the "invalidate" functions, which may cancel background processing.
bool result = Inherited::invalidate_all_steps() | m_print->invalidate_all_steps();
// Then reset some of the depending values.
- m_slicing_params.valid = false;
+ m_slicing_params->valid = false;
return result;
}
@@ -2452,12 +2452,12 @@ PrintRegionConfig region_config_from_model_volume(const PrintRegionConfig &defau
void PrintObject::update_slicing_parameters()
{
- if (!m_slicing_params.valid)
+ if (!m_slicing_params || !m_slicing_params->valid)
m_slicing_params = SlicingParameters::create_from_config(
- this->print()->config(), m_config, this->model_object()->bounding_box().max.z(), this->object_extruders());
+ this->print()->config(), m_config, this->model_object()->bounding_box().max.z(), this->object_extruders());
}
- SlicingParameters PrintObject::slicing_parameters(const DynamicPrintConfig& full_config, const ModelObject& model_object, float object_max_z)
+ std::shared_ptr<SlicingParameters> PrintObject::slicing_parameters(const DynamicPrintConfig& full_config, const ModelObject& model_object, float object_max_z)
{
PrintConfig print_config;
PrintObjectConfig object_config;
diff --git a/src/libslic3r/PrintObjectSlice.cpp b/src/libslic3r/PrintObjectSlice.cpp
index 8f28c8417..a135c6569 100644
--- a/src/libslic3r/PrintObjectSlice.cpp
+++ b/src/libslic3r/PrintObjectSlice.cpp
@@ -526,11 +526,11 @@ void PrintObject::slice()
return;
m_print->set_status(0, L("Processing triangulated mesh"));
std::vector<coordf_t> layer_height_profile;
- this->update_layer_height_profile(*this->model_object(), m_slicing_params, layer_height_profile);
+ this->update_layer_height_profile(*this->model_object(), *m_slicing_params, layer_height_profile);
m_print->throw_if_canceled();
m_typed_slices = false;
this->clear_layers();
- m_layers = new_layers(this, generate_object_layers(m_slicing_params, layer_height_profile));
+ m_layers = new_layers(this, generate_object_layers(*m_slicing_params, layer_height_profile));
this->slice_volumes();
m_print->throw_if_canceled();
// Fix the model.
diff --git a/src/libslic3r/Slicing.cpp b/src/libslic3r/Slicing.cpp
index 8a6cb0c5f..24008319f 100644
--- a/src/libslic3r/Slicing.cpp
+++ b/src/libslic3r/Slicing.cpp
@@ -77,7 +77,7 @@ coordf_t Slicing::max_layer_height_from_nozzle(const DynamicPrintConfig &print_c
}
-SlicingParameters SlicingParameters::create_from_config(
+std::shared_ptr<SlicingParameters> SlicingParameters::create_from_config(
const PrintConfig &print_config,
const PrintObjectConfig &object_config,
coordf_t object_height,
@@ -111,7 +111,8 @@ SlicingParameters SlicingParameters::create_from_config(
coordf_t support_material_interface_extruder_dmr = print_config.nozzle_diameter.get_at(object_config.support_material_interface_extruder.value - 1);
bool soluble_interface = object_config.support_material_contact_distance_type.value == zdNone;
- SlicingParameters params;
+ std::shared_ptr<SlicingParameters> slicing_params = std::make_shared<SlicingParameters>();
+ SlicingParameters& params = *slicing_params.get();
params.layer_height = object_config.layer_height.value;
params.first_print_layer_height = first_layer_height;
params.first_object_layer_height = first_layer_height;
@@ -230,7 +231,7 @@ SlicingParameters SlicingParameters::create_from_config(
assert(test_z_step(params.object_print_z_max, params.z_step));
params.valid = true;
- return params;
+ return slicing_params;
}
// Convert layer_config_ranges to layer_height_profile. Both are referenced to z=0, meaning the raft layers are not accounted for
@@ -302,7 +303,7 @@ std::vector<double> layer_height_profile_adaptive(const SlicingParameters& slici
{
// 1) Initialize the SlicingAdaptive class with the object meshes.
SlicingAdaptive as;
- as.set_slicing_parameters(slicing_params);
+ as.set_slicing_parameters(&slicing_params);
as.prepare(object);
// 2) Generate layers using the algorithm of @platsch
@@ -544,7 +545,8 @@ void adjust_layer_height_profile(
size_t idx = 0;
while (idx < layer_height_profile.size() && layer_height_profile[idx] < lo)
idx += 2;
- idx -= 2;
+ if(idx > 1)
+ idx -= 2;
std::vector<double> profile_new;
profile_new.reserve(layer_height_profile.size());
diff --git a/src/libslic3r/Slicing.hpp b/src/libslic3r/Slicing.hpp
index 96564acc3..161469cee 100644
--- a/src/libslic3r/Slicing.hpp
+++ b/src/libslic3r/Slicing.hpp
@@ -29,9 +29,9 @@ extern coordf_t check_z_step(const coordf_t val,const coordf_t z_step);
// (using a normal flow over a soluble support, using a bridging flow over a non-soluble support).
struct SlicingParameters
{
- SlicingParameters() = default;
+ SlicingParameters() = default;
- static SlicingParameters create_from_config(
+ static std::shared_ptr<SlicingParameters> create_from_config(
const PrintConfig &print_config,
const PrintObjectConfig &object_config,
coordf_t object_height,
diff --git a/src/libslic3r/SlicingAdaptive.cpp b/src/libslic3r/SlicingAdaptive.cpp
index e12dcc7a1..eb39205fb 100644
--- a/src/libslic3r/SlicingAdaptive.cpp
+++ b/src/libslic3r/SlicingAdaptive.cpp
@@ -102,21 +102,21 @@ void SlicingAdaptive::prepare(const ModelObject &object)
// returns height of the next layer.
float SlicingAdaptive::next_layer_height(const float print_z, float quality_factor, size_t &current_facet)
{
- float height = (float)m_slicing_params.max_layer_height;
+ float height = (float)m_slicing_params->max_layer_height;
float max_surface_deviation;
{
#if 0
// @platch's formula for quality:
- double delta_min = SURFACE_CONST * m_slicing_params.min_layer_height;
- double delta_mid = (SURFACE_CONST + 0.5) * m_slicing_params.layer_height;
- double delta_max = (SURFACE_CONST + 0.5) * m_slicing_params.max_layer_height;
+ double delta_min = SURFACE_CONST * m_slicing_params->min_layer_height;
+ double delta_mid = (SURFACE_CONST + 0.5) * m_slicing_params->layer_height;
+ double delta_max = (SURFACE_CONST + 0.5) * m_slicing_params->max_layer_height;
#else
// Vojtech's formula for triangle area error metric.
- double delta_min = m_slicing_params.min_layer_height;
- double delta_mid = m_slicing_params.layer_height;
- double delta_max = m_slicing_params.max_layer_height;
+ double delta_min = m_slicing_params->min_layer_height;
+ double delta_mid = m_slicing_params->layer_height;
+ double delta_max = m_slicing_params->max_layer_height;
#endif
max_surface_deviation = (quality_factor < 0.5f) ?
lerp(delta_min, delta_mid, 2. * quality_factor) :
@@ -149,10 +149,10 @@ float SlicingAdaptive::next_layer_height(const float print_z, float quality_fact
}
// lower height limit due to printer capabilities
- height = std::max(height, float(m_slicing_params.min_layer_height));
+ height = std::max(height, float(m_slicing_params->min_layer_height));
// check for sloped facets inside the determined layer and correct height if necessary
- if (height > float(m_slicing_params.min_layer_height)) {
+ if (height > float(m_slicing_params->min_layer_height)) {
for (; ordered_id < m_faces.size(); ++ ordered_id) {
const std::pair<float, float> &zspan = m_faces[ordered_id].z_span;
// facet's minimum is higher than slice_z + height -> end loop
@@ -185,7 +185,7 @@ float SlicingAdaptive::next_layer_height(const float print_z, float quality_fact
}
}
// lower height limit due to printer capabilities again
- height = std::max(height, float(m_slicing_params.min_layer_height));
+ height = std::max(height, float(m_slicing_params->min_layer_height));
}
#ifdef ADAPTIVE_LAYER_HEIGHT_DEBUG
@@ -201,7 +201,7 @@ float SlicingAdaptive::horizontal_facet_distance(float z)
for (size_t i = 0; i < m_faces.size(); ++ i) {
std::pair<float, float> zspan = m_faces[i].z_span;
// facet's minimum is higher than max forward distance -> end loop
- if (zspan.first > z + m_slicing_params.max_layer_height)
+ if (zspan.first > z + m_slicing_params->max_layer_height)
break;
// min_z == max_z -> horizontal facet
if (zspan.first > z && zspan.first == zspan.second)
@@ -209,8 +209,8 @@ float SlicingAdaptive::horizontal_facet_distance(float z)
}
// objects maximum?
- return (z + (float)m_slicing_params.max_layer_height > (float)m_slicing_params.object_print_z_height()) ?
- std::max((float)m_slicing_params.object_print_z_height() - z, 0.f) : (float)m_slicing_params.max_layer_height;
+ return (z + (float)m_slicing_params->max_layer_height > (float)m_slicing_params->object_print_z_height()) ?
+ std::max((float)m_slicing_params->object_print_z_height() - z, 0.f) : (float)m_slicing_params->max_layer_height;
}
}; // namespace Slic3r
diff --git a/src/libslic3r/SlicingAdaptive.hpp b/src/libslic3r/SlicingAdaptive.hpp
index a296553d6..fc36392fc 100644
--- a/src/libslic3r/SlicingAdaptive.hpp
+++ b/src/libslic3r/SlicingAdaptive.hpp
@@ -15,7 +15,7 @@ class SlicingAdaptive
{
public:
void clear();
- void set_slicing_parameters(SlicingParameters params) { m_slicing_params = params; }
+ void set_slicing_parameters(const SlicingParameters* params) { m_slicing_params = params; }
void prepare(const ModelObject &object);
// Return next layer height starting from the last print_z, using a quality measure
// (quality in range from 0 to 1, 0 - highest quality at low layer heights, 1 - lowest print quality at high layer heights).
@@ -32,7 +32,7 @@ public:
};
protected:
- SlicingParameters m_slicing_params;
+ const SlicingParameters* m_slicing_params;
std::vector<FaceZ> m_faces;
};
diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp
index 9f3675e3b..3519ac2ab 100644
--- a/src/libslic3r/SupportMaterial.cpp
+++ b/src/libslic3r/SupportMaterial.cpp
@@ -343,15 +343,15 @@ static Polygons contours_simplified(const Vec2i32 &grid_size, const double pixel
}
#endif // SUPPORT_USE_AGG_RASTERIZER
-PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object, const SlicingParameters &slicing_params) :
+PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object, std::shared_ptr<const SlicingParameters> slicing_params) :
m_object (object),
m_print_config (&object->print()->config()),
m_object_config (&object->config()),
m_slicing_params (slicing_params)
{
- m_support_params.first_layer_flow = support_material_1st_layer_flow(object, float(slicing_params.first_print_layer_height));
- m_support_params.support_material_flow = support_material_flow(object, float(slicing_params.layer_height));
- m_support_params.support_material_interface_flow = support_material_interface_flow(object, float(slicing_params.layer_height));
+ m_support_params.first_layer_flow = support_material_1st_layer_flow(object, float(slicing_params->first_print_layer_height));
+ m_support_params.support_material_flow = support_material_flow(object, float(slicing_params->layer_height));
+ m_support_params.support_material_interface_flow = support_material_interface_flow(object, float(slicing_params->layer_height));
m_support_params.support_layer_height_min = 0.01;
m_support_params.raft_bridge_flow_ratio = object->print()->default_region_config().bridge_flow_ratio.get_abs_value(1.);
@@ -375,13 +375,13 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
coordf_t bridge_flow_ratio = 0;
for (size_t region_id = 0; region_id < object->num_printing_regions(); ++ region_id) {
const PrintRegion &region = object->printing_region(region_id);
- external_perimeter_width = std::max(external_perimeter_width, coordf_t(region.flow(*object, frExternalPerimeter, slicing_params.layer_height).width()));
+ external_perimeter_width = std::max(external_perimeter_width, coordf_t(region.flow(*object, frExternalPerimeter, slicing_params->layer_height).width()));
bridge_flow_ratio += region.config().bridge_flow_ratio.get_abs_value(1.);
}
m_support_params.gap_xy = m_object_config->support_material_xy_spacing.get_abs_value(external_perimeter_width);
bridge_flow_ratio /= object->num_printing_regions();
- m_support_params.support_material_bottom_interface_flow = m_slicing_params.soluble_interface ?
+ m_support_params.support_material_bottom_interface_flow = m_slicing_params->soluble_interface ?
m_support_params.support_material_interface_flow.with_flow_ratio(bridge_flow_ratio) :
Flow::bridging_flow(std::sqrt(bridge_flow_ratio) * m_support_params.support_material_interface_flow.nozzle_diameter(), m_support_params.support_material_interface_flow.nozzle_diameter());
@@ -416,7 +416,7 @@ PrintObjectSupportMaterial::PrintObjectSupportMaterial(const PrintObject *object
m_support_params.interface_fill_pattern = (m_support_params.interface_density > 0.95 ? ipRectilinear : ipSupportBase);
m_support_params.contact_fill_pattern = m_object_config->support_material_interface_pattern;
if (m_support_params.contact_fill_pattern == ipAuto)
- if (m_slicing_params.soluble_interface)
+ if (m_slicing_params->soluble_interface)
m_support_params.contact_fill_pattern = ipConcentric;
else if (m_support_params.interface_density > 0.95)
m_support_params.contact_fill_pattern = ipRectilinear;
@@ -522,7 +522,7 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
MyLayersPtr intermediate_layers = this->raft_and_intermediate_support_layers(
object, bottom_contacts, top_contacts, layer_storage);
- this->trim_support_layers_by_object(object, top_contacts, m_slicing_params.gap_support_object, m_slicing_params.gap_object_support, m_support_params.gap_xy); // m_slicing_params.soluble_interface ? 0.
+ this->trim_support_layers_by_object(object, top_contacts, m_slicing_params->gap_support_object, m_slicing_params->gap_object_support, m_support_params.gap_xy); // m_slicing_params->soluble_interface ? 0.
#ifdef SLIC3R_DEBUG
for (const MyLayer *layer : top_contacts)
@@ -2045,10 +2045,10 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
// Now apply the contact areas to the layer where they need to be made.
if (! contact_polygons.empty() || ! overhang_polygons.empty()) {
// Allocate the two empty layers.
- auto [new_layer, bridging_layer] = new_contact_layer(*m_print_config, *m_object_config, m_slicing_params, m_support_params.support_layer_height_min, layer, layer_storage, layer_storage_mutex);
+ auto [new_layer, bridging_layer] = new_contact_layer(*m_print_config, *m_object_config, *m_slicing_params, m_support_params.support_layer_height_min, layer, layer_storage, layer_storage_mutex);
if (new_layer) {
// Fill the non-bridging layer with polygons.
- fill_contact_layer(*new_layer, layer_id, m_slicing_params,
+ fill_contact_layer(*new_layer, layer_id, *m_slicing_params,
*m_object_config, slices_margin, overhang_polygons, contact_polygons, enforcer_polygons, lower_layer_polygons,
m_support_params.support_material_flow, no_interface_offset
#ifdef SLIC3R_DEBUG
@@ -2077,7 +2077,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::top_contact_
// Merge close contact layers conservatively: If two layers are closer than the minimum allowed print layer height (the min_layer_height parameter),
// the top contact layer is merged into the bottom contact layer.
- merge_contact_layers(m_slicing_params, m_support_params.support_layer_height_min, contact_out);
+ merge_contact_layers(*m_slicing_params, m_support_params.support_layer_height_min, contact_out);
BOOST_LOG_TRIVIAL(debug) << "PrintObjectSupportMaterial::top_contact_layers() in parallel - end";
@@ -2377,7 +2377,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::bottom_conta
] {
// Find the bottom contact layers above the top surfaces of this layer.
MyLayer *layer_new = detect_bottom_contacts(
- m_slicing_params, m_support_params, object, layer, top_contacts, contact_idx, layer_storage, layer_support_areas, overhangs_for_bottom_contacts
+ *m_slicing_params, m_support_params, object, layer, top_contacts, contact_idx, layer_storage, layer_support_areas, overhangs_for_bottom_contacts
#ifdef SLIC3R_DEBUG
, iRun, polygons_new
#endif // SLIC3R_DEBUG
@@ -2431,7 +2431,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::bottom_conta
} // over all layers downwards
std::reverse(bottom_contacts.begin(), bottom_contacts.end());
- trim_support_layers_by_object(object, bottom_contacts, m_slicing_params.gap_support_object, m_slicing_params.gap_object_support, m_support_params.gap_xy); //m_slicing_params.soluble_interface ? 0.
+ trim_support_layers_by_object(object, bottom_contacts, m_slicing_params->gap_support_object, m_slicing_params->gap_object_support, m_support_params.gap_xy); //m_slicing_params.soluble_interface ? 0.
return bottom_contacts;
}
@@ -2565,10 +2565,10 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
std::sort(extremes.begin(), extremes.end(), layer_extreme_lower);
assert(extremes.empty() ||
- (extremes.front()->extreme_z() > m_slicing_params.raft_interface_top_z - EPSILON &&
- (m_slicing_params.raft_layers() == 1 || // only raft contact layer
+ (extremes.front()->extreme_z() > m_slicing_params->raft_interface_top_z - EPSILON &&
+ (m_slicing_params->raft_layers() == 1 || // only raft contact layer
extremes.front()->layer_type == sltTopContact || // first extreme is a top contact layer
- extremes.front()->extreme_z() > m_slicing_params.first_print_layer_height - EPSILON)));
+ extremes.front()->extreme_z() > m_slicing_params->first_print_layer_height - EPSILON)));
bool synchronize = this->synchronize_layers();
@@ -2589,7 +2589,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
// Intermediate layers are always printed with a normal etrusion flow (non-bridging).
size_t idx_layer_object = 0;
size_t idx_extreme_first = 0;
- if (! extremes.empty() && std::abs(extremes.front()->extreme_z() - m_slicing_params.raft_interface_top_z) < EPSILON) {
+ if (! extremes.empty() && std::abs(extremes.front()->extreme_z() - m_slicing_params->raft_interface_top_z) < EPSILON) {
// This is a raft contact layer, its height has been decided in this->top_contact_layers().
// Ignore this layer when calculating the intermediate support layers.
assert(extremes.front()->layer_type == sltTopContact);
@@ -2598,38 +2598,38 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
for (size_t idx_extreme = idx_extreme_first; idx_extreme < extremes.size(); ++ idx_extreme) {
MyLayer *extr2 = extremes[idx_extreme];
coordf_t extr2z = extr2->extreme_z();
- if (std::abs(extr2z - m_slicing_params.first_print_layer_height) < EPSILON) {
+ if (std::abs(extr2z - m_slicing_params->first_print_layer_height) < EPSILON) {
// This is a bottom of a synchronized (or soluble) top contact layer, its height has been decided in this->top_contact_layers().
assert(extr2->layer_type == sltTopContact);
- assert(extr2->bottom_z == m_slicing_params.first_print_layer_height);
- assert(extr2->print_z >= m_slicing_params.first_print_layer_height + m_support_params.support_layer_height_min - EPSILON);
- if (intermediate_layers.empty() || intermediate_layers.back()->print_z < m_slicing_params.first_print_layer_height) {
+ assert(extr2->bottom_z == m_slicing_params->first_print_layer_height);
+ assert(extr2->print_z >= m_slicing_params->first_print_layer_height + m_support_params.support_layer_height_min - EPSILON);
+ if (intermediate_layers.empty() || intermediate_layers.back()->print_z < m_slicing_params->first_print_layer_height) {
MyLayer &layer_new = layer_allocate(layer_storage, sltIntermediate);
layer_new.bottom_z = 0.;
- layer_new.print_z = m_slicing_params.first_print_layer_height;
- layer_new.height = m_slicing_params.first_print_layer_height;
+ layer_new.print_z = m_slicing_params->first_print_layer_height;
+ layer_new.height = m_slicing_params->first_print_layer_height;
layer_new.height_block = layer_new.height;
intermediate_layers.push_back(&layer_new);
}
continue;
}
- assert(extr2z >= m_slicing_params.raft_interface_top_z + EPSILON);
- assert(extr2z >= m_slicing_params.first_print_layer_height + EPSILON);
+ assert(extr2z >= m_slicing_params->raft_interface_top_z + EPSILON);
+ assert(extr2z >= m_slicing_params->first_print_layer_height + EPSILON);
MyLayer *extr1 = (idx_extreme == idx_extreme_first) ? nullptr : extremes[idx_extreme - 1];
// Fuse a support layer firmly to the raft top interface (not to the raft contacts).
- coordf_t extr1z = (extr1 == nullptr) ? m_slicing_params.raft_interface_top_z : extr1->extreme_z();
+ coordf_t extr1z = (extr1 == nullptr) ? m_slicing_params->raft_interface_top_z : extr1->extreme_z();
assert(extr2z >= extr1z);
assert(extr2z > extr1z || (extr1 != nullptr && extr2->layer_type == sltBottomContact));
if (std::abs(extr1z) < EPSILON) {
// This layer interval starts with the 1st layer. Print the 1st layer using the prescribed 1st layer thickness.
- // assert(! m_slicing_params.has_raft()); RaftingEdition: unclear where the issue is: assert fails with 1-layer raft & base supports
- assert(intermediate_layers.empty() || intermediate_layers.back()->print_z <= m_slicing_params.first_print_layer_height);
+ // assert(! m_slicing_params->has_raft()); RaftingEdition: unclear where the issue is: assert fails with 1-layer raft & base supports
+ assert(intermediate_layers.empty() || intermediate_layers.back()->print_z <= m_slicing_params->first_print_layer_height);
// At this point only layers above first_print_layer_heigth + EPSILON are expected as the other cases were captured earlier.
- assert(extr2z >= m_slicing_params.first_print_layer_height + EPSILON);
+ assert(extr2z >= m_slicing_params->first_print_layer_height + EPSILON);
// Generate a new intermediate layer.
MyLayer &layer_new = layer_allocate(layer_storage, sltIntermediate);
layer_new.bottom_z = 0.;
- layer_new.print_z = extr1z = m_slicing_params.first_print_layer_height;
+ layer_new.print_z = extr1z = m_slicing_params->first_print_layer_height;
layer_new.height = extr1z;
layer_new.height_block = layer_new.height;
intermediate_layers.push_back(&layer_new);
@@ -2646,11 +2646,11 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
// Find the first object layer, which has its print_z in this support Z range.
while (idx_layer_object < object.layers().size() && object.layers()[idx_layer_object]->print_z < extr1z + EPSILON)
++ idx_layer_object;
- if (idx_layer_object == 0 && extr1z == m_slicing_params.raft_interface_top_z) {
+ if (idx_layer_object == 0 && extr1z == m_slicing_params->raft_interface_top_z) {
// Insert one base support layer below the object.
MyLayer &layer_new = layer_allocate(layer_storage, sltIntermediate);
- layer_new.print_z = m_slicing_params.object_print_z_min;
- layer_new.bottom_z = m_slicing_params.raft_interface_top_z;
+ layer_new.print_z = m_slicing_params->object_print_z_min;
+ layer_new.bottom_z = m_slicing_params->raft_interface_top_z;
layer_new.height = layer_new.print_z - layer_new.bottom_z;
layer_new.height_block = layer_new.height;
intermediate_layers.push_back(&layer_new);
@@ -2667,7 +2667,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
}
} else {
// Insert intermediate layers.
- size_t n_layers_extra = size_t(ceil(dist / m_slicing_params.max_suport_layer_height));
+ size_t n_layers_extra = size_t(ceil(dist / m_slicing_params->max_suport_layer_height));
assert(n_layers_extra > 0);
coordf_t step = dist / coordf_t(n_layers_extra);
if (extr1 != nullptr && extr1->layer_type == sltTopContact &&
@@ -2683,16 +2683,16 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::raft_and_int
layer_new.height_block = layer_new.height;
intermediate_layers.push_back(&layer_new);
dist = extr2z - extr1z;
- n_layers_extra = size_t(ceil(dist / m_slicing_params.max_suport_layer_height));
+ n_layers_extra = size_t(ceil(dist / m_slicing_params->max_suport_layer_height));
if (n_layers_extra == 0)
continue;
// Continue printing the other layers up to extr2z.
step = dist / coordf_t(n_layers_extra);
}
- if (! m_slicing_params.soluble_interface && extr2->layer_type == sltTopContact) {
+ if (! m_slicing_params->soluble_interface && extr2->layer_type == sltTopContact) {
// This is a top interface layer, which does not have a height assigned yet. Do it now.
assert(extr2->height == 0.);
- assert(extr1z > m_slicing_params.first_print_layer_height - EPSILON);
+ assert(extr1z > m_slicing_params->first_print_layer_height - EPSILON);
extr2->height = step;
extr2->bottom_z = extr2z = extr2->print_z - step;
if (-- n_layers_extra == 0)
@@ -2882,7 +2882,7 @@ void PrintObjectSupportMaterial::generate_base_layers(
++ iRun;
#endif /* SLIC3R_DEBUG */
- this->trim_support_layers_by_object(object, intermediate_layers, m_slicing_params.gap_support_object, m_slicing_params.gap_object_support, m_support_params.gap_xy); //m_slicing_params.soluble_interface ? 0.
+ this->trim_support_layers_by_object(object, intermediate_layers, m_slicing_params->gap_support_object, m_slicing_params->gap_object_support, m_support_params.gap_xy); //m_slicing_params->soluble_interface ? 0.
}
void PrintObjectSupportMaterial::trim_support_layers_by_object(
@@ -2900,7 +2900,7 @@ void PrintObjectSupportMaterial::trim_support_layers_by_object(
nonempty_layers.reserve(support_layers.size());
for (size_t idx_layer = 0; idx_layer < support_layers.size(); ++ idx_layer) {
MyLayer *support_layer = support_layers[idx_layer];
- if (! support_layer->polygons.empty() && support_layer->print_z >= m_slicing_params.raft_contact_top_z + EPSILON)
+ if (! support_layer->polygons.empty() && support_layer->print_z >= m_slicing_params->raft_contact_top_z + EPSILON)
// Non-empty support layer and not a raft layer.
nonempty_layers.push_back(support_layer);
}
@@ -2914,7 +2914,7 @@ void PrintObjectSupportMaterial::trim_support_layers_by_object(
for (size_t idx_layer = range.begin(); idx_layer < range.end(); ++ idx_layer) {
MyLayer &support_layer = *nonempty_layers[idx_layer];
// BOOST_LOG_TRIVIAL(trace) << "Support generator - trim_support_layers_by_object - trimmming non-empty layer " << idx_layer << " of " << nonempty_layers.size();
- assert(! support_layer.polygons.empty() && support_layer.print_z >= m_slicing_params.raft_contact_top_z + EPSILON);
+ assert(! support_layer.polygons.empty() && support_layer.print_z >= m_slicing_params->raft_contact_top_z + EPSILON);
// Find the overlapping object layers including the extra above / below gap.
coordf_t z_threshold = support_layer.print_z - support_layer.height_block - gap_extra_below + EPSILON;
idx_object_layer_overlapping = idx_higher_or_equal(
@@ -2929,7 +2929,7 @@ void PrintObjectSupportMaterial::trim_support_layers_by_object(
break;
polygons_append(polygons_trimming, offset(object_layer.lslices, gap_xy_scaled, SUPPORT_SURFACES_OFFSET_PARAMETERS));
}
- if (!m_slicing_params.soluble_interface) {
+ if (!m_slicing_params->soluble_interface) {
// Collect all bottom surfaces, which will be extruded with a bridging flow.
for (; i < object.layers().size(); ++ i) {
const Layer &object_layer = *object.layers()[i];
@@ -3000,22 +3000,22 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf
}
// How much to inflate the support columns to be stable. This also applies to the 1st layer, if no raft layers are to be printed.
- const float inflate_factor_fine = float(scale_((m_slicing_params.raft_layers() > 1) ? 0.5 : EPSILON));
+ const float inflate_factor_fine = float(scale_((m_slicing_params->raft_layers() > 1) ? 0.5 : EPSILON));
const float inflate_factor_1st_layer = std::max(0.f, float(scale_(object.config().raft_first_layer_expansion)) - inflate_factor_fine);
MyLayer *contacts = top_contacts .empty() ? nullptr : top_contacts .front();
MyLayer *interfaces = interface_layers .empty() ? nullptr : interface_layers .front();
MyLayer *base_interfaces = base_interface_layers.empty() ? nullptr : base_interface_layers.front();
MyLayer *columns_base = base_layers .empty() ? nullptr : base_layers .front();
- if (contacts != nullptr && contacts->print_z > std::max(m_slicing_params.first_print_layer_height, m_slicing_params.raft_contact_top_z) + EPSILON)
+ if (contacts != nullptr && contacts->print_z > std::max(m_slicing_params->first_print_layer_height, m_slicing_params->raft_contact_top_z) + EPSILON)
// This is not the raft contact layer.
contacts = nullptr;
- if (interfaces != nullptr && interfaces->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON)
+ if (interfaces != nullptr && interfaces->bottom_print_z() > m_slicing_params->raft_interface_top_z + EPSILON)
// This is not the raft column base layer.
interfaces = nullptr;
- if (base_interfaces != nullptr && base_interfaces->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON)
+ if (base_interfaces != nullptr && base_interfaces->bottom_print_z() > m_slicing_params->raft_interface_top_z + EPSILON)
// This is not the raft column base layer.
base_interfaces = nullptr;
- if (columns_base != nullptr && columns_base->bottom_print_z() > m_slicing_params.raft_interface_top_z + EPSILON)
+ if (columns_base != nullptr && columns_base->bottom_print_z() > m_slicing_params->raft_interface_top_z + EPSILON)
// This is not the raft interface layer.
columns_base = nullptr;
@@ -3030,7 +3030,7 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf
// Output vector.
MyLayersPtr raft_layers;
- if (m_slicing_params.raft_layers() > 1) {
+ if (m_slicing_params->raft_layers() > 1) {
Polygons base;
Polygons columns;
if (columns_base != nullptr) {
@@ -3047,30 +3047,30 @@ PrintObjectSupportMaterial::MyLayersPtr PrintObjectSupportMaterial::generate_raf
// Do not add the raft contact layer, only add the raft layers below the contact layer.
// Insert the 1st layer.
{
- MyLayer &new_layer = layer_allocate(layer_storage, (m_slicing_params.base_raft_layers > 0) ? sltRaftBase : sltRaftInterface);
+ MyLayer &new_layer = layer_allocate(layer_storage, (m_slicing_params->base_raft_layers > 0) ? sltRaftBase : sltRaftInterface);
raft_layers.push_back(&new_layer);
- new_layer.print_z = m_slicing_params.first_print_layer_height;
- new_layer.height = m_slicing_params.first_print_layer_height;
+ new_layer.print_z = m_slicing_params->first_print_layer_height;
+ new_layer.height = m_slicing_params->first_print_layer_height;
new_layer.bottom_z = 0.;
new_layer.polygons = inflate_factor_1st_layer > 0 ? expand(base, inflate_factor_1st_layer) : base;
}
// Insert the base layers.
- for (size_t i = 1; i < m_slicing_params.base_raft_layers; ++ i) {
+ for (size_t i = 1; i < m_slicing_params->base_raft_layers; ++ i) {
coordf_t print_z = raft_layers.back()->print_z;
MyLayer &new_layer = layer_allocate(layer_storage, sltRaftBase);
raft_layers.push_back(&new_layer);
- new_layer.print_z = print_z + m_slicing_params.base_raft_layer_height;
- new_layer.height = m_slicing_params.base_raft_layer_height;
+ new_layer.print_z = print_z + m_slicing_params->base_raft_layer_height;
+ new_layer.height = m_slicing_params->base_raft_layer_height;
new_layer.bottom_z = print_z;
new_layer.polygons = base;
}
// Insert the interface layers.
- for (size_t i = 1; i < m_slicing_params.interface_raft_layers; ++ i) {
+ for (size_t i = 1; i < m_slicing_params->interface_raft_layers; ++ i) {
coordf_t print_z = raft_layers.back()->print_z;
MyLayer &new_layer = layer_allocate(layer_storage, sltRaftInterface);
raft_layers.push_back(&new_layer);
- new_layer.print_z = print_z + m_slicing_params.interface_raft_layer_height;
- new_layer.height = m_slicing_params.interface_raft_layer_height;
+ new_layer.print_z = print_z + m_slicing_params->interface_raft_layer_height;
+ new_layer.height = m_slicing_params->interface_raft_layer_height;
new_layer.bottom_z = print_z;
new_layer.polygons = interface_polygons;
//FIXME misusing contact_polygons for support columns.
@@ -3125,7 +3125,7 @@ std::pair<PrintObjectSupportMaterial::MyLayersPtr, PrintObjectSupportMaterial::M
// Contact layer needs a base_interface layer, therefore run the following block if support_material_interface_layers > 0, has soluble support and extruders are different.
bool soluble_interface_non_soluble_base =
// Zero z-gap between the overhangs and the support interface.
- m_slicing_params.soluble_interface &&
+ m_slicing_params->soluble_interface &&
// Interface extruder soluble.
m_object_config->support_material_interface_extruder.value > 0 && m_print_config->filament_soluble.get_at(m_object_config->support_material_interface_extruder.value - 1) &&
// Base extruder: Either "print with active extruder" not soluble.
@@ -3995,32 +3995,32 @@ void PrintObjectSupportMaterial::generate_toolpaths(
float raft_angle_1st_layer = 0.f;
float raft_angle_base = 0.f;
float raft_angle_interface = 0.f;
- if (m_slicing_params.base_raft_layers > 1) {
+ if (m_slicing_params->base_raft_layers > 1) {
// There are all raft layer types (1st layer, base, interface & contact layers) available.
raft_angle_1st_layer = m_support_params.interface_angle;
raft_angle_base = m_support_params.base_angle;
raft_angle_interface = m_support_params.interface_angle;
- } else if (m_slicing_params.base_raft_layers == 1 || m_slicing_params.interface_raft_layers > 1) {
+ } else if (m_slicing_params->base_raft_layers == 1 || m_slicing_params->interface_raft_layers > 1) {
// 1st layer, interface & contact layers available.
raft_angle_1st_layer = m_support_params.base_angle;
if (this->has_support())
// Print 1st layer at 45 degrees from both the interface and base angles as both can land on the 1st layer.
raft_angle_1st_layer += 0.7854f;
raft_angle_interface = m_support_params.interface_angle;
- } else if (m_slicing_params.interface_raft_layers == 1) {
+ } else if (m_slicing_params->interface_raft_layers == 1) {
// Only the contact raft layer is non-empty, which will be printed as the 1st layer.
- assert(m_slicing_params.base_raft_layers == 0);
- assert(m_slicing_params.interface_raft_layers == 1);
- assert(m_slicing_params.raft_layers() == 1 && raft_layers.size() == 0);
+ assert(m_slicing_params->base_raft_layers == 0);
+ assert(m_slicing_params->interface_raft_layers == 1);
+ assert(m_slicing_params->raft_layers() == 1 && raft_layers.size() == 0);
} else {
// No raft.
- assert(m_slicing_params.base_raft_layers == 0);
- assert(m_slicing_params.interface_raft_layers == 0);
- assert(m_slicing_params.raft_layers() == 0 && raft_layers.size() == 0);
+ assert(m_slicing_params->base_raft_layers == 0);
+ assert(m_slicing_params->interface_raft_layers == 0);
+ assert(m_slicing_params->raft_layers() == 0 && raft_layers.size() == 0);
}
// Insert the raft base layers.
- size_t n_raft_layers = size_t(std::max(0, int(m_slicing_params.raft_layers()) - 1));
+ size_t n_raft_layers = size_t(std::max(0, int(m_slicing_params->raft_layers()) - 1));
tbb::parallel_for(tbb::blocked_range<size_t>(0, n_raft_layers),
[this, &support_layers, &raft_layers,
&bbox_object, raft_angle_1st_layer, raft_angle_base, raft_angle_interface, link_max_length_factor]
@@ -4043,7 +4043,7 @@ void PrintObjectSupportMaterial::generate_toolpaths(
// Print the support base below the support columns, or the support base for the support columns plus the contacts.
if (support_layer_id > 0) {
- const Polygons &to_infill_polygons = (support_layer_id < m_slicing_params.base_raft_layers) ?
+ const Polygons &to_infill_polygons = (support_layer_id < m_slicing_params->base_raft_layers) ?
raft_layer.polygons :
//FIXME misusing contact_polygons for support columns.
((raft_layer.contact_polygons == nullptr) ? Polygons() : *raft_layer.contact_polygons);
@@ -4079,7 +4079,7 @@ void PrintObjectSupportMaterial::generate_toolpaths(
filler->angle = raft_angle_1st_layer;
density = float(m_object_config->raft_first_layer_density.value * 0.01);
spacing = m_support_params.first_layer_flow.spacing();
- } else if (support_layer_id >= m_slicing_params.base_raft_layers) {
+ } else if (support_layer_id >= m_slicing_params->base_raft_layers) {
filler->angle = raft_angle_interface;
// We don't use $base_flow->spacing because we need a constant spacing
// value that guarantees that all layers are correctly aligned.
@@ -4101,7 +4101,7 @@ void PrintObjectSupportMaterial::generate_toolpaths(
// Filler and its parameters
filler, density,
// Extrusion parameters
- (support_layer_id < m_slicing_params.base_raft_layers) ? erSupportMaterial : erSupportMaterialInterface, flow, spacing,
+ (support_layer_id < m_slicing_params->base_raft_layers) ? erSupportMaterial : erSupportMaterialInterface, flow, spacing,
m_object->print()->default_region_config());
#ifndef NDEBUG
support_layer.support_fills.visit(verifier);
diff --git a/src/libslic3r/SupportMaterial.hpp b/src/libslic3r/SupportMaterial.hpp
index 680a37063..696b98d9b 100644
--- a/src/libslic3r/SupportMaterial.hpp
+++ b/src/libslic3r/SupportMaterial.hpp
@@ -156,15 +156,15 @@ public:
typedef std::vector<MyLayer*> MyLayersPtr;
public:
- PrintObjectSupportMaterial(const PrintObject *object, const SlicingParameters &slicing_params);
+ PrintObjectSupportMaterial(const PrintObject *object, std::shared_ptr<const SlicingParameters> slicing_params);
// Is raft enabled?
- bool has_raft() const { return m_slicing_params.has_raft(); }
+ bool has_raft() const { return m_slicing_params->has_raft(); }
// Has any support?
bool has_support() const { return m_object_config->support_material.value || m_object_config->support_material_enforce_layers; }
bool build_plate_only() const { return this->has_support() && m_object_config->support_material_buildplate_only.value; }
- bool synchronize_layers() const { return m_slicing_params.soluble_interface && m_object_config->support_material_synchronize_layers.value; }
+ bool synchronize_layers() const { return m_slicing_params->soluble_interface && m_object_config->support_material_synchronize_layers.value; }
bool has_contact_loops() const { return m_object_config->support_material_interface_contact_loops.value; }
// Generate support material for the object.
@@ -255,7 +255,7 @@ private:
const PrintObjectConfig *m_object_config;
// Pre-calculated parameters shared between the object slicer and the support generator,
// carrying information on a raft, 1st layer height, 1st object layer height, gap between the raft and object etc.
- SlicingParameters m_slicing_params;
+ std::shared_ptr<const SlicingParameters> m_slicing_params;
// Various precomputed support parameters to be shared with external functions.
SupportParams m_support_params;
};
diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h
index 1e046c291..8ba78d49a 100644
--- a/src/libslic3r/libslic3r.h
+++ b/src/libslic3r/libslic3r.h
@@ -327,6 +327,33 @@ public:
inline bool empty() const { return size() == 0; }
};
+
+// to check when & how an object is created/copied/deleted
+class Intrumentation {
+public:
+ //SlicingParameters() = default;
+ Intrumentation() {
+ std::cout << "create" << "\n";
+ }
+ Intrumentation(const Intrumentation& sp) {
+ std::cout << "copy" << "\n";
+ }
+ virtual ~Intrumentation() {
+ std::cout << "destroy" << "\n";
+ }
+ Intrumentation& operator=(const Intrumentation& sp) {
+ std::cout << "assign" << "\n";
+ return *this;
+ }
+ Intrumentation(Intrumentation&& sp) {
+ std::cout << "move-copy" << "\n";
+ }
+ Intrumentation& operator=(Intrumentation&& sp) {
+ std::cout << "move-assign" << "\n";
+ return *this;
+ }
+};
+
} // namespace Slic3r
#endif
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index fa9bc02c9..71e76e99f 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -151,7 +151,7 @@ GLCanvas3D::LayersEditing::~LayersEditing()
glsafe(::glDeleteTextures(1, &m_z_texture_id));
m_z_texture_id = 0;
}
- delete m_slicing_parameters;
+ //m_slicing_parameters.reset();
}
const float GLCanvas3D::LayersEditing::THICKNESS_BAR_WIDTH = 70.0f;
@@ -171,8 +171,7 @@ void GLCanvas3D::LayersEditing::init()
void GLCanvas3D::LayersEditing::set_config(const DynamicPrintConfig* config)
{
m_config = config;
- delete m_slicing_parameters;
- m_slicing_parameters = nullptr;
+ m_slicing_parameters.reset();
m_layers_texture.valid = false;
}
@@ -187,8 +186,7 @@ void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id)
(model_object_new != nullptr && m_model_object->id() != model_object_new->id())) {
m_layer_height_profile.clear();
m_layer_height_profile_modified = false;
- delete m_slicing_parameters;
- m_slicing_parameters = nullptr;
+ m_slicing_parameters.reset();
m_layers_texture.valid = false;
this->last_object_id = object_id;
m_model_object = model_object_new;
@@ -574,9 +572,8 @@ void GLCanvas3D::LayersEditing::accept_changes(GLCanvas3D& canvas)
void GLCanvas3D::LayersEditing::update_slicing_parameters()
{
- if (m_slicing_parameters == nullptr) {
- m_slicing_parameters = new SlicingParameters();
- *m_slicing_parameters = PrintObject::slicing_parameters(*m_config, *m_model_object, m_object_max_z);
+ if (!m_slicing_parameters) {
+ m_slicing_parameters = PrintObject::slicing_parameters(*m_config, *m_model_object, m_object_max_z);
}
}
diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp
index 2d6a0a2a4..427ebaf62 100644
--- a/src/slic3r/GUI/GLCanvas3D.hpp
+++ b/src/slic3r/GUI/GLCanvas3D.hpp
@@ -207,7 +207,7 @@ class GLCanvas3D
// Maximum z of the currently selected object (Model::objects[last_object_id]).
float m_object_max_z{ 0.0f };
// Owned by LayersEditing.
- SlicingParameters *m_slicing_parameters{ nullptr };
+ std::shared_ptr<SlicingParameters> m_slicing_parameters{ nullptr };
std::vector<double> m_layer_height_profile;
bool m_layer_height_profile_modified{ false };
diff --git a/src/slic3r/GUI/ScriptExecutor.cpp b/src/slic3r/GUI/ScriptExecutor.cpp
index 5a4a1e2cc..5c5ffbc7c 100644
--- a/src/slic3r/GUI/ScriptExecutor.cpp
+++ b/src/slic3r/GUI/ScriptExecutor.cpp
@@ -626,7 +626,11 @@ void ScriptContainer::init(const std::string& tab_key, Tab* tab)
throw ScriptError("Failed to create script engine.");
}
// The script compiler will send any compiler messages to the callback function
+#ifdef AS_MAX_PORTABILITY
+ m_script_engine->SetMessageCallback(WRAP_FN(as_message_callback), 0, AngelScript::asCALL_GENERIC);
+#else
m_script_engine->SetMessageCallback(AngelScript::asFUNCTION(as_message_callback), 0, AngelScript::asCALL_CDECL);
+#endif
// Configure the script engine with the callback function
AngelScript::RegisterScriptArray(m_script_engine.get(), false);
AngelScript::RegisterStdString(m_script_engine.get());
@@ -756,7 +760,7 @@ std::string get_type_name(ConfigOptionType type)
}
void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const boost::any& value)
{
- if (value.empty())
+ if (value.empty() || !is_intialized())
return;
std::string func_name = ("void " + def.opt_key + "_set(" + get_type_name(def.type) + ")");
AngelScript::asIScriptFunction* func = m_script_module->GetFunctionByDecl(func_name.c_str());
@@ -896,6 +900,9 @@ void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const
boost::any ScriptContainer::call_script_function_get_value(const ConfigOptionDef& def)
{
+ if (!is_intialized())
+ return boost::any();
+
std::string func_name;
switch (def.type) {