Make read-only constructor parameters - private.

master
Y. Sapir 2014-05-19 23:38:10 +03:00
parent 76738dc66b
commit 22b05cb187
6 changed files with 81 additions and 32 deletions

View File

@ -4,8 +4,8 @@
namespace Slic3r {
LayerRegion::LayerRegion(Layer *layer, PrintRegion *region)
: layer(layer),
region(region)
: _layer(layer),
_region(region)
{
}
@ -13,6 +13,18 @@ LayerRegion::~LayerRegion()
{
}
Layer*
LayerRegion::layer()
{
return this->_layer;
}
PrintRegion*
LayerRegion::region()
{
return this->_region;
}
#ifdef SLIC3RXS
REGISTER_CLASS(LayerRegion, "Layer::Region");
#endif
@ -20,8 +32,8 @@ REGISTER_CLASS(LayerRegion, "Layer::Region");
Layer::Layer(int id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z)
: id(id),
object(object),
: _id(id),
_object(object),
upper_layer(NULL),
lower_layer(NULL),
regions(),
@ -47,6 +59,19 @@ Layer::~Layer()
this->clear_regions();
}
int
Layer::id()
{
return this->_id;
}
PrintObject*
Layer::object()
{
return this->_object;
}
size_t
Layer::region_count()
{

View File

@ -24,8 +24,8 @@ class LayerRegion
friend class Layer;
public:
Layer *layer;
PrintRegion *region;
Layer* layer();
PrintRegion* region();
// collection of surfaces generated by slicing the original geometry
// divided by type top/bottom/internal
@ -51,6 +51,9 @@ class LayerRegion
ExtrusionEntityCollection fills;
private:
Layer *_layer;
PrintRegion *_region;
LayerRegion(Layer *layer, PrintRegion *region);
~LayerRegion();
};
@ -62,8 +65,9 @@ class Layer {
friend class PrintObject;
public:
int id; // sequential number of layer, 0-based
PrintObject *object;
int id();
PrintObject* object();
Layer *upper_layer;
Layer *lower_layer;
LayerRegionPtrs regions;
@ -84,6 +88,9 @@ class Layer {
void delete_region(int idx);
protected:
int _id; // sequential number of layer, 0-based
PrintObject *_object;
Layer(int id, PrintObject *object, coordf_t height, coordf_t print_z,
coordf_t slice_z);
virtual ~Layer();

View File

@ -48,7 +48,7 @@ REGISTER_CLASS(PrintState, "Print::State");
PrintRegion::PrintRegion(Print* print)
: config(), print(print)
: config(), _print(print)
{
}
@ -56,10 +56,16 @@ PrintRegion::~PrintRegion()
{
}
Print*
PrintRegion::print()
{
return this->_print;
}
PrintConfig &
PrintRegion::print_config()
{
return print->config;
return this->_print->config;
}
#ifdef SLIC3RXS
@ -69,10 +75,10 @@ REGISTER_CLASS(PrintRegion, "Print::Region");
PrintObject::PrintObject(Print* print, ModelObject* model_object,
const BoundingBoxf3 &modobj_bbox)
: print(print),
model_object(model_object)
: _print(print),
_model_object(model_object)
{
region_volumes.resize(print->regions.size());
region_volumes.resize(this->_print->regions.size());
// Compute the translation to be applied to our meshes so that we work with smaller coordinates
{
@ -97,6 +103,18 @@ PrintObject::~PrintObject()
{
}
Print*
PrintObject::print()
{
return this->_print;
}
ModelObject*
PrintObject::model_object()
{
return this->_model_object;
}
void
PrintObject::add_region_volume(int region_id, int volume_id)
{

View File

@ -46,11 +46,13 @@ class PrintRegion
public:
PrintRegionConfig config;
Print* print;
Print* print();
PrintConfig &print_config();
private:
Print* _print;
PrintRegion(Print* print);
virtual ~PrintRegion();
};
@ -65,9 +67,6 @@ class PrintObject
friend class Print;
public:
Print* print;
ModelObject* model_object;
// vector of (vectors of volume ids), indexed by region_id
std::vector<std::vector<int> > region_volumes;
Points copies; // Slic3r::Point objects in scaled G-code coordinates
@ -89,6 +88,10 @@ class PrintObject
// TODO: Fill* fill_maker => (is => 'lazy');
PrintState _state;
Print* print();
ModelObject* model_object();
// adds region_id, too, if necessary
void add_region_volume(int region_id, int volume_id);
@ -107,6 +110,9 @@ class PrintObject
void delete_support_layer(int idx);
private:
Print* _print;
ModelObject* _model_object;
// TODO: call model_object->get_bounding_box() instead of accepting
// parameter
PrintObject(Print* print, ModelObject* model_object,

View File

@ -9,10 +9,8 @@
%name{Slic3r::Layer::Region} class LayerRegion {
// owned by Layer, no constructor/destructor
Ref<Layer> layer()
%code%{ RETVAL = THIS->layer; %};
Ref<PrintRegion> region()
%code%{ RETVAL = THIS->region; %};
Ref<Layer> layer();
Ref<PrintRegion> region();
Ref<SurfaceCollection> slices()
%code%{ RETVAL = &THIS->slices; %};
@ -33,10 +31,8 @@
%name{Slic3r::Layer} class Layer {
// owned by PrintObject, no constructor/destructor
int id()
%code%{ RETVAL = THIS->id; %};
Ref<PrintObject> object()
%code%{ RETVAL = THIS->object; %};
int id();
Ref<PrintObject> object();
Ref<Layer> upper_layer()
%code%{ RETVAL = THIS->upper_layer; %};
Ref<Layer> lower_layer()

View File

@ -47,8 +47,7 @@ _constant()
Ref<PrintRegionConfig> config()
%code%{ RETVAL = &THIS->config; %};
Ref<Print> print()
%code%{ RETVAL = THIS->print; %};
Ref<Print> print();
Ref<PrintConfig> print_config()
%code%{ RETVAL = &THIS->print_config(); %};
};
@ -64,12 +63,10 @@ _constant()
RETVAL = THIS->region_volumes[region_id];
%};
int region_count()
%code%{ RETVAL = THIS->print->regions.size(); %};
%code%{ RETVAL = THIS->print()->regions.size(); %};
Ref<Print> print()
%code%{ RETVAL = THIS->print; %};
Ref<ModelObject> model_object()
%code%{ RETVAL = THIS->model_object; %};
Ref<Print> print();
Ref<ModelObject> model_object();
Ref<PrintObjectConfig> config()
%code%{ RETVAL = &THIS->config; %};
Points copies()