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:
class pyvcad.Convolve#

A Unary node that applies a convolution kernel to the continuous attributes of its child node.

This is highly useful for blending, blurring, or sharpening color or material distributions without affecting the raw signed distance field geometry.

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.

  • enable_cache (bool) – Toggles the internal volumetric LRU cache. Defaults to true.

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])
__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Convolve, child: pyvcad.pyvcad.Node, attributes: collections.abc.Sequence[str], kernel: pyvcad.pyvcad.ConvolveKernel, physical_radius: collections.abc.Sequence[typing.SupportsFloat]) -> None

  2. __init__(self: pyvcad.pyvcad.Convolve, child: pyvcad.pyvcad.Node, attributes: collections.abc.Sequence[str], kernel: pyvcad.pyvcad.ConvolveKernel, physical_radius: collections.abc.Sequence[typing.SupportsFloat], enable_cache: bool) -> None

cache_capacity(self: pyvcad.pyvcad.Convolve) int#

Gets the current cache capacity limit

set_cache_capacity(self: pyvcad.pyvcad.Convolve, capacity: SupportsInt) None#

Sets the cache capacity limit

set_use_cache(self: pyvcad.pyvcad.Convolve, enabled: bool) None#

Toggle the internal cache.

use_cache(self: pyvcad.pyvcad.Convolve) bool#

Check if the cache is active.

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.

  1. __init__(self: pyvcad.pyvcad.BoxKernel, radius: typing.SupportsInt) -> None

  2. __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#