Open
Conversation
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.
9abc656 to
dbcd0d9
Compare
kmarchais
approved these changes
Apr 17, 2026
Member
kmarchais
left a comment
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.