diff --git a/xs/src/Layer.cpp b/xs/src/Layer.cpp index fc77f9c3a..69f9fb13a 100644 --- a/xs/src/Layer.cpp +++ b/xs/src/Layer.cpp @@ -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() { diff --git a/xs/src/Layer.hpp b/xs/src/Layer.hpp index bae59ec66..a36d15c48 100644 --- a/xs/src/Layer.hpp +++ b/xs/src/Layer.hpp @@ -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(); diff --git a/xs/src/Print.cpp b/xs/src/Print.cpp index 4f7e8d7e3..686d84e6c 100644 --- a/xs/src/Print.cpp +++ b/xs/src/Print.cpp @@ -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) { diff --git a/xs/src/Print.hpp b/xs/src/Print.hpp index c1b8ee155..e1b321653 100644 --- a/xs/src/Print.hpp +++ b/xs/src/Print.hpp @@ -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 > 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, diff --git a/xs/xsp/Layer.xsp b/xs/xsp/Layer.xsp index c63b3665f..504dbfac9 100644 --- a/xs/xsp/Layer.xsp +++ b/xs/xsp/Layer.xsp @@ -9,10 +9,8 @@ %name{Slic3r::Layer::Region} class LayerRegion { // owned by Layer, no constructor/destructor - Ref layer() - %code%{ RETVAL = THIS->layer; %}; - Ref region() - %code%{ RETVAL = THIS->region; %}; + Ref layer(); + Ref region(); Ref 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 object() - %code%{ RETVAL = THIS->object; %}; + int id(); + Ref object(); Ref upper_layer() %code%{ RETVAL = THIS->upper_layer; %}; Ref lower_layer() diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index b48869db1..329fd49a8 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -47,8 +47,7 @@ _constant() Ref config() %code%{ RETVAL = &THIS->config; %}; - Ref print() - %code%{ RETVAL = THIS->print; %}; + Ref print(); Ref 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() - %code%{ RETVAL = THIS->print; %}; - Ref model_object() - %code%{ RETVAL = THIS->model_object; %}; + Ref print(); + Ref model_object(); Ref config() %code%{ RETVAL = &THIS->config; %}; Points copies()