Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 2.7 KB

File metadata and controls

78 lines (50 loc) · 2.7 KB

Architecture

Role in the stack

Addon Role
ofxPlotGenerators Pixel Generation + Direct path geometry (procedural)
ofxPlotFinders Raster / image → strokes (ofPath in plotter layers)
ofxPlotter Authoring, layers, export (ImageToPath::toStrokeDocument)
ofxPlotProcessors (this) Optimize paths before G-code

Geometry in the pipeline is ofPath where bezier curves are preserved wherever possible.

Affine processors (scale, rotate, translate, skew, layout) transform control points directly. Vertex-level processors (simplify, snap, clip, squiggles) tessellate internally when needed, then rebuild as lineTo paths.

Core types

StrokeDocument

  • paths — one ofPath per pen-down stroke
  • meta — parallel StrokeMeta (closed, allowReverse, locked, layerId, color, …)
  • bounds — cached AABB from path commands; call rebuildBounds() after edits

Helper accessors: pathStart(index), pathEnd(index), pathLengthMM(index) (tessellated length for metrics).

IPlotProcessor

Each processor implements:

  • id() — stable key (e.g. "line_merge")
  • displayName() — UI label
  • process(doc, options, result?) — in-place mutation
  • defaultOptions()ofJson defaults

ProcessorRegistry

Singleton registry of built-in processors. Lookup by id() for pipeline steps and UI.

PlotPipeline

Ordered list of { processorId, enabled, options }. Methods:

  • run(doc) / runFrom(doc, stepIndex)
  • runWithReport(doc) — per-step PlotMetrics before/after
  • loadPreset(path) / savePreset(path)
  • PlotPipeline::defaults() — merge + sort on, squiggles/filter off

PlotMetrics

pathCount, vertexCount, drawLengthMM, travelLengthMM — used for “travel saved” UI.

vertexCount and draw length are derived from tessellated outlines (for consistent metrics across curved paths).

LineIndex

Uniform-grid spatial index for path endpoint merge/sort (pathStartPt / pathEndPt).

Layer handling

Most geometry processors respect optional JSON filter:

"layer_ids": [1, 2]

If omitted or empty, all layers are affected. Merge/sort/shuffle run per layer in first-seen layer order.

Adding a processor

  1. Subclass IPlotProcessor under src/processors/
  2. Register in ProcessorRegistry.cpp
  3. Document options in Processors