Refactoring: new method in Flow for calculating spacing between extrusions having different width

This commit is contained in:
Alessandro Ranellucci 2014-06-12 09:15:40 +02:00
parent 8ee11b3239
commit 6194cbf530
4 changed files with 26 additions and 10 deletions

View file

@ -40,7 +40,7 @@ Flow::new_from_spacing(float spacing, float nozzle_diameter, float height, bool
float
Flow::spacing() const {
if (this->bridge) {
return width + BRIDGE_EXTRA_SPACING;
return this->width + BRIDGE_EXTRA_SPACING;
}
float min_flow_spacing;
@ -54,6 +54,21 @@ Flow::spacing() const {
return this->width - OVERLAP_FACTOR * (this->width - min_flow_spacing);
}
/* This method returns the centerline spacing between an extrusion using this
flow and another one using another flow.
this->spacing(other) shall return the same value as other.spacing(*this) */
float
Flow::spacing(const Flow &other) const {
assert(this->height == other.height);
assert(this->bridge == other.bridge);
if (this->bridge) {
return this->width/2 + other.width/2 + BRIDGE_EXTRA_SPACING;
}
return this->spacing()/2 + other.spacing()/2;
}
/* This method returns extrusion volume per head move unit. */
double
Flow::mm3_per_mm() const {

View file

@ -29,6 +29,7 @@ class Flow
Flow(float _w, float _h, float _nd, bool _bridge = false)
: width(_w), height(_h), nozzle_diameter(_nd), bridge(_bridge) {};
float spacing() const;
float spacing(const Flow &other) const;
double mm3_per_mm() const;
coord_t scaled_width() const {
return scale_(this->width);

View file

@ -24,6 +24,8 @@
bool bridge()
%code{% RETVAL = THIS->bridge; %};
float spacing();
float spacing_to(Flow* other)
%code{% RETVAL = THIS->spacing(*other); %};
long scaled_width();
long scaled_spacing();
double mm3_per_mm();