Skip to content

Fluent constructors for lattice and TPMS families#136

Open
kmarchais wants to merge 4 commits into
mainfrom
refactor/2.0-lattice-tpms-constructors
Open

Fluent constructors for lattice and TPMS families#136
kmarchais wants to merge 4 commits into
mainfrom
refactor/2.0-lattice-tpms-constructors

Conversation

@kmarchais
Copy link
Copy Markdown
Member

Summary

Replaces the long-positional-argument constructors on the lattice and TPMS families with required-positional __init__ + chained with_* setters. Resolves PLR0913 without noqa.

Changes

Lattice family

  • AbstractLattice.__init__(*, center, orientation) only — all geometry params via .with_strut_radius, .with_strut_heights, .with_cell_size, .with_strut_joints, .with_density, .with_base_vertices, .with_strut_vertex_pairs
  • CustomLattice(base_vertices, strut_vertex_pairs, *, center, orientation) — required topology positional, rest chained
  • Vertex/strut/rotation arrays computed lazily on first access; setters invalidate caches
  • Density-to-radius root-find triggered lazily by the strut_radius property

TPMS family

  • Tpms(surface_function, *, center, orientation); chained with_offset, with_phase_shift, with_cell_size, with_repeat_cell, with_resolution, with_density
  • CylindricalTpms(radius, surface_function, ...), SphericalTpms(radius, surface_function, ...) — theta / phi auto-snap moved into overridden _init_cell_parameters
  • Sweep(curve_points, surface_function, radial_max, ...) plus .with_seed_normal, .with_n_curve_samples
  • Infill(obj, surface_function, ...) overrides with_cell_size / with_repeat_cell to derive the other from obj.bounds
  • GradedInfill(obj, surface_function, ...) exposes .with_gradation(offset_skin, offset_core, transition, smoothness)
  • Last-set-wins for mutually exclusive pairs (offset vs density, cell_size vs repeat_cell on Infill)
  • Grid built eagerly with defaults; setters rebuild grid as needed and reapply callable offsets

Misc

  • _BBox converted to a dataclass
  • pyproject.toml: PLR0913 added to [tool.ruff.lint] extend-select
  • 22 example files and 58 test-site calls rewritten to the fluent API

Notes

@kmarchais kmarchais force-pushed the refactor/2.0-lattice-tpms-constructors branch from 84e1ec0 to 2c24c43 Compare May 12, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant