Files
OrcaSlicer/docs/HLSD/precise-seam.md
T
Damir Galeev aefb6b3d66 Precise Seam: intersect modifiers with the model surface, not the perimeter centerline (#17557)
* Precise Seam: intersect modifiers with the model surface, not the perimeter centerline

A modifier acted where it crossed the centerline of the printed perimeter, which
lies about half a line width inside the model surface and deeper at corners. It
now acts where it crosses the model surface.

- The surface is reconstructed from the centerline by a shift of half the
  external perimeter width less the XY compensation and a 5 um margin, clipped
  against the modifier and carried back onto the centerline.
- On elephant foot layers and with Arachne the shift is measured against the
  layer's islands.
- With fuzzy skin the perimeter generator keeps the centerline before texturing
  (ExtrusionLoop::untextured); modifiers are evaluated on it and the points are
  carried onto the noisy loop.
- Open extrusions are left out of Precise Seam.
- The "had no effect" warning no longer names the centerline.

See docs/HLSD/precise-seam.md.

* Precise Seam: fuzzy skin window per loop kind; no negative search reach

The transfer window of a fuzzy skin loop counted every region with fuzzy
skin on the layer, including those that do not texture its kind (a Hole
region for contours, an External one for holes). FuzzySkin.cpp skips such
regions, so mixed settings widened the transfer search and the weak zone
order check. The window is now computed for contours and holes separately
from the regions should_fuzzify() selects, as a function in
PreciseSeamInternal.hpp with a unit test.

The modifier prefilter of the measured shift no longer takes a negative
reach: a compensation beyond the whole wall depth leaves no shift.

* Precise Seam: shift narrow classic loops by their own line; keep the warning translations

Without thin wall detection the classic generator prints an island too narrow for
two lines with a thinner line and insets the loop by half of that width, while the
surface shift used the region's external perimeter width. The reconstructed
surface lay 0.055 x spacing - 5 um outside the model, more than the margin, so a
modifier flush against the face acted on such loops. The shift of a classic loop
now comes from the width of its own external perimeter path; Arachne loops are
measured as before.

The two "had no effect on the seam" messages lost their bracketed part, and the
catalogs dropped the old entries without getting the new ones. The entries are
back under the new msgids with the existing translations, trimmed of the
bracketed part.

* Precise Seam: keep the aligned seam inside an Enforced modifier zone

A loop with an Enforced zone in effect now has exact ends: alignment no longer
moves the seam up to 0.2 mm past a zone boundary, and Random does not sample
the edge leaving the zone.

* Precise Seam: test both ends of an Enforced zone in alignment

The regression test for the aligned seam leaving an Enforced modifier zone
ran on the right face only, where the stepping end of the zone is the last
candidate of the Enforced run. It now also runs on the left face, where the
same end is the first candidate, so both directions of the allowed arc are
checked.

The HLSD notes that a zone reduced to a single candidate holds the aligned
seam on it, so alignment cannot smooth its shift between layers.
2026-11-23 18:32:08 +08:00

62 KiB

Precise Seam — High Level Design

Purpose and scope

Precise Seam lets a helper volume decide where the seam of an object goes. The user attaches a mesh to an object as a Precise Seam modifier. On every layer, the part of the external perimeter that lies inside the modifier's slice determines where the seam must, may or must not be placed. The helper is a persistent model object rather than paint on the surface, so it keeps working when the design changes. A body swept along a path on the surface can guide the seam along any trajectory.

The modifier is non-printing geometry. It takes no part in object slicing, region assignment, filament selection or brim adhesion, and it affects only seam placement during G-code export. Objects without Precise Seam volumes follow the regular seam placement unchanged.

Precise Seam does not replace the seam placer. It feeds it: a modifier inserts the points it needs into the perimeter and changes the enforced/blocked type of seam candidates, the same typing mechanism as seam painting, and the configured seam position then chooses among them.

Modifier types

Precise Seam adds six ModelVolumeType values after SUPPORT_ENFORCER, strong types first and weak types after them. is_precise_seam(), is_precise_seam_strong() and is_precise_seam_weak() are range checks that depend on this order.

Type Group Effect on an intersected perimeter
PRECISE_SEAM_CENTER strong seam at the midpoint, by arc length, of the intersection
PRECISE_SEAM_LEFT strong seam at the first point of the intersection
PRECISE_SEAM_RIGHT strong seam at the last point of the intersection
PRECISE_SEAM_ENFORCED weak intersection marked as enforced
PRECISE_SEAM_BLOCKED weak intersection marked as blocked
PRECISE_SEAM_NEUTRAL weak intersection reset to neutral

A strong modifier fixes a single point. The perimeter gets exactly one enforced seam candidate there, and every other candidate is blocked. A weak modifier retypes, and where needed adds, the candidates inside its intersection, like painting does.

An intersection is a continuous part of the external perimeter's centerline whose model surface lies inside the modifier's slice on that layer. It is a portion of the perimeter, never a chord through the object. The centerline lies about half an extrusion width inside the printed wall and is invisible to the user, who places modifiers against the model surface. Extraction therefore reconstructs that surface from the centerline, clips it, and carries the result back onto the centerline along the normal (see Surface reconstruction). A modifier acts when it reaches the reconstructed surface, which lies a margin of 5 µm inside the model surface, and has no effect when it stays inside the body, even if it crosses the centerline. A modifier that enters the model by less than the margin does not act. An open extrusion (a thin wall printed as one line) is left out: its G-code does not depend on where the seam is.

Terms

  • Segment: an intersection as the code represents it (PerimeterSegment). User-facing texts call it an intersection.
  • Fragment: a piece of the perimeter returned by clipping, before it is tied to the source contour.
  • Interval: the bound part of one source edge, given by the edge index and a parameter range on that edge.
  • Zone: a weak segment with its type (Enforced, Blocked or Neutral).
  • Boundary: an end of a zone, inserted into the perimeter polygon.
  • Candidate: a seam candidate of the seam placer, built from the points of the processed perimeter polygon (painted enforcers may add more).

First and last are taken along the perimeter oriented counter-clockwise as seen from above. On an outer wall seen from outside, Left is therefore the left end of the intersection. On the wall of a hole seen from inside the hole, the two ends are swapped. Mirroring an object does not mirror the mode: perimeters stay counter-clockwise, so Left remains the left end seen from outside, and the seam moves to the other end of the modifier instead of following the mirrored model.

Priority

The order of volumes in the object is the priority order, highest first. ModelObject::sort_volumes() keeps every strong modifier before every weak one and preserves the user's order within each group. The object list lets the user drag a modifier only within its own group. A type change that crosses the group boundary moves the volume to the end of its new group, with the lowest priority there.

  • Strong: modifiers are tried in priority order on each perimeter. The first one that yields a usable segment decides the seam. Within that modifier the longest segment wins; lengths are never compared across modifiers. Once a strong point is placed, no later strong modifier and no weak modifier is processed for that perimeter.
  • Weak: every weak modifier applies. They are applied from the lowest priority to the highest, so the highest one overwrites overlapping zones.

A strong modifier without a usable segment, even one whose fragments were all discarded, passes the turn to the next one.

Data flow

  1. Invalidation. Print::apply() treats a change of Precise Seam volumes as a change of seam placement and invalidates G-code export; the object is not resliced (see Print invalidation).
  2. Modifier slices. SeamPlacer::init() collects each object's Precise Seam volumes once, slices every volume separately and caches its regions with their bounding boxes.
  3. Perimeters. Seam candidates are gathered in parallel over the layers. For objects with Precise Seam volumes, each external perimeter polygon is normalized and prepared once for all modifiers.
  4. Extraction. For each modifier, the perimeter is clipped against the modifier's regions on that layer. The clipped fragments are bound back to the source edges of the perimeter and assembled into segments.
  5. Strong, then weak. Strong modifiers try to insert one seam point into the perimeter polygon. If none succeeds, weak modifiers insert their zone boundaries and subdivide enforced edges.
  6. Candidates. The seam placer builds candidates from the modified polygon. Painting assigns types first, weak zones overwrite them, and a strong point makes its candidate the only enforced one.
  7. Selection and restoration. The configured seam position chooses the seams and aligns them. Afterwards the exact strong points are restored.
  8. Warnings. After all objects are processed, SeamPlacer::init() prepares one combined warning text if any problem was found; G-code export issues it.

Modifier slices

init_precise_seam_data() collects the Precise Seam volumes of each object: strong ones in priority order and weak ones in reverse, so that weak zones can be applied with last-write-wins. Each volume is sliced separately with PrintObject::slice_single_volume_regions(), at the object's layer heights and with the same centered transformation as the object. The slices keep every region's outer contour together with its holes as an ExPolygon. Volumes are not merged, so each keeps its own priority, and a modifier may have several regions on one layer.

prepare_modifier_slices() moves the slices into ModifierRegionsCache, pairing each region with the bounding box of its exterior. Empty layers keep their slots, so the cache is indexed by object layer; Layer::id() includes raft layers, which are subtracted. The cache is filled before candidates are gathered and is only read afterwards, shared by both modifier kinds and all worker threads without locking.

Perimeter preparation

The seam placer works on external perimeter loops, including the walls of holes. Precise Seam processes closed loops only: an open extrusion (a thin wall printed as one line) keeps its ordinary seam candidates, and modifiers are not evaluated on it. A modifier that crosses only such a wall has no effect, and the "had no effect" warning names it when it was evaluated on a closed loop. For objects with Precise Seam volumes, consecutive duplicate points and the repeated closing point of each extrusion loop are removed: adjacent extrusion paths share endpoints, and the resulting zero-length edges would prevent point insertion at their junctions. Distinct visits to one point of a self-touching contour are kept. Objects without Precise Seam volumes keep their original points, so ordinary seam candidates are unaffected.

Each polygon is made counter-clockwise. A single PreparedPerimeter is then built for all modifiers of that perimeter. It holds a validity check (at least three points, no consecutive or closing duplicates), the bounding box, the clipping line (the polygon as an open polyline with its first point repeated at the end), the side of the air (outside a contour, inside a hole, by the loop role) and the surface shift. The surface line is built from it on the first request, so perimeters that no modifier approaches never pay for it.

The surface shift is the distance from the centerline to the model surface the user sees, less a margin. Its nominal value is d = w/2 - c - m:

  • w is the region's nominal external perimeter width, the flow the perimeter generator uses for the outer loop on that layer, first layer included. A loop of the classic generator takes the width of its own outer wall line instead (ExtrusionPath::width of its first external perimeter path): with thin wall detection off, an island too narrow for two lines and short enough is printed with a thinner line, inset by half of that width. Bridged paths lie on the same centerline with the overhang flow's width and are not asked; a loop without an external perimeter path keeps the region's width.
  • c is the XY compensation that moved this wall away from the model, positive towards air: xy_contour_compensation for a contour and minus xy_hole_compensation for a hole (a positive value enlarges holes). It is zero where slicing skips compensation, for multi-material painting with several filaments. It is also zero for a hole on a layer with several regions when the hole setting is negative: slicing then clips the regions by the compensated islands, and clipping cannot add the material that would make the hole smaller. Both values are taken once per object in SeamPlacer::init(), so they describe the outer contours and holes of the object. A wall on the boundary between two regions of one object is compensated differently by slicing, and there the surface is not restored exactly (see Known limitations). Modifier slices are not compensated, so they stay in the frame of the model.
  • m is SURFACE_MARGIN (5 µm). A modifier face placed flush against a model face would otherwise touch the reconstructed surface by rounding noise and act on some layers only; the margin moves that unstable position 5 µm deep, where it is not reached by accident.

Measured shift. On the layers with elephant foot compensation (printing directly on the bed, below elefant_foot_compensation_layers) and on every layer of Arachne perimeters (not in spiral vase mode, which uses the classic generator), the centerline does not lie at depth w/2: elephant foot compensation shrinks the contour the perimeters are built on by an amount that changes along it, and Arachne lines vary in width. There the shift is measured: d(P) = D(P) - c' - m at a point P of the centerline, where D(P) is the depth of P below the boundary of the layer's islands (Layer::lslices) and c' the part of c those islands contain. The depth is the offset from P to the nearest point of the boundary, projected on the normal of the edge (at a vertex, the larger of the projections on its two edges' normals). At an inner corner the nearest point is the corner of the boundary, farther away than either side; its projections are the distances to the sides.

  • Slicing stores the islands of an elephant foot layer from before that compensation, and those of other layers as the perimeters see them, so D includes the elephant foot compensation at that point and the half width of the line actually printed there. The islands contain the XY compensation (c' = c), except on an elephant foot layer with several regions: slicing keeps those islands from before a negative contour compensation and applies it to the perimeters only, so there c' is zero for contours.
  • A distance is accepted only within the range of the wall's own line: from half the narrowest line the generator prints to half the widest, widened by the elephant foot compensation of the layer, by the part of c missing from the islands, by half the difference between line width and spacing (Arachne keeps a precise outer wall that much deeper where it prints one line) and by the slicing resolution plus 1 µm. The narrowest line is half the nominal width for Arachne, which splits a wall into two lines narrower than its minimum bead width, and slightly under it for the classic generator, which prints narrow loops thinner; the widest is twice the nominal width for Arachne and the nominal width for the classic generator. A distance outside that range does not come from the wall's own surface: the wall is thinner than a line, or it lies on the boundary between two regions, which the islands do not contain. Such a point takes the nominal shift.
  • Every vertex is measured, and an edge longer than 0.5 mm (the step at which elephant foot compensation is resampled) also at points at most 0.5 mm apart along it. If they all follow the straight change between its vertices within the snapping radius, the edge stays one piece; otherwise they all split it.
  • A negative value is taken as zero. A perimeter whose values all equal the nominal shift within the snapping radius keeps the constant shift, so a wall at its nominal depth gives exactly the result of the nominal shift. A perimeter whose largest value is within the snapping radius keeps the centerline; a single point at zero does not change that.
  • The measurement is decided per loop. A loop with fuzzy skin is measured on its smooth centerline (see Fuzzy skin). A noisy line itself is never measured: the noise moves it off the smooth outline, so measuring would pull its points within the range back to the outline while the points outside it kept the noise. A loop without a smooth centerline on a layer where any region adds fuzzy skin to the outer walls of that kind of loop keeps the nominal shift, since nothing tells an unchanged loop from a noisy one that lost its centerline.
  • The islands are indexed once per layer and only on layers where a Precise Seam modifier has a region, and only loops that some modifier on the layer approaches are measured.

A shift within the snapping radius is treated as zero: extraction then clips the centerline itself. The preparation borrows the polygon and is used only while the polygon is unchanged: strong processing returns immediately after inserting its point, and weak processing collects all segments before it inserts anything. An invalid perimeter receives no Precise Seam processing.

Fuzzy skin

Fuzzy skin is applied by the perimeter generator, which resamples a loop and moves its points off the smooth centerline (Arachne's extrusion mode changes the line width instead). Only the noisy line reaches the seam placer, and a surface shifted from it would repeat the noise. The generator therefore keeps the centerline before texturing of an external loop whose points the texture changed, in ExtrusionLoop::untextured (classic traverse_loops(), Arachne traverse_extrusions(), which copies the junctions only where the layer has fuzzy skin on that kind of loop). A list of points equal to the printed one is not kept. The field is kept for every such loop, whether or not the object has Precise Seam volumes, because adding a volume does not regenerate perimeters (see Print invalidation). Copying, moving, reversing or turning the start of the loop keeps it, and so do the simplification and arc fitting of its paths after the generator, which leave the same textured loop; giving the loop other geometry must reset it.

For such a loop the preparation has two polygons: the smooth centerline, from which the surface is reconstructed and on which the shift is measured, clipping, binding, segments, lengths, Center and full containment are worked out; and the noisy loop, into which the results are inserted. Both are normalized alike (no repeated points, counterclockwise).

  • Pairs. A segment keeps the surface points its ends were carried from, and merging intervals keeps the pair of the outer end, also across vertex zero. An arc still collapses into its vertex, but the end keeps its real point on the arc: a zero-length segment has the two ends of its piece of arc, and separate pieces of one arc make one vertex point from the piece nearest the arc's start to the end of the farthest. A vertex point that continues a segment gives the segment's end its arc point. Left and Right take the pair of their end. Center, the middle by length of the smooth segment, takes as its pair the point of the shifted edge at the same parameter (shift profile included), the middle of the arc or bridge at a vertex (of the piece covered, for a zero-length segment), the point where the shifted edges meet at a vertex without either (collinear edges; the smooth point itself, as an emergency fallback, should the edge have no element left), or the crossing K in the dead stretch of a concave corner.

  • Transfer. The line through the surface point and the smooth point is intersected with the edges of the noisy loop within a window of the smooth point, and the crossing nearest to it is taken; an edge lying along the line gives its point nearest to the smooth point. The window is an estimate from the settings, not a measured distance or a proven bound, computed separately for contours and holes: only the regions that texture the loop's kind count, as FuzzySkin.cpp decides it. Regions texture a loop one after another, each over the result of the previous ones, so it adds up the amplitudes of their different noises (regions that differ only in which walls they texture make one noise). An amplitude is the thickness times the largest value of its noise module: Perlin, Billow and RidgedMulti add octaves and can exceed one. These bounds rest on the range libnoise states for its coherent noise, from -1 to 1. Arachne's combined mode moves a point by half its change of width, which adds half the smallest width it keeps. On top come the largest point distance, the farthest a chord cutting a convex corner passes from the smooth point, and a micrometre of rounding. There are three outcomes:

    • exact: such a crossing exists;
    • approximate: the pair coincides (the centerline path, where the surface is the centerline) or the line crosses nothing within the window; the nearest point of the noisy loop within the window is taken, and counted in the log;
    • failed: not even that; the point is a discarded fragment, with its counter, log marker and the type in the warning. A strong segment whose point fails takes no part; a weak zone with a failed boundary is dropped.
  • Strong modifiers choose the segment and the point on the smooth loop, ties included, and insert the carried point into the noisy one. Among candidates that are carried the noise never changes the winner; a candidate whose transfer fails drops out, and the next one wins.

  • Weak zones carry each boundary separately. Before anything is inserted, a policy, not a proven guarantee, tells some zones whose boundaries came out in the reverse order. It assumes that the points of a zone's true noisy arc lie within the window of the smooth zone, as its carried boundaries do; the window is an estimate. A short zone's true arc then stays within a circle around its smooth boundary, however much the noise lengthens it, while the arc round the rest of the loop leaves that circle wherever the loop spreads beyond it; its length tells nothing, as the noise may lengthen a stretch many times over. With a threshold of four windows on the smooth loop:

    • for a zone shorter than that, the circle lies around its smooth left boundary with the zone's length plus a window for radius. The zone is reversed when the noisy arc from its carried left boundary forward to its right one leaves the circle; otherwise it keeps its order when the arc from the right boundary forward to the left one leaves it; with both arcs inside, it is reversed when the first arc is the longer;
    • otherwise, for a zone whose rest of the loop is that short, the same holds around its smooth right boundary, with the rest's length plus a window for radius and the arcs swapped: the arc from the right boundary forward to the left one is the rest's;
    • otherwise the order is not checked; a transfer onto another part of the loop there is a limitation of the direct transfer.

    An arc leaves the circle when either carried boundary or a vertex of the noisy loop between them, across its start, lies outside; boundaries on one edge with the second behind the first make an arc round the whole loop. A reversed zone is reduced to its left boundary, a zero-length zone that types the one candidate there. This is a declared degradation, counted in the log: it happens, for example, for a piece of a convex corner's arc where the noisy loop cuts the corner inside it, since the lines through the corner then cross the noise behind it in the reverse order.

Segment extraction

extract_perimeter_segments() turns one modifier's regions on one layer into segments of the perimeter, each with its geometry and its position on the source contour. Both modifier kinds consume these segments; the extractor is told the modifier type so that it prepares only the data that type needs.

Surface reconstruction

The surface is the set of points on the air side at the shift d from the centerline. build_surface_line() builds it as a closed line whose every edge remembers its source:

  • Shifted edge. Each source edge moved along its normal into the air. With a constant shift along the edge, the shift is rounded once per edge, so the shifted edge is an exact integer translate of its source and keeps its parameters. Where a measured shift changes along the edge, the shifted edge is a chain of straight parts through the points moved by the shift at its vertices and at its measured interior points; each part maps linearly onto the range of parameters of the source edge between those points.
  • Arc. Where shifted edges diverge (a convex vertex as seen from the air), an arc around the vertex whose radius is the shift at that vertex, approximated by chords with a sagitta of at most 40 units. Both shifted edges take that shift at the vertex, so the line stays continuous; with no shift there they meet at the vertex itself. A reversal of direction turns by half a circle.
  • Crossing. Where shifted edges cross (a concave vertex) at a point K inside both of the parts meeting there, they end exactly at K: no part of them lies beyond it. A part trimmed this way covers only part of its range of the source edge, and its parameters are carried over proportionally. Both trims of one part must leave at least 4 units of it.
  • Bridge. At any other concave vertex (shifted edges crossing beyond the end of one of them, as in a fillet finer than the shift), a straight edge between the ends of the full shifted edges, carried onto the vertex like an arc. The shifted edges keep their tails beyond the crossing.

Each crossing is the end of a dead stretch: the part of the centerline around the vertex that has no surface of its own. It is recorded at once, with the elements of the surface line that end and start at K. Resolving these corners exactly matters on shallow corners, such as the many vertices of a tessellated hole: there the parts of the full shifted edges beyond K stay within micrometers of the surface, and a modifier boundary crossing them would split the segment.

The surface line is not filtered further: every part of it counts as surface, even where it comes closer than d to another part of the centerline. The centerline is itself the model contour shifted inwards by half the line width, so shifting it back by slightly less returns to that contour and does not fold: a concave fillet of radius r on the surface is a fillet of radius r + d on the centerline, and a sharp inner corner stays sharp and resolves exactly. The line folds only on corners that are not resolved exactly: a very sharp inner corner that the slicer bevels, a sharp change of the measured shift, or relief finer than the shift (see Known limitations). There the tails and bridges of the line stay part of it, and the user's rule that a modifier enters the wall by a clear depth keeps such corners out of play. A general offset of the polygon could not replace the surface line: it rounds and cuts corners and loses the link to source edges.

Clipping

Regions whose bounding box does not overlap the perimeter's, enlarged by the shift, are skipped. The surface line, as an open path closed at its start, is intersected with each remaining region by intersection_pl(), which clips open paths against an ExPolygon with its holes attached, using the nonzero rule. Clipping an open line yields only pieces of the surface, so a modifier crossing the whole object produces two separate pieces rather than a chord through the body. Holes in a modifier and several regions of one modifier simply produce more pieces. The line is cut at its start, so a piece crossing it arrives as two fragments. A border that only touches the surface can come back as a single point; such fragments carry no coverage and are dropped before binding. With a shift of zero the centerline's own clipping line is clipped instead, without offsets or contact rules.

Binding fragments to source edges

Clipper returns coordinates only. Insertion needs the source edge of every point, and coordinates alone are ambiguous where a contour visits the same point twice. Each fragment is therefore bound to the edges of the line it was clipped from (the surface line, or the centerline for a shift of zero), producing intervals: an edge index with a parameter range on that edge.

  • Exact path. For fragments with interior points, the second point is used as an anchor that must equal a source vertex exactly. Clipping keeps the vertices of an open path unchanged, including collinear ones. The following points must match successive source vertices in either direction; later occurrences of the anchor are tried if a sequence does not match. Only the two end cuts are projected onto their edges.
  • Projection path. Two-point fragments, and fragments the exact path cannot match, are bound by projection. The first source edge that holds both points of the first pair, with distinct parameters, establishes the edge and direction. Every following pair must continue on the same edge or cross to the neighboring edge at their actual shared vertex, in the same direction. A pair continuing on the same edge reuses the previous pair's parameter for their shared point, so the two projections of one point cannot differ.
  • Failure. A fragment that cannot be bound continuously is rolled back and discarded. Earlier fragments and other fragments are unaffected. The failure is counted, logged and reported to the user (see Diagnostics).

Two rare rounding cases are handled only after both paths have failed, so the normal path never pays for them:

  • Cut beside a vertex. When a modifier boundary crosses within about one coordinate unit of a source vertex, Clipper can place the cut at the vertex's height but a few units beside it. The end pair then collapses to the vertex's parameter or misses both neighboring edges. An end cut closer than the snapping radius to a vertex of the fragment's own chain is snapped to that vertex: either its neighbor in the fragment (the cut is a rounded copy of it and is dropped) or a vertex that shares a source edge with that neighbor. The neighbor wins whenever it is within the radius. Ends that are themselves source vertices and ambiguous choices are left unchanged. Binding is then retried once with the same strict rules, so a wrong candidate can only fail again.
  • Contact. A fragment that still fails but is shorter than the snapping radius is accepted as a contact and binds nothing. Insertion would collapse it onto one point anyway.

Both outcomes are recoveries, not failures: they show no user warning but leave a log marker.

Carrying the surface onto the centerline

Intervals on the surface line are carried onto the centerline through their source:

Surface Centerline
Shifted edge, parameters t0..t1 the same source edge, the same parameters (proportionally on a trimmed part or a part of a split edge)
Arc or bridge around a vertex that vertex, as a vertex point
Both ends of a dead stretch covered the whole centerline between them

A point of an edge with a constant shift moves back by subtracting that edge's integer shift, which is the same as following the normal. On an edge whose shift changes, the point is the one at the same parameter of the source edge.

The last rule covers the crossing point K of a concave corner: when the modifier covers the surface on both sides of K, the centerline around the vertex, which has no surface of its own, joins them. When only one side is covered, the segment ends under the modifier's crossing, outside the dead stretch. An end counts as covered when coverage ends within the snapping radius of it on the same edge of the surface line, so a modifier boundary passing exactly through K covers it.

Assembling segments

The intervals are sorted by edge and parameter. Intervals on the same occurrence of an edge are united when they overlap or meet, by parameter or at the same integer point; equal coordinates on different edges are never united. A vertex point adds no edge: next to coverage that reaches its vertex it disappears, and alone it forms a zero-length segment, a single point with no edges, where the modifier reached the surface only around a convex corner. Its strong target is the vertex in every mode, and as a weak zone it types the one candidate there. A parameter of 1 is stored as parameter 0 of the next edge, so intervals on adjacent edges meet exactly at their shared vertex. Consecutive intervals that meet form one PerimeterSegment, and the last segment is joined with the first when they meet at vertex zero, undoing the artificial cut of the clipping line.

Each segment keeps its polyline, the source edge of every polyline edge, and its begin and end positions on the source contour.

Full containment

A modifier that covers the whole perimeter has no boundaries on it. The policy follows seam painting, where a whole perimeter can be painted in either color:

  • Seam Enforced types the whole perimeter, like a perimeter painted green all round, with subdivision applied as described under Weak modifiers.
  • Seam Neutral types the whole perimeter Neutral, like an unmarked perimeter, clearing painting and lower zones.
  • Seam Blocked types the whole perimeter Blocked, like a perimeter painted red all round, overriding painting and lower zones. The seam cannot avoid such a perimeter: the seam placer compares Blocked candidates with each other like Neutral ones, so the seam is placed as on an unmarked perimeter. If the perimeter stays Blocked after all weak zones, it is reported in the user warning (see Diagnostics and warnings), so the user can check the modifier.
  • Seam Center, Left and Right are skipped with the full-containment warning: there is no intersection to place the point on.

Enforced, Neutral and Blocked take part in the usual priority order (see Weak modifiers).

The perimeter is fully contained when the united intervals cover every source edge from parameter 0 to 1, which is the case when the modifier covers the whole surface: every shifted edge and every dead stretch. A modifier that covers the whole centerline but leaves part of the surface outside gives ordinary segments. An uncovered part of a single arc carries onto one vertex, a gap of zero length, and so still counts as full containment. A modifier boundary that merely touches the perimeter counts as well:

  • At a vertex or on an axis-aligned edge, clipping splits the line exactly at the touch, the pieces meet at one point, and the coverage is complete.
  • On an inclined edge the touching point is usually not representable on the integer grid. The boundary pokes a few units across and leaves a real gap, so a single segment covers everything except that gap.

Weak insertion would collapse such a segment's boundaries onto one vertex and turn the intended zone into a single candidate, and strong would put the seam at the touch. A single segment is therefore also full containment in the cases where insertion collapses it, exactly up to edges shorter than 2 µm:

  • the uncovered length from its end to its begin is below 1 µm, or
  • the gap spans one vertex, or starts at a vertex and ends on the next edge, and both ends lie within 1 µm of the vertex that ends the first gap edge, since each end then snaps onto it from its own edge.

A cheap filter runs first: both cases bring the segment's ends within 2 µm of each other. A zero-length segment covers nothing and is never full containment, although its ends coincide.

Strong modifiers

For a strong modifier, the extractor prepares each segment's target point before anything is inserted, together with the source edge it lies on:

  • Left: the segment's first point.
  • Right: the segment's last point.
  • Center: the point at half the segment's arc length.

Arc length is the sum of Euclidean edge lengths, not the chord or a vertex count.

insert_strong_seam_point() selects the longest segment of the first modifier that has one; a zero-length segment loses to any other. Exactly equal lengths are resolved by the prepared target points: greater bed Y first, then smaller X; a complete tie keeps the first segment. Slice coordinates already include instance rotation and have the bed axes; centering and XY translation do not change this order. Nearly equal lengths are not treated as equal, so exact ties occur mainly on axis-aligned geometry. Geometrically equal segments, such as a symmetric modifier crossing both faces of a thin wall, differ only by rounding noise that varies between layers, so the chosen face may alternate. This is accepted deliberately: such a modifier is ambiguous by itself: more than one segment raises the "multiple intersections" warning. The user should make the modifier cross the perimeter once.

The selected point is inserted on its source edge. A point within 1 µm of an existing vertex is snapped to that vertex. Helper points are added 1 µm on both sides of it, except on an adjacent edge shorter than 2 µm, which already bounds the distance.

When the candidates are built, the candidate at the inserted point is the only enforced one and becomes the central enforcer; every other candidate is blocked. Every seam position mode therefore selects it. Alignment and random placement can still move the final position, so after alignment restore_precise_seam_positions() writes the exact point and its index back into every perimeter that has a strong seam.

Weak modifiers

collect_weak_modifier_segments() extracts the segments of every weak modifier before the polygon is modified, so all positions refer to the same contour. Each segment becomes a zone with a type and two boundaries, kept in application order, lowest priority first. Full containment of a weak modifier becomes a whole-perimeter zone at its place in that order: it has no boundaries and takes part in no insertion or helper step below. The boundaries carry their positions on the source contour; these remain as provenance after insertion and are not indices into the modified polygon.

prepare_weak_modifier_segments() then changes the polygon:

  1. Boundary insertion. Insertion events are sorted by decreasing source edge and parameter, and the polygon is modified from its end towards its start. A pending boundary's source index therefore stays valid. Vertex zero has the canonical position (0, 0) and is processed last, and a point on the closing edge is appended rather than inserted at index zero. A boundary within 1 µm of either endpoint of its current edge, an original vertex or a boundary inserted earlier, is snapped to that point, so coincident boundaries share a vertex. A zone narrower than 1 µm collapses into a single vertex.
  2. Helper points. A helper point is added 1 µm outside every boundary, unless the edge there is shorter than 2 µm, which already bounds it. The helpers keep the edges at a boundary short, so a seam placed along such an edge stays close to the boundary. Coincident boundaries share their helpers.
  3. Enforced subdivision. Zone types are resolved for the polygon's edges in priority order. The edges of a zone are those from its left boundary up to, but not including, its right boundary; a whole-perimeter zone types every edge. Enforced edges longer than SeamPlacer::enforcer_oversampling_distance (0.2 mm) are subdivided into steps of at most that length; shorter edges and existing vertices are kept. The regular seam placer then chooses the seam as for painted seams.

When candidates are built, painting assigns their types first. apply_weak_modifiers_to_perimeter() then overwrites the types of the candidates between the boundaries of each zone, both boundaries included, lowest priority first; a whole-perimeter zone types every candidate. Blocked and Enforced zones therefore take precedence over painting, and Neutral clears painting inside its zone.

A loop on which a candidate is left Enforced by a zone has exact ends (see Seam alignment): the zone ends at its inserted boundaries, so alignment and the Random position keep the seam between them. The mark is one per loop and is set after painting has typed the candidates. A run enforced on the same loop only by paint near the layer keeps its candidates, but the seam no longer passes its ends either. A zone reduced to a single candidate holds the aligned seam on that candidate: alignment cannot smooth its shift between layers, which may show where the loop differs from layer to layer, as with fuzzy skin.

Numeric tolerances

Coordinates are integers in scaled units: 1 nm by default, and 10 nm when a bed larger than 2147 mm switches SCALING_FACTOR. Both Precise Seam tolerances are deliberately defined in units rather than physical distances. Clipper truncates cuts to whole units at any scale, so the on-edge tolerance must follow the unit; the snapping radius scales with it to keep its margin over single-precision candidate coordinates, which are coarser on large beds. Distances quoted in this document in nanometers and micrometers assume the default unit; on large printers they are ten times larger. The enforced subdivision step is a physical distance and stays 0.2 mm.

Value Role
MACHINE_PRECISION_SQUARED (2.5 units², about 1.6 nm) A point lies on an edge if it is this close. It absorbs Clipper's truncation of cuts to whole units (under √2 units from the edge) and never bridges a real gap: a one-unit uncovered gap stays a gap.
TOLERANCE_LINEAR (1000 units, 1 µm) Insertion snaps points this close to an existing vertex, and helper points are placed this far from boundaries. The same radius bounds the rounding fallback, contacts and the sub-micron full-containment rule, so those decisions match what insertion would produce anyway. It is also the reach of a dead-stretch end, the smallest surface shift, and the agreement of measured shifts with the nominal shift and with a straight change along an edge.
SURFACE_MARGIN (5000 units, 5 µm) The reconstructed surface lies this far inside the model surface, so a modifier flush with a model face does not act.
SURFACE_ARC_SAGITTA (40 units) Maximum sagitta of the chords of surface arcs.
SHIFT_SAMPLING_STEP (0.5 mm) Largest spacing of shift measurements along an edge, the step at which elephant foot compensation is resampled.
Slicing resolution plus 1 µm Widens the accepted range of measured depths: perimeters are built on a contour simplified by the resolution.
enforcer_oversampling_distance (0.2 mm) Maximum step of enforced subdivision.

Raising the on-edge tolerance would not help with cuts beside a vertex: more points past a vertex would be clamped to its parameter and collapse. Lowering it would reject ordinary rounded cuts. The snapping radius is kept far above clipping precision for robustness: seam candidates hold single-precision coordinates, whose step is about 8 to 15 nm at typical object coordinates (about 0.25 µm 3 m from the object's centre, on large beds only), and weak boundaries and the strong point are located among the candidates by those coordinates, so distinct points must stay clearly distinct. 1 µm is also far below printing precision.

Diagnostics and warnings

One PreciseSeamWarnings instance is shared by all objects and layers of a SeamPlacer::init() call. After all objects are processed, SeamPlacer::init() prepares at most one warning text, available through precise_seam_warning(). G-code export issues it as one non-critical warning with the ID SlicingPreciseSeamWarning. It is a single line, "Precise Seam: . Seam placement may differ from expected.", because the export warnings dialog shows only the first line of each warning. Repeated warning events replace the notification instead of appending to it. Except for the "covers an entire perimeter" and "had no effect" causes, the causes name the modifier types involved, as the menu names them, in menu order and each type once, for example "(Seam Left, Seam Enforced)". The causes are:

  • failed to process some intersections (types): at least one fragment was discarded by binding. Other segments remain usable.

  • multiple intersections with a perimeter, only one was used (types): a Seam Center, Left or Right modifier had more than one segment on a perimeter (see Strong modifiers).

  • a perimeter is fully inside a modifier, the modifier was not applied to it (types): a Seam Center, Left or Right modifier was skipped for a perimeter (see Full containment).

  • Seam Blocked modifier "" of "