Skip to content

Commit

Permalink
General improvements to filling
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Kennard committed Sep 10, 2011
1 parent 8270845 commit 5de93f3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
38 changes: 23 additions & 15 deletions e3d-fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fill_perimeter (slice_t * slice, poly_dim_t width, int loops, int fast)
p[l] = q;
q = poly_inset (q, (l + 1 < loops) ? width : width / 2);
if (fast)
poly_tidy (q, width / 8); // inner surfaces need way less detail
poly_tidy (q, width / 10); // inner surfaces need way less detail
}
slice->fill = q;
// process loops in reverse order
Expand Down Expand Up @@ -202,31 +202,39 @@ fill_area (stl_t * stl, poly_dim_t width, int layers)
}

static void
fill (int e, stl_t * s, slice_t * a, polygon_t * p, int dir, poly_dim_t width, double density)
fill (int e, stl_t * s, slice_t * a, polygon_t * p, int dir, poly_dim_t width, double density, double fillflow)
{
if (density <= 0)
return;
if (!p || !p->contours)
return;
polygon_t *q = poly_inset (p, width / 2);
poly_dim_t w = s->max.x - s->min.x, y, d = width * sqrtl (2.0), dy = d * (2.0 / density), iy = dy - d;
poly_dim_t w = s->max.x - s->min.x, y, d = width * sqrtl (2.0), dy = d * 2.0, iy = dy - d;
int flag = 0;
if (density < 1)
{ // sparse fill
dy = d * (2.0 * fillflow / density);
//iy = dy - d;
iy = dy / 2;
flag = 1;
}
for (y = s->min.y - w; y < s->max.y + dy; y += dy)
{
polygon_t *n = poly_new ();
poly_dim_t oy = y + (d * dir / 4) % dy;
poly_dim_t oy = y + (d * dir / 4 + ((dir / 2 % 2) * dy / 2)) % dy;
if (dir & 1)
{
poly_add (n, s->min.x, oy, 0);
poly_add (n, s->min.x, oy + iy, 0);
poly_add (n, s->max.x, oy + w + iy, 0);
poly_add (n, s->max.x, oy + w, 0);
poly_add (n, s->min.x, oy, flag);
poly_add (n, s->min.x, oy + iy, flag);
poly_add (n, s->max.x, oy + w + iy, flag);
poly_add (n, s->max.x, oy + w, flag);
}
else
{
poly_add (n, s->max.x, oy + iy, 0);
poly_add (n, s->max.x, oy, 0);
poly_add (n, s->min.x, oy + w, 0);
poly_add (n, s->min.x, oy + w + iy, 0);
poly_add (n, s->max.x, oy + iy, flag);
poly_add (n, s->max.x, oy, flag);
poly_add (n, s->min.x, oy + w, flag);
poly_add (n, s->min.x, oy + w + iy, flag);
}
prefix_extrude (&a->extrude[e], poly_clip (POLY_INTERSECT, 2, n, q));
poly_free (n);
Expand All @@ -235,14 +243,14 @@ fill (int e, stl_t * s, slice_t * a, polygon_t * p, int dir, poly_dim_t width, d
}

void
fill_extrude (stl_t * s, poly_dim_t width, double density)
fill_extrude (stl_t * s, poly_dim_t width, double density, double fillflow)
{ // Generate extrude path for fills
int layer = 0;
slice_t *a;
for (a = s->slices; a; a = a->next)
{
fill (EXTRUDE_FILL, s, a, a->infill, layer, width, density);
fill (EXTRUDE_FILL, s, a, a->solid, layer, width, 1);
fill (EXTRUDE_FILL, s, a, a->infill, layer, width, density, fillflow);
fill (EXTRUDE_FILL, s, a, a->solid, layer, width, 1, 1);
// flying layer done differently - outside in plot
polygon_t *q = poly_inset (a->flying, width / 2);
while (q && q->contours)
Expand Down
2 changes: 1 addition & 1 deletion e3d-fill.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

void fill_perimeter (slice_t *, poly_dim_t width, int loops, int fast); // create perimeter and remaining fill area
void fill_area (stl_t * stl, poly_dim_t width, int layers); // Break down fill areas based on layers
void fill_extrude (stl_t * stl, poly_dim_t width, double density); // Generate extrude path for fills
void fill_extrude (stl_t * stl, poly_dim_t width, double density,double fillflow); // Generate extrude path for fills
void fill_anchor (stl_t * stl, int loops, poly_dim_t width, poly_dim_t offset, poly_dim_t step); // Add anchor to layer 0
15 changes: 10 additions & 5 deletions e3d-gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

unsigned int
gcode_out (const char *filename, stl_t * stl, double flowrate, poly_dim_t layer, poly_dim_t speed0, poly_dim_t speed, poly_dim_t zspeed, double back,
poly_dim_t hop, int mirror, double anchorflow, int eplaces, int tempbed, int temp0, int temp, int quiet)
poly_dim_t hop, int mirror, double anchorflow, double fillflow, int eplaces, int tempbed, int temp0, int temp, int quiet)
{ // returns time estimate in seconds
FILE *o = fopen (filename, "w");
if (!o)
Expand Down Expand Up @@ -119,10 +119,14 @@ gcode_out (const char *filename, stl_t * stl, double flowrate, poly_dim_t layer,
move (v->x, v->y, z + hop, back);
}
move (v->x, v->y, z, 0);
double flow = (c->vertices->flag ? fillflow : 1);
for (v = c->vertices->next; v; v = v->next)
extrude (v->x, v->y, z, speed, flowrate);
{
extrude (v->x, v->y, z, speed, flowrate * flow);
flow = (v->flag ? fillflow : 1);
}
v = c->vertices;
extrude (v->x, v->y, z, speed, flowrate);
extrude (v->x, v->y, z, speed, flowrate * flow);
}
}
// layers
Expand All @@ -149,8 +153,9 @@ gcode_out (const char *filename, stl_t * stl, double flowrate, poly_dim_t layer,
plot_loops (s->extrude[e], speed0, flowrate, 1); // flying layer - in order it was made
if (s == stl->slices && temp && temp0 != temp)
{
move (cx, cy, z + hop * 2, back);
fprintf (o, "M109 S%d\n", temp);
//move (cx, cy, z + hop * 2, back);
//fprintf (o, "M109 S%d\n", temp);
fprintf (o, "M108 S%d\n", temp);
}
z += layer;
s = s->next;
Expand Down
2 changes: 1 addition & 1 deletion e3d-gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
#include "e3d.h"

unsigned int gcode_out (const char *filename, stl_t * stl, double feedrate, poly_dim_t layer, poly_dim_t speed0, poly_dim_t speed, poly_dim_t zspeed,
double back, poly_dim_t hop, int mirror, double anchorflow, int eplaces,int tempbed,int temp0,int temp,int quiet);
double back, poly_dim_t hop, int mirror, double anchorflow, double fillflow,int eplaces,int tempbed,int temp0,int temp,int quiet);
7 changes: 5 additions & 2 deletions e3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ main (int argc, const char *argv[])
double anchorgap = 2;
double anchorstep = 5;
double anchorflow = 2;
double infillflow = 1.5;
double filament = 2.9;
double packing = 1;
double speed = 50;
Expand Down Expand Up @@ -89,13 +90,14 @@ main (int argc, const char *argv[])
{"anchor-gap", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &anchorgap, 0, "Gap between perimeter and anchor in widths", "Widths"},
{"anchor-step", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &anchorstep, 0, "Spacing of joins between perimeter and anchor in widths", "Widths"},
{"anchor-flow", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &anchorflow, 0, "Extrude multiplier for anchor join loop", "Ratio"},
{"infill-flow", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &infillflow, 0, "Extrude multiplier for sparse infill", "Ratio"},
{"filament", 'f', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &filament, 0, "Filament diameter", "Units"},
{"packing", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &packing, 0, "Multiplier for feed rate", "Ratio"},
{"speed", 'S', POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &speed, 0, "Speed", "Units/sec"},
{"speed0", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &speed0, 0, "Speed (layer0)", "Units/sec"},
{"z-speed", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &zspeed, 0, "Max Z Speed", "Units/sec"},
{"temp0", 0, POPT_ARG_INT, &temp0, 0, "Set layer 0 temp (M109)", "C"},
{"temp", 0, POPT_ARG_INT, &temp, 0, "Set temp (M109)", "C"},
{"temp", 0, POPT_ARG_INT, &temp, 0, "Set temp", "C"},
{"bed", 0, POPT_ARG_INT, &tempbed, 0, "Set temp of bed (M140)", "C"},
{"hop", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &hop, 0, "Hop up when moving and not extruding", "Units"},
{"back", 0, POPT_ARGFLAG_SHOW_DEFAULT | POPT_ARG_DOUBLE, &back, 0, "Pull back extrude when not extruding", "Units"},
Expand Down Expand Up @@ -214,7 +216,7 @@ main (int argc, const char *argv[])
for (; s; s = s->next)
fill_perimeter (s, width, skins + (((count++) & 1) ? altskins : 0), fast);
fill_area (stl, width, layers);
fill_extrude (stl, width, density);
fill_extrude (stl, width, density, infillflow);
}

if (anchorloops)
Expand All @@ -238,6 +240,7 @@ main (int argc, const char *argv[])
{
unsigned int t =
gcode_out (gcodefile, stl, layer * layer * widthratio / filament / filament * packing, l, speed0s, speeds, zspeeds, back, hops, mirror, anchorflow,
infillflow,
eplaces, tempbed, temp0, temp, quiet);
if (!quiet)
{
Expand Down

0 comments on commit 5de93f3

Please sign in to comment.