# Concept: STL boundary selection and dispensing path preparation

Date: 2026-10-26 | Status: proposal for review, not implemented

## Purpose

Help an engineer turn a part boundary into an inspectable tool path with less
manual tracing and point teaching. The user converts STEP to STL externally.
The first proposed application is adhesive/sealant dispensing; the user has
not yet confirmed the application or a robot/controller.

The output is a geometry-based path proposal with tool poses and process
parameters. It is not yet a validated executable robot program.

## Requirements and proposed defaults

Confirmed requirements:

- STL input replaces direct STEP input for this stage.
- Users choose top-face perimeter, top-view silhouette, or height section.
- Silhouette curves retain actual 3D surface positions.
- Show all candidates and allow individual selection, including holes.
- Accept offsets, tool angle, approach, departure, and speed.
- Generated-path deviation target is 100 microns (0.1 mm).

Proposals requiring review:

- Start with dispensing, millimetres, and an explicit part coordinate frame.
- Evaluate accuracy against the mesh-derived intended path for this stage.
- Export neutral JSON plus an inspectable CSV waypoint file.
- Start with planar offsets, then validate curved-surface offsets separately.
- Keep camera integration and robot postprocessing for a later stage.

## How the user works

1. Import STL. Select its units, confirm dimensions, and inspect mesh warnings.
2. Set the part origin and top direction using visible coordinate axes.
3. Choose an extraction mode and its parameters.
4. Inspect numbered, colored contour candidates. Select loops or segments;
   view closure status, length, height range, and any ambiguity.
5. Choose travel direction and start point for each selected contour. Select
   the support surface/side used to determine offset and tool orientation.
6. Enter lateral offset, standoff, tool angles, approach/departure distances,
   and process/transfer speeds.
7. Inspect the path, tool axes, process state, and separate transfer segments.
   Preview remains paused until the user starts it.
8. Validate and export. Invalid candidates retain actionable controls: change
   selection, adjust parameters, reverse direction, or return to input checks.

Check degenerate/duplicate triangles, winding, non-manifold edges, open
boundaries, and self-intersections. Repairs or vertex welding require explicit
selection and recorded tolerances; do not silently smooth or remesh the input.

```text
STEP -- external conversion --> STL
                                |
                     units + mesh checks + frame
                                |
              choose perimeter / silhouette / section
                                |
                  inspect and select 3D contours
                                |
                   offset + orientation + motion
                                |
                     preview + deviation checks
                                |
                      JSON + CSV path proposal
```

## Three extraction modes

| Mode | User input | Proposed processing | Result |
|---|---|---|---|
| Top-face perimeter | Top direction, clicked surface region, region-growth settings | Grow a connected triangle region; find edges with only one incident triangle inside that region | Outer and inner region boundaries in 3D |
| Top-view silhouette | Viewing direction | Identify mesh contour candidates, resolve visibility and projected overlaps, retain original triangle/edge provenance | Visible outline segments at their actual 3D positions |
| Section at height | Plane origin, normal, signed height | Intersect mesh triangles with the plane; assemble the resulting segments | Planar curves embedded in 3D |

An STL has triangles, not original CAD faces. Top-face selection therefore means
selecting a mesh region. Angle thresholds and manual refinement may be needed,
especially for fillets and curved surfaces. A closed solid does not need open
mesh edges to have a selectable surface-region perimeter.

Silhouette extraction must not simply flatten geometry and assign one height.
Changes in visibility may split a projected outline into disconnected 3D
segments. At sharp edges, the supporting face normal is not unique; the user
must choose the process side. Keep open segments selectable, flag branches,
and do not connect them automatically as dispensing motion.

Section extraction must handle coplanar triangles and vertex/edge tangencies
deterministically. Merge points only within a documented numerical tolerance,
avoid merging nearby distinct loops, and report unresolved branches.

## Path construction

Maintain two objects: the extracted source contour and the intended continuous
process path after offsets. Sample the latter adaptively to create export
waypoints. Retain source triangle/segment IDs for inspection and validation.

Use these proposed conventions:

- Right-handed part frame, user-defined +Z up. UI positions in mm, angles in
  degrees, speeds in mm/s, and time in seconds.
- TCP at the nozzle tip. Tool +Z points from the nozzle body through the tip.
- Zero tilt points tool +Z opposite the chosen outward support normal.
- STL normals are faceted. Distinguish per-triangle normals from estimated
  smooth normals; any normal smoothing needs separate angular criteria and
  explicit preview. Positional tolerance alone does not bound tool-angle error.
- Lead tilts the tool axis toward travel; side tilt points left along travel.
  Define left using the support normal crossed with the path tangent.
- Build an orthonormal reference tool frame from tangent and normal. Document
  one rotation composition order, including roll, before implementation.
  Preview the axes; store exported orientation as normalized quaternions with
  explicit component order and frame direction.
- Lateral offset is separate from normal standoff. Planar loops offer
  inside/outside controls; directed segments offer left/right controls.
- Curved-surface offsets require a defined surface-distance rule and a support
  region. Define these before that stage; a fixed XYZ translation is not an
  equivalent substitute.
- Keep process path, approach, departure, and transfers as distinct segments.
  Approach/departure use the outward normal at the endpoint as a proposed
  default. Transfers have process output off and are not collision-validated.
- Preserve corners or use explicitly chosen fillets that become part of the
  intended reference path. Flag offset intersections, collapsed loops, normal
  flips, and undefined tangents. No silent smoothing or path bridging.
- Let users choose closed-loop start points. Reversing travel recomputes the
  travel-relative orientation consistently. Bead overlap at a seam remains a
  process parameter to define later.

## Accuracy and acceptance

The target is maximum positional deviation <= 0.1 mm, not average error and
not a physical robot accuracy claim. Position accuracy does not establish
orientation accuracy; angular limits need a separate definition.

For this stage the proposed reference is the intended continuous mesh-derived
process path, including requested offset and standoff. Validate the entire
exported polyline, including segment interiors, in both directions against the
corresponding reference path. Also check traversal order and connectivity: a
small geometric distance alone does not prove a correct path.

Use an initial adaptive sampling target of 0.025 mm as engineering margin, not
as an acceptance certificate. The final checker must independently bound or
verify the maximum deviation; sparse point checks alone cannot prove the bound.
Verify exported/reloaded coordinates and orientations, not only in-memory data.

STL cannot recover curvature or detail lost during STEP conversion. Record the
CAD exporter settings and request a maximum tessellation deviation where the
exporter supports one. CAD-to-STL error, boundary-selection error, and path
sampling error are separate. Passing the mesh-relative test does not establish
0.1 mm accuracy against the STEP model. End-to-end CAD accuracy requires an
independent CAD comparison or a justified combined error budget.

## Test parts and acceptance evidence

| Part | Required evidence |
|---|---|
| Rounded flange with opening and bolt holes | All expected loops appear and remain individually selectable; known dimensions and offsets match |
| Stepped housing | Perimeter, silhouette, and section give the expected distinct curves |
| Sloped/curved cover | Silhouette retains varying Z; support selection and normal changes are visible |
| Concave part with narrow slots | Invalid offsets are detected; nearby loops are not accidentally merged |
| Overhang or overlapping projected regions | Visibility splits are retained without false 3D connections |
| Damaged or incorrectly scaled mesh | Useful diagnostics and recovery controls; no automatic geometry alteration |
| One real production part | Engineer approves selected contours and reports remaining manual steps |

Repeat relevant tests after changing the part frame and reversing travel.
Test plane tangencies, multiple components, and export round trips. Compare
independently built reference fixtures with extraction results; do not validate
only against the same algorithm's intermediate output.

## Export proposal

JSON is the authoritative neutral format. Include schema version, source file
identity, units, part frame, contour provenance, extraction settings, offset
rules, intended path representation, waypoint poses, quaternion convention,
segment types, speeds, process state, and validation results.

CSV provides one pose per row with contour/segment IDs, XYZ, quaternion
components, speed, and process state. Include frame and unit information in an
accompanying metadata file. CSV is a review/interchange representation, not a
controller program. Neither format claims timing or acceleration feasibility.

## Reuse and implementation stages

Use existing Open3D STL import, mesh diagnostics, section slicing, rendering,
and intersection queries where appropriate. Add only the missing region
selection, contour assembly/visibility, and validation logic after evaluating
existing code. No CAD kernel is required for the current STL-input proposal.

1. Import, explicit units/frame, mesh diagnostics, and reference test fixtures.
2. Section and planar region perimeter extraction with selectable candidates.
3. Visible silhouette extraction retaining actual 3D provenance.
4. Planar offsets, tool pose preview, approach/departure, and neutral export.
5. Curved support surfaces and their offset/orientation rules, validated
   separately with the same accuracy target.

All three extraction modes remain in the proposed scope; stages are sequencing,
not removal of requirements. Check device support per reused operation. Do not
promise universal CPU/CUDA/SYCL coverage or silently transfer geometry between
devices. Keep robot-specific workflow code in an external prototype layer;
Open3D library contributions must remain general 3D processing functionality.

## Deferred work and open decisions

Camera pose estimation, camera-to-robot calibration, robot postprocessors,
inverse kinematics, reachability, collision checking, acceleration/jerk limits,
and material-flow tuning are later work. A future placement transform rotates
both positions and tool orientations into the measured part pose.

Before implementation, confirm dispensing as the first process, approve the
mesh-relative accuracy definition, supply representative STL files with units,
define curved offset distance and rotation composition, and choose the first
prototype interface. Robot/controller selection is needed before executable
program export, not before geometry extraction research.

Measure discovery value by recording manual contour corrections, setup time,
and remaining path edits on the production part. No savings are claimed until
those observations exist.
