Cuboid
An axis-aligned box in 3D, optionally with rounded edges and corners: blocks, plates and chamber walls.
Cuboid(midpoint, side_lengths, fillet=r) rounds the twelve edges and eight corners with
radius r, up to half the shortest side. The level set is the exact signed distance with or
without the fillet.
import numpy as np
from simgeometry import Cuboid, GeometryCollection
block = Cuboid(midpoint=(0.0, 0.0, 0.0), side_lengths=(2.0, 1.0, 0.4))rounded = Cuboid(midpoint=(0.0, 1.5, 0.0), side_lengths=(2.0, 1.0, 0.4), fillet=0.15)print("volume:", block.volume(), " rounded:", round(rounded.volume(), 4))print( "corner inside:", block.contains((0.99, 0.49, 0.19)), rounded.contains((0.99, 1.99, 0.19)),)assert np.isclose(block.signed_distance((1.5, 0.0, 0.0)), 0.5)volume: 0.8 rounded: 0.7389corner inside: True Falseimport plasma_plotsimport pyvista as pv
pv.OFF_SCREEN = True # render without a window, e.g. on a docs server
blocks = GeometryCollection({"sharp": block, "fillet 0.15": rounded})plotter = blocks.show_3d( backend="pyvista", display=False, resolution=64, show_bounds=False)plasma_plots.scene(plotter, alt="A box with sharp edges and one with rounded edges")