Wipe tower postprocessing, wipe tower block on 3D plate improved.

- it renders red with one egde as indeterminate, the front edge is where the wipe tower will start
- changing width changes depth of the block (as requested)
- the block shows the brim of the wipe tower
- after slicing, the block is rendered in usual dark green and takes the exact shape of the tower (also with brim)
- moving or rotationg the block after slicing does not invalidate the wipe tower (and hence the exact block dimensions are preserved)
- changing anything that invalidates the wipe tower reverts the block back to the "indeterminate" shape
- the block is not shown after slicing, if the wipe tower is not actually generated (printing single color object with the wipe tower enabled)

This required changes in the wipe tower generator, which now generates the tower
at origin with no rotation. Resulting gcode is postprocessed and transformed during
gcode export. This means the wipe tower needs not be invalidated when it is moved or rotated.
This commit is contained in:
Lukas Matena 2018-07-27 15:56:27 +02:00
parent dd724e9dab
commit d5f042b4b8
14 changed files with 264 additions and 77 deletions

View file

@ -25,18 +25,30 @@ public:
bool operator==(const xy &rhs) const { return x == rhs.x && y == rhs.y; }
bool operator!=(const xy &rhs) const { return x != rhs.x || y != rhs.y; }
// Rotate the point around given point about given angle (in degrees)
// shifts the result so that point of rotation is in the middle of the tower
xy rotate(const xy& origin, float width, float depth, float angle) const {
// Rotate the point around center of the wipe tower about given angle (in degrees)
xy rotate(float width, float depth, float angle) const {
xy out(0,0);
float temp_x = x - width / 2.f;
float temp_y = y - depth / 2.f;
angle *= M_PI/180.;
out.x += (temp_x - origin.x) * cos(angle) - (temp_y - origin.y) * sin(angle);
out.y += (temp_x - origin.x) * sin(angle) + (temp_y - origin.y) * cos(angle);
return out + origin;
out.x += temp_x * cos(angle) - temp_y * sin(angle) + width / 2.f;
out.y += temp_x * sin(angle) + temp_y * cos(angle) + depth / 2.f;
return out;
}
// Rotate the point around origin about given angle in degrees
void rotate(float angle) {
float temp_x = x * cos(angle) - y * sin(angle);
y = x * sin(angle) + y * cos(angle);
x = temp_x;
}
void translate(const xy& vect) {
x += vect.x;
y += vect.y;
}
float x;
float y;
};
@ -104,6 +116,9 @@ public:
// This is useful not only for the print time estimation, but also for the control of layer cooling.
float elapsed_time;
// Is this a priming extrusion? (If so, the wipe tower rotation & translation will not be applied later)
bool priming;
// Sum the total length of the extrusion.
float total_extrusion_length_in_plane() {
float e_length = 0.f;