Skip to content

Add implicit F-rep ops and Shape support#120

Open
chemiskyy wants to merge 6 commits intomainfrom
feature/frep-core
Open

Add implicit F-rep ops and Shape support#120
chemiskyy wants to merge 6 commits intomainfrom
feature/frep-core

Conversation

@chemiskyy
Copy link
Copy Markdown
Member

Introduce F-rep implicit operations and integrate implicit-field support into Shape. Adds new module microgen.shape.implicit_ops (boolean, smooth blending, batch_smooth_union, repeat, shell, blend, from_field, etc.) and comprehensive tests. Refactors microgen/shape/shape.py to carry optional implicit fields, provide evaluation, default generate_vtk/generate via marching-cubes -> CadQuery, boolean operators, smooth booleans, and transform helpers (translate/rotate/scale). Updates package exports and docs to expose implicit_ops and related helpers; re-exports ShellCreationError from tpms for backward compatibility.

chemiskyy and others added 5 commits April 16, 2026 15:53
Introduce F-rep implicit operations and integrate implicit-field support into Shape. Adds new module microgen.shape.implicit_ops (boolean, smooth blending, batch_smooth_union, repeat, shell, blend, from_field, etc.) and comprehensive tests. Refactors microgen/shape/shape.py to carry optional implicit fields, provide evaluation, default generate_vtk/generate via marching-cubes -> CadQuery, boolean operators, smooth booleans, and transform helpers (translate/rotate/scale). Updates package exports and docs to expose implicit_ops and related helpers; re-exports ShellCreationError from tpms for backward compatibility.
Introduce gradient-normalized SDF and a spatially-varying shell operator. Adds _fd_sdf (central finite-difference fallback), normalize_to_sdf (uses autograd.elementwise_grad when available, probes for deferred failures, falls back to FD; accepts epsilon to avoid division by zero), and variable_shell (returns |f(p)| - t(p)/2 using a provided thickness field). Also minor argument formatting cleanup for implicit boolean ops lambdas.
Replace the function-level deferred imports between Shape and implicit_ops
with module-level `from . import <other> as _alias` imports. Attribute
lookup (`_ops.union`, `_shape.Shape`) happens at call time, so the
circular reference resolves naturally once both modules finish loading.
@kmarchais kmarchais force-pushed the feature/frep-core branch 2 times, most recently from 9abc656 to dbcd0d9 Compare April 17, 2026 08:23
Copy link
Copy Markdown
Member

@kmarchais kmarchais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great improvement! Maybe we could add autograd as optional dependency.

1) implicit_ops: Probe dfdx, dfdy and dfdz when normalizing to an SDF to catch deferred failures where autograd wraps only the argnum-th argument (prevents crashes from non-autograd ops on y/z).

2) shape: Clarify in evaluate() that coordinates are in the field's local frame. When rotating a Shape, recompute the axis-aligned bounding box by rotating the 8 box corners instead of conservatively keeping the old bounds. Also adjust bounds handling for negative scale factors (swap min/max per axis) so bounds remain correct after scale/rotation transforms.
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.

2 participants