Fixed a regression bug from the last commit. Some more code simplification
and inlining.
This commit is contained in:
parent
efb1fd2066
commit
e1ca1a82fb
5 changed files with 48 additions and 133 deletions
|
@ -9,61 +9,22 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
|
||||||
coordf_t slice_z)
|
|
||||||
: upper_layer(NULL),
|
|
||||||
lower_layer(NULL),
|
|
||||||
slicing_errors(false),
|
|
||||||
slice_z(slice_z),
|
|
||||||
print_z(print_z),
|
|
||||||
height(height),
|
|
||||||
_id(id),
|
|
||||||
_object(object)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Layer::~Layer()
|
Layer::~Layer()
|
||||||
{
|
{
|
||||||
// remove references to self
|
this->lower_layer = this->upper_layer = nullptr;
|
||||||
if (NULL != this->upper_layer) {
|
for (LayerRegion *region : this->regions)
|
||||||
this->upper_layer->lower_layer = NULL;
|
delete region;
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL != this->lower_layer) {
|
|
||||||
this->lower_layer->upper_layer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->clear_regions();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Layer::clear_regions()
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < this->regions.size(); ++ i)
|
|
||||||
delete this->regions[i];
|
|
||||||
this->regions.clear();
|
this->regions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerRegion*
|
LayerRegion* Layer::add_region(PrintRegion* print_region)
|
||||||
Layer::add_region(PrintRegion* print_region)
|
|
||||||
{
|
{
|
||||||
LayerRegion* region = new LayerRegion(this, print_region);
|
this->regions.emplace_back(new LayerRegion(this, print_region));
|
||||||
this->regions.push_back(region);
|
return this->regions.back();
|
||||||
return region;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Layer::delete_region(int idx)
|
|
||||||
{
|
|
||||||
LayerRegionPtrs::iterator i = this->regions.begin() + idx;
|
|
||||||
LayerRegion* item = *i;
|
|
||||||
this->regions.erase(i);
|
|
||||||
delete item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge all regions' slices to get islands
|
// merge all regions' slices to get islands
|
||||||
void
|
void Layer::make_slices()
|
||||||
Layer::make_slices()
|
|
||||||
{
|
{
|
||||||
ExPolygons slices;
|
ExPolygons slices;
|
||||||
if (this->regions.size() == 1) {
|
if (this->regions.size() == 1) {
|
||||||
|
@ -95,8 +56,7 @@ Layer::make_slices()
|
||||||
this->slices.expolygons.push_back(STDMOVE(slices[i]));
|
this->slices.expolygons.push_back(STDMOVE(slices[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Layer::merge_slices()
|
||||||
Layer::merge_slices()
|
|
||||||
{
|
{
|
||||||
if (this->regions.size() == 1) {
|
if (this->regions.size() == 1) {
|
||||||
// Optimization, also more robust. Don't merge classified pieces of layerm->slices,
|
// Optimization, also more robust. Don't merge classified pieces of layerm->slices,
|
||||||
|
@ -111,8 +71,7 @@ Layer::merge_slices()
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool
|
bool Layer::any_internal_region_slice_contains(const T &item) const
|
||||||
Layer::any_internal_region_slice_contains(const T &item) const
|
|
||||||
{
|
{
|
||||||
FOREACH_LAYERREGION(this, layerm) {
|
FOREACH_LAYERREGION(this, layerm) {
|
||||||
if ((*layerm)->slices.any_internal_contains(item)) return true;
|
if ((*layerm)->slices.any_internal_contains(item)) return true;
|
||||||
|
@ -122,8 +81,7 @@ Layer::any_internal_region_slice_contains(const T &item) const
|
||||||
template bool Layer::any_internal_region_slice_contains<Polyline>(const Polyline &item) const;
|
template bool Layer::any_internal_region_slice_contains<Polyline>(const Polyline &item) const;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
bool
|
bool Layer::any_bottom_region_slice_contains(const T &item) const
|
||||||
Layer::any_bottom_region_slice_contains(const T &item) const
|
|
||||||
{
|
{
|
||||||
FOREACH_LAYERREGION(this, layerm) {
|
FOREACH_LAYERREGION(this, layerm) {
|
||||||
if ((*layerm)->slices.any_bottom_contains(item)) return true;
|
if ((*layerm)->slices.any_bottom_contains(item)) return true;
|
||||||
|
@ -136,8 +94,7 @@ template bool Layer::any_bottom_region_slice_contains<Polyline>(const Polyline &
|
||||||
// Here the perimeters are created cummulatively for all layer regions sharing the same parameters influencing the perimeters.
|
// Here the perimeters are created cummulatively for all layer regions sharing the same parameters influencing the perimeters.
|
||||||
// The perimeter paths and the thin fills (ExtrusionEntityCollection) are assigned to the first compatible layer region.
|
// The perimeter paths and the thin fills (ExtrusionEntityCollection) are assigned to the first compatible layer region.
|
||||||
// The resulting fill surface is split back among the originating regions.
|
// The resulting fill surface is split back among the originating regions.
|
||||||
void
|
void Layer::make_perimeters()
|
||||||
Layer::make_perimeters()
|
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for layer " << this->id();
|
BOOST_LOG_TRIVIAL(trace) << "Generating perimeters for layer " << this->id();
|
||||||
|
|
||||||
|
@ -276,10 +233,4 @@ void Layer::export_region_fill_surfaces_to_svg_debug(const char *name)
|
||||||
this->export_region_fill_surfaces_to_svg(debug_out_path("Layer-fill_surfaces-%s-%d.svg", name, idx ++).c_str());
|
this->export_region_fill_surfaces_to_svg(debug_out_path("Layer-fill_surfaces-%s-%d.svg", name, idx ++).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SupportLayer::SupportLayer(size_t id, PrintObject *object, coordf_t height,
|
|
||||||
coordf_t print_z, coordf_t slice_z)
|
|
||||||
: Layer(id, object, height, print_z, slice_z)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,15 +130,13 @@ protected:
|
||||||
size_t _id; // sequential number of layer, 0-based
|
size_t _id; // sequential number of layer, 0-based
|
||||||
PrintObject *_object;
|
PrintObject *_object;
|
||||||
|
|
||||||
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
|
||||||
coordf_t slice_z);
|
upper_layer(nullptr), lower_layer(nullptr), slicing_errors(false),
|
||||||
|
slice_z(slice_z), print_z(print_z), height(height),
|
||||||
|
_id(id), _object(object) {}
|
||||||
virtual ~Layer();
|
virtual ~Layer();
|
||||||
|
|
||||||
void clear_regions();
|
|
||||||
void delete_region(int idx);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SupportLayer : public Layer {
|
class SupportLayer : public Layer {
|
||||||
friend class PrintObject;
|
friend class PrintObject;
|
||||||
|
|
||||||
|
@ -149,12 +147,11 @@ public:
|
||||||
ExtrusionEntityCollection support_fills;
|
ExtrusionEntityCollection support_fills;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SupportLayer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
|
SupportLayer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z, coordf_t slice_z) :
|
||||||
coordf_t slice_z);
|
Layer(id, object, height, print_z, slice_z) {}
|
||||||
virtual ~SupportLayer() {}
|
virtual ~SupportLayer() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,7 +158,6 @@ public:
|
||||||
|
|
||||||
// print_z: top of the layer; slice_z: center of the layer.
|
// print_z: top of the layer; slice_z: center of the layer.
|
||||||
Layer* add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z);
|
Layer* add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z);
|
||||||
void delete_layer(int idx);
|
|
||||||
|
|
||||||
size_t support_layer_count() const { return this->support_layers.size(); }
|
size_t support_layer_count() const { return this->support_layers.size(); }
|
||||||
void clear_support_layers();
|
void clear_support_layers();
|
||||||
|
|
|
@ -58,16 +58,14 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
|
||||||
this->layer_height_profile = model_object->layer_height_profile;
|
this->layer_height_profile = model_object->layer_height_profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool PrintObject::add_copy(const Pointf &point)
|
||||||
PrintObject::add_copy(const Pointf &point)
|
|
||||||
{
|
{
|
||||||
Points points = this->_copies;
|
Points points = this->_copies;
|
||||||
points.push_back(Point::new_scale(point.x, point.y));
|
points.push_back(Point::new_scale(point.x, point.y));
|
||||||
return this->set_copies(points);
|
return this->set_copies(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool PrintObject::delete_last_copy()
|
||||||
PrintObject::delete_last_copy()
|
|
||||||
{
|
{
|
||||||
Points points = this->_copies;
|
Points points = this->_copies;
|
||||||
points.pop_back();
|
points.pop_back();
|
||||||
|
@ -86,7 +84,8 @@ bool PrintObject::set_copies(const Points &points)
|
||||||
std::vector<Points::size_type> ordered_copies;
|
std::vector<Points::size_type> ordered_copies;
|
||||||
Slic3r::Geometry::chained_path(points, ordered_copies);
|
Slic3r::Geometry::chained_path(points, ordered_copies);
|
||||||
|
|
||||||
for (Point copy : ordered_copies) {
|
for (size_t point_idx : ordered_copies) {
|
||||||
|
Point copy = points[point_idx];
|
||||||
copy.translate(this->_copies_shift);
|
copy.translate(this->_copies_shift);
|
||||||
this->_shifted_copies.push_back(copy);
|
this->_shifted_copies.push_back(copy);
|
||||||
}
|
}
|
||||||
|
@ -94,68 +93,39 @@ bool PrintObject::set_copies(const Points &points)
|
||||||
return this->_print->invalidate_step(psSkirt) || this->_print->invalidate_step(psBrim);
|
return this->_print->invalidate_step(psSkirt) || this->_print->invalidate_step(psBrim);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool PrintObject::reload_model_instances()
|
||||||
PrintObject::reload_model_instances()
|
|
||||||
{
|
{
|
||||||
Points copies;
|
Points copies;
|
||||||
for (ModelInstancePtrs::const_iterator i = this->_model_object->instances.begin(); i != this->_model_object->instances.end(); ++i) {
|
copies.reserve(this->_model_object->instances.size());
|
||||||
copies.push_back(Point::new_scale((*i)->offset.x, (*i)->offset.y));
|
for (const ModelInstance *mi : this->_model_object->instances)
|
||||||
}
|
copies.emplace_back(Point::new_scale(mi->offset.x, mi->offset.y));
|
||||||
return this->set_copies(copies);
|
return this->set_copies(copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintObject::clear_layers()
|
||||||
PrintObject::clear_layers()
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < this->layers.size(); ++ i) {
|
for (Layer *l : this->layers)
|
||||||
Layer *layer = this->layers[i];
|
delete l;
|
||||||
layer->upper_layer = layer->lower_layer = nullptr;
|
|
||||||
delete layer;
|
|
||||||
}
|
|
||||||
this->layers.clear();
|
this->layers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer*
|
Layer* PrintObject::add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z)
|
||||||
PrintObject::add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z)
|
|
||||||
{
|
{
|
||||||
Layer* layer = new Layer(id, this, height, print_z, slice_z);
|
layers.push_back(new Layer(id, this, height, print_z, slice_z));
|
||||||
layers.push_back(layer);
|
return layers.back();
|
||||||
return layer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintObject::clear_support_layers()
|
||||||
PrintObject::delete_layer(int idx)
|
|
||||||
{
|
{
|
||||||
LayerPtrs::iterator i = this->layers.begin() + idx;
|
for (Layer *l : this->support_layers)
|
||||||
delete *i;
|
delete l;
|
||||||
this->layers.erase(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PrintObject::clear_support_layers()
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < this->support_layers.size(); ++ i) {
|
|
||||||
Layer *layer = this->support_layers[i];
|
|
||||||
layer->upper_layer = layer->lower_layer = nullptr;
|
|
||||||
delete layer;
|
|
||||||
}
|
|
||||||
this->support_layers.clear();
|
this->support_layers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SupportLayer*
|
SupportLayer* PrintObject::add_support_layer(int id, coordf_t height, coordf_t print_z)
|
||||||
PrintObject::add_support_layer(int id, coordf_t height, coordf_t print_z)
|
|
||||||
{
|
{
|
||||||
SupportLayer* layer = new SupportLayer(id, this, height, print_z, -1);
|
support_layers.emplace_back(new SupportLayer(id, this, height, print_z, -1));
|
||||||
support_layers.push_back(layer);
|
return support_layers.back();
|
||||||
return layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PrintObject::delete_support_layer(int idx)
|
|
||||||
{
|
|
||||||
SupportLayerPtrs::iterator i = this->support_layers.begin() + idx;
|
|
||||||
delete *i;
|
|
||||||
this->support_layers.erase(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
|
bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_option_key> &opt_keys)
|
||||||
|
@ -493,8 +463,7 @@ void PrintObject::detect_surfaces_type()
|
||||||
} // for each $self->print->region_count
|
} // for each $self->print->region_count
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintObject::process_external_surfaces()
|
||||||
PrintObject::process_external_surfaces()
|
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "Processing external surfaces...";
|
BOOST_LOG_TRIVIAL(info) << "Processing external surfaces...";
|
||||||
|
|
||||||
|
@ -524,8 +493,7 @@ struct DiscoverVerticalShellsCacheEntry
|
||||||
Polygons bottom_fill_surfaces;
|
Polygons bottom_fill_surfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void PrintObject::discover_vertical_shells()
|
||||||
PrintObject::discover_vertical_shells()
|
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
||||||
|
@ -1085,7 +1053,9 @@ void PrintObject::_slice()
|
||||||
if (layer->regions[region_id] != nullptr && ! layer->regions[region_id]->slices.empty())
|
if (layer->regions[region_id] != nullptr && ! layer->regions[region_id]->slices.empty())
|
||||||
// Non empty layer.
|
// Non empty layer.
|
||||||
goto end;
|
goto end;
|
||||||
this->delete_layer(int(this->layers.size()) - 1);
|
delete layer;
|
||||||
|
this->layers.pop_back();
|
||||||
|
this->layers.back()->upper_layer = nullptr;
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
;
|
;
|
||||||
|
@ -1229,7 +1199,9 @@ std::string PrintObject::_fix_slicing_errors()
|
||||||
|
|
||||||
// remove empty layers from bottom
|
// remove empty layers from bottom
|
||||||
while (! this->layers.empty() && this->layers.front()->slices.expolygons.empty()) {
|
while (! this->layers.empty() && this->layers.front()->slices.expolygons.empty()) {
|
||||||
this->delete_layer(0);
|
delete this->layers.front();
|
||||||
|
this->layers.erase(this->layers.begin());
|
||||||
|
this->layers.front()->lower_layer = nullptr;
|
||||||
for (size_t i = 0; i < this->layers.size(); ++ i)
|
for (size_t i = 0; i < this->layers.size(); ++ i)
|
||||||
this->layers[i]->set_id(this->layers[i]->id() - 1);
|
this->layers[i]->set_id(this->layers[i]->id() - 1);
|
||||||
}
|
}
|
||||||
|
@ -1258,8 +1230,7 @@ void PrintObject::_simplify_slices(double distance)
|
||||||
BOOST_LOG_TRIVIAL(debug) << "Slicing objects - siplifying slices in parallel - end";
|
BOOST_LOG_TRIVIAL(debug) << "Slicing objects - siplifying slices in parallel - end";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintObject::_make_perimeters()
|
||||||
PrintObject::_make_perimeters()
|
|
||||||
{
|
{
|
||||||
if (this->state.is_done(posPerimeters)) return;
|
if (this->state.is_done(posPerimeters)) return;
|
||||||
this->state.set_started(posPerimeters);
|
this->state.set_started(posPerimeters);
|
||||||
|
@ -1368,8 +1339,7 @@ PrintObject::_make_perimeters()
|
||||||
this->state.set_done(posPerimeters);
|
this->state.set_done(posPerimeters);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void PrintObject::_infill()
|
||||||
PrintObject::_infill()
|
|
||||||
{
|
{
|
||||||
if (this->state.is_done(posInfill)) return;
|
if (this->state.is_done(posInfill)) return;
|
||||||
this->state.set_started(posInfill);
|
this->state.set_started(posInfill);
|
||||||
|
|
|
@ -94,14 +94,12 @@ _constant()
|
||||||
Ref<Layer> get_layer(int idx);
|
Ref<Layer> get_layer(int idx);
|
||||||
Ref<Layer> add_layer(int id, coordf_t height, coordf_t print_z,
|
Ref<Layer> add_layer(int id, coordf_t height, coordf_t print_z,
|
||||||
coordf_t slice_z);
|
coordf_t slice_z);
|
||||||
void delete_layer(int idx);
|
|
||||||
|
|
||||||
size_t support_layer_count();
|
size_t support_layer_count();
|
||||||
void clear_support_layers();
|
void clear_support_layers();
|
||||||
Ref<SupportLayer> get_support_layer(int idx);
|
Ref<SupportLayer> get_support_layer(int idx);
|
||||||
Ref<SupportLayer> add_support_layer(int id, coordf_t height, coordf_t print_z);
|
Ref<SupportLayer> add_support_layer(int id, coordf_t height, coordf_t print_z);
|
||||||
void delete_support_layer(int idx);
|
|
||||||
|
|
||||||
bool invalidate_state_by_config_options(std::vector<std::string> opt_keys);
|
bool invalidate_state_by_config_options(std::vector<std::string> opt_keys);
|
||||||
bool invalidate_step(PrintObjectStep step);
|
bool invalidate_step(PrintObjectStep step);
|
||||||
bool invalidate_all_steps();
|
bool invalidate_all_steps();
|
||||||
|
|
Loading…
Reference in a new issue