Minor issue when dealing with files with empty layers at bottom. #2553

This commit is contained in:
Alessandro Ranellucci 2015-01-18 12:35:05 +01:00
parent f11196525b
commit 9f0283f808
4 changed files with 18 additions and 9 deletions

View File

@ -291,7 +291,7 @@ sub slice {
while (@{$self->layers} && !@{$self->get_layer(0)->slices}) { while (@{$self->layers} && !@{$self->get_layer(0)->slices}) {
shift @{$self->layers}; shift @{$self->layers};
for (my $i = 0; $i <= $#{$self->layers}; $i++) { for (my $i = 0; $i <= $#{$self->layers}; $i++) {
$self->get_layer($i)->id( $self->get_layer($i)->id-1 ); $self->get_layer($i)->set_id( $self->get_layer($i)->id-1 );
} }
} }

View File

@ -6,7 +6,7 @@
namespace Slic3r { namespace Slic3r {
Layer::Layer(int id, PrintObject *object, coordf_t height, coordf_t print_z, Layer::Layer(size_t id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z) coordf_t slice_z)
: _id(id), : _id(id),
_object(object), _object(object),
@ -35,12 +35,18 @@ Layer::~Layer()
this->clear_regions(); this->clear_regions();
} }
int size_t
Layer::id() Layer::id() const
{ {
return this->_id; return this->_id;
} }
void
Layer::set_id(size_t id)
{
this->_id = id;
}
PrintObject* PrintObject*
Layer::object() Layer::object()
{ {
@ -147,7 +153,7 @@ REGISTER_CLASS(Layer, "Layer");
#endif #endif
SupportLayer::SupportLayer(int id, PrintObject *object, coordf_t height, SupportLayer::SupportLayer(size_t id, PrintObject *object, coordf_t height,
coordf_t print_z, coordf_t slice_z) coordf_t print_z, coordf_t slice_z)
: Layer(id, object, height, print_z, slice_z) : Layer(id, object, height, print_z, slice_z)
{ {

View File

@ -72,7 +72,8 @@ class Layer {
friend class PrintObject; friend class PrintObject;
public: public:
int id(); size_t id() const;
void set_id(size_t id);
PrintObject* object(); PrintObject* object();
Layer *upper_layer; Layer *upper_layer;
@ -97,11 +98,11 @@ class Layer {
template <class T> bool any_bottom_region_slice_contains(const T &item) const; template <class T> bool any_bottom_region_slice_contains(const T &item) const;
protected: protected:
int _id; // sequential number of layer, 0-based size_t _id; // sequential number of layer, 0-based
PrintObject *_object; PrintObject *_object;
Layer(int 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);
virtual ~Layer(); virtual ~Layer();
@ -119,7 +120,7 @@ class SupportLayer : public Layer {
ExtrusionEntityCollection support_interface_fills; ExtrusionEntityCollection support_interface_fills;
protected: protected:
SupportLayer(int 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);
virtual ~SupportLayer(); virtual ~SupportLayer();
}; };

View File

@ -35,6 +35,7 @@
// owned by PrintObject, no constructor/destructor // owned by PrintObject, no constructor/destructor
int id(); int id();
void set_id(int id);
Ref<PrintObject> object(); Ref<PrintObject> object();
Ref<Layer> upper_layer() Ref<Layer> upper_layer()
%code%{ RETVAL = THIS->upper_layer; %}; %code%{ RETVAL = THIS->upper_layer; %};
@ -89,6 +90,7 @@
// copies of some Layer methods, because the parameter wrapper code // copies of some Layer methods, because the parameter wrapper code
// gets confused about getting a Layer::Support instead of a Layer // gets confused about getting a Layer::Support instead of a Layer
int id(); int id();
void set_id(int id);
Ref<PrintObject> object(); Ref<PrintObject> object();
Ref<SupportLayer> upper_layer() Ref<SupportLayer> upper_layer()
%code%{ RETVAL = (SupportLayer*)THIS->upper_layer; %}; %code%{ RETVAL = (SupportLayer*)THIS->upper_layer; %};