diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 5a7091121..56279223a 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -32,14 +32,6 @@ sub support_layers { return [ map $self->get_support_layer($_), 0..($self->support_layer_count - 1) ]; } -# this is the *total* layer count (including support layers) -# this value is not supposed to be compared with $layer->id -# since they have different semantics -sub total_layer_count { - my $self = shift; - return $self->layer_count + $self->support_layer_count; -} - # this should be idempotent sub slice { my $self = shift; diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index 868a3d775..27ba83780 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -114,13 +114,14 @@ class PrintObject // adds region_id, too, if necessary void add_region_volume(int region_id, int volume_id); - size_t layer_count(); + size_t total_layer_count() const; + size_t layer_count() const; void clear_layers(); Layer* get_layer(int idx); 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(); + size_t support_layer_count() const; void clear_support_layers(); SupportLayer* get_support_layer(int idx); SupportLayer* add_support_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index e8d4eb788..16c904cfb 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -131,8 +131,17 @@ PrintObject::add_region_volume(int region_id, int volume_id) region_volumes[region_id].push_back(volume_id); } +/* This is the *total* layer count (including support layers) + this value is not supposed to be compared with Layer::id + since they have different semantics */ size_t -PrintObject::layer_count() +PrintObject::total_layer_count() const +{ + return this->layer_count() + this->support_layer_count(); +} + +size_t +PrintObject::layer_count() const { return this->layers.size(); } @@ -167,7 +176,7 @@ PrintObject::delete_layer(int idx) } size_t -PrintObject::support_layer_count() +PrintObject::support_layer_count() const { return this->support_layers.size(); } diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 60135f4a1..2213a9511 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -88,6 +88,7 @@ _constant() void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges) %code%{ THIS->layer_height_ranges = layer_height_ranges; %}; + size_t total_layer_count(); size_t layer_count(); void clear_layers(); Ref get_layer(int idx);