Conversation
Add the implicit_shape module to the shape package and re-export ImplicitShape, the implicit_shape symbol, and batch_smooth_union at the microgen top-level. Update imports and __all__ in microgen/__init__.py and microgen/shape/__init__.py so implicit shapes and the batch smoothing helper are publicly available.
Add documentation for the implicit shapes (F-rep) feature: a new examples page (docs/examples/implicit_shapes.rst) with included example scripts and images, and a comprehensive tutorials section (docs/tutorials.rst) demonstrating primitives, booleans, smooth blending, batch union, transforms, utilities, and TPMS composition with runnable Jupyter cells. Also expose microgen.shape.implicit_shape in the API docs (docs/microgen.shape.rst) and add the new examples page to the docs index (docs/index.rst). This surfaces the new implicit_shape API and usage patterns for users.
Add three new example scripts demonstrating the F-rep implicit modeling utilities and comparisons to strut lattices. - examples/ImplicitShapes/primitives_and_booleans.py: Shows primitive implicit shapes (sphere, box, capsule), hard boolean ops (union, intersection, difference) and smooth blending, plus a batch smooth-union demo combining many spheres. - examples/ImplicitShapes/trabecular_bone.py: Generates a Voronoi-based trabecular-bone-like scaffold (with optional Lloyd relaxation), builds capsules and joint spheres from Voronoi edges/vertices, combines them with batch smooth union and intersects with a clip box, then meshes for visualization. - examples/Lattices/implicit_lattice.py: Builds implicit cubic, BCC and octet-truss lattices from capsule/sphere primitives (batch smooth union), compares implicit vs original strut meshes, and sweeps the smoothness parameter k for visual comparison. Examples rely on numpy, pyvista, scipy.spatial.Voronoi and the microgen implicit-shape utilities for construction and visualization.
Add implicit_basic_factory to the shape package and the top-level microgen package exports. The change imports implicit_basic_factory in microgen/shape/__init__.py and microgen/__init__.py and appends it to their __all__ lists so the factory is publicly available from both microgen.shape and the top-level microgen namespace.
Introduce a new implicit primitive factory and wire shape-to-implicit conversions. Adds microgen/shape/implicit_basic_factory.py implementing ImplicitShape factories (implicit_sphere, implicit_box, implicit_cylinder, implicit_plane, implicit_torus, implicit_capsule, implicit_ellipsoid) as SDF-based functions with reasonable bounds. Adds to_implicit methods to Box, Capsule, Cylinder and Ellipsoid that build the corresponding ImplicitShape, apply orientation (as ZXZ Euler angles) and translation. Also updates TYPE_CHECKING imports to reference ImplicitShape. Useful for converting existing geometric shapes to implicit fields for sampling/boolean ops.
Change Tpms to inherit from ImplicitShape (import implicit_shape.ImplicitShape) and initialize implicit-interface attributes for compatibility. The constructor now sets self._func as a lambda wrapping surface_function with k_x/k_y/k_z scaling and phase shifts, and computes self._bounds from cell_size and repeat_cell. This enables Tpms instances to be used where an implicit field/bounds are expected.
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.
This pull request adds comprehensive support and documentation for implicit (F-rep) shape modeling in the
microgenlibrary. It introduces new example scripts, expands the documentation with detailed tutorials and API references for implicit shapes, and updates the package's public API to expose new implicit modeling utilities and classes.Documentation Enhancements:
implicit_shapes.rstwith worked examples and images for primitives, boolean operations, lattices, and trabecular bone using implicit modeling.tutorials.rst) with a new section on implicit shapes, covering conversion, boolean operations, smooth blending, transforms, utilities, and TPMS composition, including executable code blocks.New Example Scripts:
primitives_and_booleans.pydemonstrating creation and visualization of implicit primitives, boolean operations, smooth blending, and batch smooth union.implicit_lattice.pyshowing construction of BCC, Octet-Truss, and Cubic lattices using implicit capsules and smooth unions, with comparison to strut lattices and smoothness parameter sweeps.trabecular_bone.pyfor generating a Voronoi-based trabecular bone structure using implicit capsules and spheres, combined with smooth union and intersection.API and Package Updates:
ImplicitShape,batch_smooth_union,implicit_shape, andimplicit_basic_factoryin the mainmicrogenandmicrogen.shapemodules and updated their__all__lists for public API access. [1] [2] [3] [4] [5] [6] [7]