Tree — attribute nodes#
Attribute nodes are Unary scene nodes: each wraps a child subtree and changes how continuous attributes are produced or post-processed for that geometry. They are not the same thing as attaching an Attribute with Node.set_attribute()—that API defines field values on a node (see Attributes). Attribute nodes instead implement attribute-side operators in the tree: converters, lookup tables, or spatial filters that sit between evaluation and the rest of the pipeline.
AttributeModifier applies an attribute converter (for example, mapping one named field into another, such as HU to RGBA via a lookup table). Convolve applies a convolution kernel over attribute samples in a neighborhood so you can smooth, blend, or emphasize material or color distributions without altering the signed-distance geometry of the child.
Unary attribute nodes#
- class pyvcad.AttributeModifier#
An attribute modifier node that applies a converter to its child’s attributes.
Note: Setting or getting attributes directly on this node via set_attribute or get_attribute is not supported and will raise an error.
- __init__(self: pyvcad.pyvcad.AttributeModifier, converter: AttributeConverterBase, child: pyvcad.pyvcad.Node) None#
Constructor. Creates an AttributeModifier with a converter and a child node.
- Parameters:
converter (AttributeConverterBase) – The attribute converter to apply.
child (Node) – The child node to be modified.
- class pyvcad.Convolve#
A Unary node that applies a convolution kernel to the continuous attributes of its child node.
Convolve is useful for blending, blurring, or sharpening scalar fields, colors, or material distributions without affecting the raw signed distance field geometry. It is the generic, flexible sibling of the Blend node; both share the same precomputed child-attribute voxel grid, but Convolve performs a per-sample weighted sum over arbitrary kernel weights while Blend specializes in a fast separable-blur fast path that moves all per-sample cost into prepare(). Use Blend for the common box-blend case; use Convolve when you need custom kernel weights or a non-blur operation.
During prepare() the child’s targeted attributes are parallel-sampled onto a dense voxel grid. At sample() time each kernel tap becomes a cheap flat-memory trilinear grid lookup instead of a full child-tree traversal, which makes the node orders of magnitude faster than a naive implementation.
- Parameters:
child (Node) – The node to process.
attributes (list[str]) – Names of the attributes to target. Pass an empty list to target all.
kernel (ConvolveKernel) – The kernel to apply.
physical_radius (list[float]) – [rx, ry, rz] physical bounds (in mm) that the kernel spans.
override_voxel_size (list[float], optional) – Optional [x, y, z] voxel size (mm) for the internal precomputed grid. Sparser than the tree sampler’s voxel_size saves memory; trilinear interpolation preserves smoothness at sample time. Defaults to the tree sampler’s voxel_size.
Example
>>> from libvcad import pyvcad as pv >>> kernel = pv.BoxKernel(2) >>> blur_node = pv.Convolve(my_shape, ['Temperature'], kernel, [5.0, 5.0, 5.0]) >>> # Coarser precomputed grid to save memory on a very large scene: >>> blur_node = pv.Convolve(my_shape, ['Temperature'], kernel, [5.0, 5.0, 5.0], override_voxel_size=[1.0, 1.0, 1.0])
- __init__(self: pyvcad.pyvcad.Convolve, child: pyvcad.pyvcad.Node, attributes: collections.abc.Sequence[str], kernel: pyvcad.pyvcad.ConvolveKernel, physical_radius: collections.abc.Sequence[SupportsFloat], override_voxel_size: collections.abc.Sequence[SupportsFloat] | None = None) None#
Convolution kernels#
Kernels describe the spatial stencil Convolve uses (uniform box averaging or explicit per-voxel weights).
- class pyvcad.ConvolveKernel#
- __init__(*args, **kwargs)#
- get_radius_x(self: pyvcad.pyvcad.ConvolveKernel) int#
Gets the X radius of the kernel.
- get_radius_y(self: pyvcad.pyvcad.ConvolveKernel) int#
Gets the Y radius of the kernel.
- get_radius_z(self: pyvcad.pyvcad.ConvolveKernel) int#
Gets the Z radius of the kernel.
- class pyvcad.BoxKernel#
A Box Kernel acts as a simple uniform average over a local radius volume.
- Parameters:
radius (int) – Uniform radius in all three axes. If set to 1, samples a 3x3x3 grid.
Example
>>> from libvcad import pyvcad as pv >>> kernel = pv.BoxKernel(1)
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pyvcad.pyvcad.BoxKernel, radius: typing.SupportsInt) -> None
__init__(self: pyvcad.pyvcad.BoxKernel, rx: typing.SupportsInt, ry: typing.SupportsInt, rz: typing.SupportsInt) -> None
- class pyvcad.CustomKernel#
A Custom Convolution Kernel created from an array of explicit weights.
- Parameters:
weights (list[float]) – A flattened list of 3D kernel weights.
rx (int) – The X radius. The array should have size (2*rx+1)*(2*ry+1)*(2*rz+1)
ry (int) – The Y radius.
rz (int) – The Z radius.
Example
>>> from libvcad import pyvcad as pv >>> target_size = 27 # 3x3x3 >>> kernel = pv.CustomKernel([1.0]*target_size, 1, 1, 1)
- __init__(self: pyvcad.pyvcad.CustomKernel, weights: collections.abc.Sequence[SupportsFloat], rx: SupportsInt, ry: SupportsInt, rz: SupportsInt) None#