mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-30 02:11:59 +00:00
Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
181 lines
11 KiB
Markdown
181 lines
11 KiB
Markdown
# Multiline infill — High Level Design
|
|
|
|
## Purpose and scope
|
|
|
|
`fill_multiline` prints every sparse infill wall as N adjacent lines instead of
|
|
one, so a wall is `d1 = N * spacing` thick. Only internal sparse infill uses it.
|
|
Each pattern first builds its single-line centerlines at N times the usual line
|
|
spacing (so the density holds), and `multiline_fill()` then replaces each
|
|
centerline by the lines of that wall: the centerline itself when N is odd, and
|
|
closed outlines around it at every `spacing` out to `d1 / 2`. The outlines are
|
|
clipped to the fill region contracted by half a line width, then connected like
|
|
any other infill. Clipping also cuts an outline at its first point, which may be
|
|
anywhere along a line, so `join_cut_outlines()` joins the pieces back first.
|
|
|
|
Outlines of centerlines that cross each other overlap at every crossing, which
|
|
over-extrudes the wall intersections. `sparse_infill_strategy` chooses what the
|
|
line-crossing patterns Grid, Triangles, Tri-hexagon, Cubic, Quarter Cubic,
|
|
Adaptive Cubic and Support Cubic do about it. Non-crossing builds centerlines
|
|
that never cross (`FillRectilinear::fill_surface_trapezoidal()`, and `FillAdaptive`
|
|
for the two octree patterns). With a single line, `d1 = spacing` and those
|
|
centerlines are printed as they are. Crossing keeps the straight lines of the
|
|
single-line pattern and prints each wall as N copies of its line, `spacing`
|
|
apart: the `FillRectilinear` patterns slice the region with the copies, as
|
|
Rectilinear does, and `FillAdaptive` shifts copies of each octree segment. The
|
|
walls overlap where they cross.
|
|
Default crosses with one line and turns back with more. `make_fills()` resolves
|
|
Default per region before grouping the surfaces, so regions that print the same
|
|
paths share a fill. 3D Honeycomb skips `multiline_fill()` and draws
|
|
its N lines itself as parallel copies of each wave, which never cross
|
|
(`Fill3DHoneycomb`). Rectilinear, Aligned Rectilinear, Lateral Lattice and
|
|
Lateral Honeycomb have only parallel lines, so they skip `multiline_fill()` too:
|
|
`FillRectilinear::fill_surface_by_multilines()` slices the region with N copies
|
|
of each line, `spacing` apart, and the clipping leaves no outline to join. The
|
|
two families of the lateral patterns run in one direction and slide over each
|
|
other with z, so their walls overlap on some layers. The walls of one direction
|
|
are therefore laid out together: walls that overlap print as one wall, of as
|
|
many lines `spacing` apart as its width holds, centered on it. Neither a gap nor
|
|
overlapping lines show where two walls meet, and the layout is the same as two
|
|
walls where they just touch and as one where they coincide. The other patterns
|
|
outline their usual centerlines.
|
|
|
|
## Non-crossing centerlines
|
|
|
|
The crossing lines are resolved into x-monotone paths, the levels of the line
|
|
arrangement: walking along x, the k-th path is always the k-th line from the
|
|
bottom. At every crossing, the two paths bounce off each other instead of
|
|
passing through. Adjacent paths meet only at crossings, so their outlines touch
|
|
there and nowhere overlap.
|
|
|
|
Where two paths meet, each is cut short by a line perpendicular to the bisector
|
|
of its bend, `d1 / 2` from the crossing. The two cut segments are parallel and
|
|
`d1` apart, so the outermost lines of the two walls sit exactly `spacing` apart,
|
|
like the lines inside a wall. Where three lines meet at one point, the middle
|
|
path runs straight through and the outer two are cut `d1` from it.
|
|
|
|
Each pattern builds its rows along x in a rotated frame. Grid lines run at ±45°
|
|
there, and its rows are trapezoid waves that transpose on alternate layers. The three families of Triangles, Tri-hexagon and
|
|
Cubic run at 0°, 60° and 120°. Those rows rotate by 120° every layer about a
|
|
3-fold center of the arrangement, so each family takes every role in turn.
|
|
The pattern is phased on fixed positions, so it lines up across layers and
|
|
across the regions of one layer. Rounding the corners with
|
|
`sparse_infill_smooth_factor` happens before `multiline_fill()`, and only these
|
|
paths have corners to round: the crossing lines are straight.
|
|
|
|
Each region builds only the rows over its bounding box in that frame, and
|
|
outlines only the centerlines within `d1 / 2` of it, the ones whose outlines
|
|
reach it. Every row is monotone along its direction, so each outline is started
|
|
on the cap at the first end of its centerline, outside the region, and clipping
|
|
to the region cuts it only where it crosses the boundary.
|
|
|
|
## Cubic
|
|
|
|
Single-line Cubic draws the three families at the same spacing `h` and shifts
|
|
them with z: by `+dx`, `-dx` and `+dx`, `dx = z / sqrt(2)`. The multiline paths
|
|
follow the same lines. In the frame where one family is horizontal, the other two
|
|
cross in rows `h` apart, alternating by half a period, at height
|
|
`tau = -3 * dx (mod h)` above the horizontal line below them. The crossings split
|
|
every band between horizontal lines into up-pointing triangles of height `tau`,
|
|
down-pointing triangles of height `h - tau`, and hexagons. At `tau = 0` (and `h`)
|
|
all three families meet at common points, as in Triangles. At `tau = h / 2` the
|
|
triangles are equal, as in Tri-hexagon. The origin of that frame is always a
|
|
3-fold center, whatever z is, so the per-layer rotation keeps the lines in place.
|
|
|
|
Each band holds two paths that touch at its crossings: the upper one takes the
|
|
V below the crossing and runs along the top horizontal line, and the lower one
|
|
takes the inverted V above it and runs along the bottom line. Both are the same function
|
|
of `tau`, the lower one mirrored with `h - tau`. `cubic_upper_level()` builds one
|
|
period of the upper path as the lower envelope of five lines, clipped from below:
|
|
|
|
- the two slanted lines through the crossings,
|
|
- the horizontal line, lowered when the triangle above it is less than `1.5 * d1` high,
|
|
- the two chamfers where the path turns onto and off the horizontal line, `d1 / 2`
|
|
from those crossings,
|
|
- the flat cut into the V at the crossing.
|
|
|
|
The cut height `clamp(tau - d1 / 2, 0, h - d1) + d1` is what makes the pattern
|
|
continuous in z. While both triangles are at least `1.5 * d1` high, every
|
|
crossing is a pair of bends `d1 / 2` from it, as in Tri-hexagon. When a triangle
|
|
is thinner, its three paths stack like a triple crossing. The path through it
|
|
flattens toward its base line and lies on it once the triangle is under `d1 / 2`
|
|
high, and the paths beside it are pushed `d1` away. The layout thus reaches the
|
|
Triangles one where the families meet. Adjacent paths stay at least `d1` apart
|
|
at every `tau` and at every density up to 100%.
|
|
|
|
## Quarter Cubic
|
|
|
|
Single-line Quarter Cubic draws two pairs of parallel lines, one pair
|
|
perpendicular to the other. With `u` and `v` along the two directions, the lines
|
|
lie at `u = +-a` and `v = +-b` modulo the period `P = 4 * d1 / density`, and `a`
|
|
and `b` change with z in different phases. The multiline paths follow the same
|
|
lines.
|
|
|
|
The rows run at 45° to the lines, like those of Grid, and transpose on alternate
|
|
layers, which maps the lines onto themselves. Along a row, a path is a staircase:
|
|
it rises along a line of `u` to a crossing, falls along a line of `v` to the next
|
|
one, and so on. Every crossing is a peak of one staircase and a valley of another,
|
|
each cut `d1 / 2` from it, so their walls touch there. There are two shapes of
|
|
staircase, one with the gaps between the lines in the order `2 * b`, `2 * a`,
|
|
`P - 2 * b`, `P - 2 * a`, and the other in the order `P - 2 * b`, `2 * a`, `2 * b`,
|
|
`P - 2 * a`. A period along `u` moves each staircase onto the next of its shape.
|
|
|
|
Like the single-line pattern, `a` and `b` stay `d1 / 2` from `0` and `P / 2`, so
|
|
two parallel lines come together until their walls touch. The cuts take
|
|
`d1 / sqrt(2)` from each end of a segment between two bends, which does not fit
|
|
on a segment shorter than `sqrt(2) * d1`, between lines that close. The two
|
|
crossings of such a segment then move apart along y, each by half of what it
|
|
lacks, until the bends of its staircase are level. That staircase runs straight
|
|
from one line to the other, the flats of the staircases above and below it stay
|
|
`d1` away from it, and everything else stays on the lines. A move along one
|
|
direction leaves the segments along the other unchanged, so the moves of both
|
|
directions add up where both pairs are close, at high density. The longer gap
|
|
of a pair has room for them, as `P` is at least `4 * d1`.
|
|
|
|
## Adaptive Cubic
|
|
|
|
Adaptive Cubic and Support Cubic take their lines from an octree of cubes
|
|
standing on a corner. On each layer every cube cuts its three mid-planes into
|
|
segments of the same three 60° families as Cubic, but the pattern is not
|
|
periodic. Smaller cubes near the surface add finer lines, and a finer line ends
|
|
where it meets the wall of its coarser cube, so the lines form crossings and
|
|
T-junctions. `FillAdaptive::multiline_paths()` builds the paths from these
|
|
segments directly, for each fill region and within `4 * d1` of it.
|
|
|
|
At a crossing the two paths bounce as in Cubic. At a T-junction the through line
|
|
runs straight on and the path of the ending line stops there. Every path still
|
|
runs left to right in the frame where one family is horizontal, and that family
|
|
rotates with the layer.
|
|
|
|
Every line of every cube size lies on one fine lattice, so crossings closer than
|
|
a few `d1` are the corners of one small triangle of that lattice, as in Cubic.
|
|
The cuts follow the Cubic rules without a closed formula:
|
|
|
|
- The two bends of a crossing are cut `d1` apart, `d1 / 2` each, perpendicular
|
|
to their bisector, so their walls touch. A cut goes no further than the path
|
|
end, and the other bend takes the rest of `d1`.
|
|
- At the tip of a small triangle, between the two slanted families, a cut also
|
|
goes no further than the neighbouring bend turning the other way, and the
|
|
path beyond that bend is kept a wall away from it. The bends onto the
|
|
horizontal family are not limited this way: pushing their paths apart would
|
|
open gaps between walls that should touch.
|
|
- A cut moves the path only where the cut line lies beyond it, near its bend.
|
|
The sharp bends between the two slanted families are cut after the bends onto
|
|
the horizontal family, so the tip of a small triangle wins, as in Cubic.
|
|
- A path stopping at a T-junction is trimmed until it is `d1` less half a line
|
|
spacing from every other path, so that its end overlaps the wall it stops on
|
|
by half a line and bonds to it. The paths are trimmed one at a time against
|
|
the others as already trimmed, so two ends facing each other meet instead of
|
|
both backing off. A path stopping on the line of another is trimmed before
|
|
that one, so it gives way and the other still reaches the line it stops on. A
|
|
second round trims every path again from its full length, so an end grows
|
|
back where the ends it gave way to were trimmed later, and a last round only
|
|
shortens them, keeping them that far apart. Paths shorter than `d1` are left
|
|
out.
|
|
- A line that ends on another less than `2 * d1` past a crossing stops at that
|
|
crossing instead, the shorter one where both do. The path along such a stub
|
|
would be trimmed away, leaving a hole between the walls that were cut to
|
|
touch it.
|
|
|
|
Short paths enclosed by coarser lines still print as closed outlines, but most
|
|
paths run on across several cells.
|